免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2165 | 回复: 3
打印 上一主题 下一主题

[Web] nginx无法解析php,求高人协助 [复制链接]

论坛徽章:
8
数据库技术版块每日发帖之星
日期:2015-12-22 06:20:00数据库技术版块每日发帖之星
日期:2015-12-23 06:20:00数据库技术版块每周发帖之星
日期:2016-02-03 16:55:09数据库技术版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-08-13 06:20:00数据库技术版块每日发帖之星
日期:2016-08-15 06:20:00IT运维版块每日发帖之星
日期:2016-08-16 06:20:00IT运维版块每日发帖之星
日期:2016-08-17 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-10-24 02:30 |只看该作者 |倒序浏览
本人在虚拟机通过源码方式安装nginx和php

nginx的配置文件如下:
vim /usr/local/nginx/conf/nginx.conf



  1. #user  nobody;
  2. worker_processes  4;

  3. error_log  logs/error.log;
  4. #error_log  logs/error.log  notice;
  5. #error_log  logs/error.log  info;

  6. pid        logs/nginx.pid;


  7. events {
  8.     worker_connections  1024;
  9. }


  10. http {
  11.     include       mime.types;
  12.     default_type  application/octet-stream;

  13.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  14.     #                  '$status $body_bytes_sent "$http_referer" '
  15.     #                  '"$http_user_agent" "$http_x_forwarded_for"';

  16.     #access_log  logs/access.log  main;

  17.     sendfile        on;
  18.     #tcp_nopush     on;

  19.     #keepalive_timeout  0;
  20.     keepalive_timeout  65;

  21.     #gzip  on;

  22.     server {
  23.         listen       80;
  24.         server_name  localhost;

  25.         #charset koi8-r;

  26.         #access_log  logs/host.access.log  main;
  27.        
  28.         location ~ .*\.(php)?$
  29.         {
  30.                 expires -1s;
  31.                 try_files $uri =404;
  32.                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
  33.                 include fastcgi_params;
  34.                 fastcgi_param PATH_INFO $fastcgi_path_info;
  35.                 fastcgi_index index.php;
  36.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  37.                 fastcgi_pass 127.0.0.1:9000;
  38.                  
  39.         }

  40.         location / {
  41.             root   html;
  42.             index  index.html index.htm;
  43.         }
  44.         #error_page  404              /404.html;

  45.         # redirect server error pages to the static page /50x.html
  46.         #
  47.         error_page   500 502 503 504  /50x.html;
  48.         location = /50x.html {
  49.             root   html;
  50.                
  51.         }

  52.         #location ~ \.php$ {
  53.         #        root html;
  54.         #        fastcgi_pass unix:/tmp/php-fcgi.sock;
  55.         ##        fastcgi_pass   127.0.0.1:9000;
  56.         #        fastcgi_index index.php;
  57.         #        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  58.         #        include fastcgi_params;
  59.         ##        include fastcgi.conf;
  60.         #}

  61.         #location ~ .*\.(php)?$
  62.         #{
  63.         #        expires -1s;
  64.         #        try_files $uri =404;
  65.         #        fastcgi_split_path_info ^(.+\.php)(/.+)$;
  66.         #        include fastcgi_params;
  67.         #        fastcgi_param PATH_INFO $fastcgi_path_info;
  68.         #        fastcgi_index index.php;
  69.         #        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  70.         #        fastcgi_pass 127.0.0.1:9000;                 
  71.         #       
  72.         #}

  73.        
  74.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  75.         #
  76.         #location ~ \.php$ {
  77.         #    proxy_pass   http://127.0.0.1;
  78.         #}

  79.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  80.         #
  81.         #location ~ \.php$ {
  82.         #    root           html;
  83.         #    fastcgi_pass   127.0.0.1:9000;
  84.         #    fastcgi_index  index.php;
  85.         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  86.         #    include        fastcgi_params;
  87.         #}

  88.         # deny access to .htaccess files, if Apache's document root
  89.         # concurs with nginx's one
  90.         #
  91.         #location ~ /\.ht {
  92.         #    deny  all;
  93.         #}
  94.     }


  95.     # another virtual host using mix of IP-, name-, and port-based configuration
  96.     #
  97.     #server {
  98.     #    listen       8000;
  99.     #    listen       somename:8080;
  100.     #    server_name  somename  alias  another.alias;

  101.     #    location / {
  102.     #        root   html;
  103.     #        index  index.html index.htm;
  104.     #    }
  105.     #}


  106.     # HTTPS server
  107.     #
  108.     #server {
  109.     #    listen       443 ssl;
  110.     #    server_name  localhost;

  111.     #    ssl_certificate      cert.pem;
  112.     #    ssl_certificate_key  cert.key;

  113.     #    ssl_session_cache    shared:SSL:1m;
  114.     #    ssl_session_timeout  5m;

  115.     #    ssl_ciphers  HIGH:!aNULL:!MD5;
  116.     #    ssl_prefer_server_ciphers  on;

  117.     #    location / {
  118.     #        root   html;
  119.     #        index  index.html index.htm;
  120.     #    }
  121.     #}

  122. }
