三、安装PHP(可选安装PHP-FPM)
# sudo yum install php
# sudo /etc/init.d/httpd restart
FPM安装详见 http://my.oschina.net/alanlqc/blog/148126
四、测试
静态页面:
# echo "This is 192.168.85.83" > /data/www/index.html
动态页面:
# echo "<?php phpinfo(); ?>" > /var/www/html/info.php
通过curl -I 可以看到访问静态页面的时候是通过nginx处理的
# curl -I http://192.168.85.83
HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Mon, 29 Jul 2013 08:42:27 GMT
Content-Type: text/html
Content-Length: 22
Last-Modified: Sun, 28 Jul 2013 19:17:58 GMT
Connection: keep-alive
Expires: Tue, 13 Aug 2013 08:42:27 GMT
Cache-Control: max-age=1296000
Accept-Ranges: bytes
由于动态页面是通过nginx进行反向代理交给apache处理,所以返回显示的也是nginx
# curl -I http://192.168.85.83/info.php
HTTP/1.1 200 OK
Server: nginx/1.0.15
Date: Mon, 29 Jul 2013 08:43:34 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.3.3
验证php是通过apache 处理的:
关闭apache 再测试访问php页面,看到访问不到php,但是能访问到静态页面
# sudo /etc/init.d/httpd stop
Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里