Php5.6与Apache2.4
*
一,准备
1,下载php-5.6.27-Win32-VC11-x64.zip
2,httpd-2.4.23-win64-VC14.zip
地址:http://www.apachelounge.com/download/
3,之前安装过vcredist_x86.exe (Microsoft Visual C++ 2012 Redistributable (x86) - 11.0.61030)
此处略过,如果没有,就需要安装了
二,配置
1,path添加php
在系统环境变量PATH中添加 ;D:\php;D:\php\ext,
在php中
2,
修改D:\software\WebServer\apache\Apache24\conf\httpd.conf.
把ServerRoot这行修改为 ServerRoot "D:\software\WebServer\apache\Apache24", 双引号之间的就是你的apache放置的位置
多处有这样的路径,建议整体替换
D:\software\WebServer\apache\Apache24\bin>httpd.exe AH00558: httpd.exe: Could not reliably determine the server's fully qualified domain name, using fe80::8cf8:2311:ec23:abf1. Set the 'ServerName' directive globally to suppress this message D:\software\WebServer\apache\Apache24\bin>httpd.exe
有错误,配置以下,地址可以随便取
ServerName localhost:8082
3,
修改D:\Apache24\conf\httpd.conf.
把DocumentRoot按照下面的内容修改:
DocumentRoot "d:/Apache24/htdocs"
<Directory "d:/Apache24/htdocs">
把Listen Port修改为:Listen 8080
4,
# php5 support
LoadModule php5_module D:/php/php5apache2_4.dll
AddType application/x-httpd-php .php .html .htm
# configure the path to php.ini
PHPIniDir "D:/php"
5,我没有做这步,直接在apache的bin目录,输入httpd.exe回车运行的
保存httpd.conf, 重启Apache服务。
小技巧:d:\apache24\bin\httpd.exe -k install, 这句可以把apache添加到系统服务里去。(要以管理员身份运行)
C:\Windows\system32>d: D:\>cd D:\software\WebServer\apache\Apache24\bin D:\software\WebServer\apache\Apache24\bin>httpd.exe -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. D:\software\WebServer\apache\Apache24\bin>
6,在浏览器中打开 127.0.0.1:8082, (我的监听端口是8082)是不是能看到it works,这说明你的apache已经工作了。
三,配置虚拟主机多站点
1,在apache的httpd.conf中打开vhost的配置
# Virtual hosts Include conf/extra/httpd-vhosts.conf
2,打开conf/extra/httpd-vhosts.conf文件,这是默认的示例,我们需要改
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "c:/Apache24/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "c:/Apache24/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost>
*
<VirtualHost *:8082> DocumentRoot "D:\software\WebServer\apache\Apache24\htdocs\builder_front\dist" ServerName 127.0.0.2 </VirtualHost>
***********************
遇到的问题:
1,配置虚拟主机后,一直不能访问,我放在不同于apache的盘符,后来移到了htdocs目录下
并且开始
<VirtualHost *:8082>和ServerName localhost:8082
开始都是80,但是listen是8082,然后servername www.baidu.com:80
一直不能访问,
改为了一致端口8082就可以
还有一个大小目录包含的问题,在其下的目录下才有权限
# # "D:/software/WebServer/apache/Apache24/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # <Directory "D:/software/WebServer/apache/Apache24/"> AllowOverride None Options None Require all granted </Directory>
*
备注:公众号清汤袭人能找到我,那是随笔的地方