复制代码
vim /usr/local/php/etc/php-fpm.conf


  1. [global]
  2. pid = /var/run/php-fpm.pid
  3. error_log = /var/log/php-fpm.log
  4. [www]
  5. listen = /tmp/php-fcgi.sock
  6. user=php-fpm
  7. group=php-fpm
  8. pm = dynamic
  9. pm.max_children = 50
  10. pm.start_servers = 20
  11. pm.min_spare_servers = 5
  12. pm.max_spare_servers = 35
  13. pm.max_requests = 500
  14. rlimit_files = 1024
复制代码

通过ps查看php-fpm和nginx服务都是正常开启,防火墙iptables已经关闭,然而访问/usr/local/nginx/html/2.php的时候出现:


通过百度搜了好多帖子,仍没有有效办法解决。哪位高人帮忙解决一下?看看配置文件有什么问题?谢谢!

论坛徽章:
9
巳蛇
日期:2013-12-05 15:03:33戌狗
日期:2013-12-10 20:52:35白羊座
日期:2014-12-30 14:11:58处女座
日期:2015-01-15 14:33:442015年亚洲杯纪念徽章
日期:2015-01-28 13:37:36羊年新春福章
日期:2015-01-30 15:03:352015年亚洲杯之约旦
日期:2015-02-09 17:07:552015年亚洲杯之韩国
日期:2015-03-26 15:04:132015年亚洲杯之卡塔尔
日期:2015-04-04 16:35:54
2 [报告]
发表于 2016-10-24 13:44 |只看该作者
一看知道楼主对这块不熟悉,贴出php完整配置,另外再查下php进程。

论坛徽章:
8
数据库技术版块每日发帖之星
日期:2015-12-22 06:20:00数据库技术版块每日发帖之星
日期:2015-12-23 06:20:00数据库技术版块每周发帖之星
日期:2016-02-03 16:55:09数据库技术版块每日发帖之星
日期:2016-07-15 06:20:00IT运维版块每日发帖之星
日期:2016-08-13 06:20:00数据库技术版块每日发帖之星
日期:2016-08-15 06:20:00IT运维版块每日发帖之星
日期:2016-08-16 06:20:00IT运维版块每日发帖之星
日期:2016-08-17 06:20:00
3 [报告]
发表于 2016-10-24 14:31 |只看该作者
回复 2# h101com

php的配置就是拷贝的原来的,没有做任何改动。
php进程:
  1. [root@host188 ~]# ps aux | grep php
  2. root      12420  0.0  0.4 202704  4576 ?        Ss   03:49   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
  3. php-fpm   12421  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  4. php-fpm   12422  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  5. php-fpm   12423  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  6. php-fpm   12424  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  7. php-fpm   12425  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  8. php-fpm   12426  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  9. php-fpm   12427  0.0  0.3 202704  3844 ?        S    03:49   0:00 php-fpm: pool www
  10. php-fpm   12428  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  11. php-fpm   12429  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  12. php-fpm   12430  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  13. php-fpm   12431  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  14. php-fpm   12432  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  15. php-fpm   12433  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  16. php-fpm   12434  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  17. php-fpm   12435  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  18. php-fpm   12436  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  19. php-fpm   12437  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  20. php-fpm   12438  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  21. php-fpm   12439  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  22. php-fpm   12440  0.0  0.3 202704  3848 ?        S    03:49   0:00 php-fpm: pool www
  23. root      16920  0.0  0.0 103332   860 pts/1    S+   07:41   0:00 grep php
复制代码


论坛徽章:
9
巳蛇
日期:2013-12-05 15:03:33戌狗
日期:2013-12-10 20:52:35白羊座
日期:2014-12-30 14:11:58处女座
日期:2015-01-15 14:33:442015年亚洲杯纪念徽章
日期:2015-01-28 13:37:36羊年新春福章
日期:2015-01-30 15:03:352015年亚洲杯之约旦
日期:2015-02-09 17:07:552015年亚洲杯之韩国
日期:2015-03-26 15:04:132015年亚洲杯之卡塔尔
日期:2015-04-04 16:35:54
4 [报告]
发表于 2016-10-24 16:12 |只看该作者
上面那段不是完整配置。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP