手机版
你好,游客 登录 注册
背景:
阅读新闻

Nginx+Apache实现网页动静分离

[日期:2013-08-11] 来源:oschina.net  作者:alanlqc [字体: ]

三、安装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 的下载地址请点这里

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款