windows 下配置 apache2.4 和php

1.修改apache conf/http.conf文件


Define SRVROOT “C:\Users\Administrator\Desktop\server\apache”


LoadModule php5_module “C:\Users\Administrator\Desktop\lnmp\php-5.6.20-Win32-VC11-x64\php5apache2_4.dll”
PHPIniDir “C:\Users\Administrator\Desktop\lnmp\php-5.6.20-Win32-VC11-x64”

把php.ini-development复制一份,重新全名为 php.ini


AddType application/x-httpd-php .php

修改文件夹默认首页文件,添加 index.php作为默认首页

<IfModule dir_module>
DirectoryIndex index.php index.html

apache 不列出目录 把 Options Indexes FollowSymLinks 改为

Options FollowSymLinks

只需要将上面代码中的 Indexes 去掉,就可以禁止 Apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了。Indexes 的作用就是当该目录下没有 index.html 文件时,就显示目录结构,去掉 Indexes ,Apache 就不会显示该目录的列表了。

重要 :在httpd中加入以下两个参数!

# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and
# will not recycle sockets between connections. This is useful for network
# adapters with broken driver support, as well as some virtual network
# providers such as vpn drivers, or spam, virus or spyware filters.
AcceptFilter http none
AcceptFilter https none

cmd 命令把 apache 添加到服务

httpd.exe -k install

其实可以httpd -help 查看命令帮助


Leave a Reply