抱歉,您的浏览器无法访问本站

本页面需要浏览器支持(启用)JavaScript


了解详情 >

Windows 下 Apache 服务器安装配置

下载

Apache 官方仅提供源代码,需要编译好的安装包需通过第三方下载,下载完成后解压文件,例如:E:/WinService/Apache24

配置

打开 Apache24/conf/httpd.conf 文件,Apache 默认配置路径是 c:/Apache24 ,如果和当前路径不同则修改为当前路径。

注意路径中的斜杠

安装启动 Apache 服务

以管理员身份运行 CMD ,进入 E:/WinService/Apache24/bin 目录,执行命令:

httpd -k install

安装成功提示:

Installing the 'Apache2.4' service
The 'Apache2.4' service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.

执行命令 net start apache2.4 启动服务,启动成功后提示:

The Apache2.4 service is starting.
The Apache2.4 service was started successfully.

打开浏览器输入:localhost127.0.0.1

页面显示:It works! 则运行成功。

执行:httpd.exe -t 可以检测是否存在其它问题。

卸载 Apache 服务

httpd.exe -k uninstall

端口设置

监听端口可以设置多个,例如:

Listen 80
Listen 8080
Listen 8090

网站根目录

默认网站根目录:/htdocs,修改 httpd.conf 文件

DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">

默认访问文件

默认访问文件:index.html

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

目录浏览

默认开启目录浏览

Options Indexes FollowSymLinks

需要关闭的话就在前面添加#注释即可。

评论