Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92562
  • 博文数量: 23
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 253
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-01 20:41
文章分类

全部博文(23)

分类: 服务器与存储

2015-05-21 00:09:36



搭建了lnmp后,没有能解析php,编译参数如下:

    --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error_log --http-log-path=/var/log/nginx/access_log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-file-aio --with-http_image_filter_module



     编译的参数的时候把配置文件是/etc/nginx/nginx.conf,但是安装完成了之后,/usr/local/nginx/conf/目录下还有nginx.conf这个配置文件,但是我是在/etc/nginx/nginx.conf中配置的php解析。
nginx.conf配置如下:

点击(此处)折叠或打开

  1. events {
  2.     worker_connections 1024;
  3. }
  4. http {
  5.     include mime.types;
  6.     default_type application/octet-stream;
  7.     sendfile on;
  8.     keepalive_timeout 65;
  9.     server {
  10.         listen 80;
  11.         server_name localhost;
  12.         location / {
  13.             root /usr/local/nginx/html;
  14.             index index.php index.html index.htm ;
  15.         }
  16.         error_page 500 502 503 504 /50x.html;
  17.         location = /50x.html {
  18.             root /usr/local/nginx/html;
  19.         }
  20.         location ~ \.php$ {
  21.             root /usr/local/nginx/html;
  22.             fastcgi_pass unix:/tmp/php-fcgi.sock;
  23.             fastcgi_index index.php;
  24.             fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
  25.             include /etc/nginx/fastcgi_params;
  26.         }
  27.     }
  28. }

但是这样解析不了php。于是,ps -aux | grep nginx 查看一下进程,结果如下:

点击(此处)折叠或打开

  1. root 5647 0.0 0.0 10976 980 ? Ss 08:29 0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

       nginx运行的是/usr/local/nginx/conf/nginx.conf也就是安装目录下的配置文件。但是这个配置文件中什么都没有配置,所以php解析不了,复制/etc/nginx/nginx.conf到/usr/local/nginx/conf/nginx.conf,覆盖一下,php可以解析了。也可以这样,nginx -s reload -c /etc/nginx/nginx.conf,重新载入一下配置文件,重启一下nginx,也可以解析了。对于这个案例来说,是配置文件载入错误造成的。





阅读(2669) | 评论(0) | 转发(0) |
1

上一篇:关于php-fpm启动失败经验教训

下一篇:没有了

给主人留下些什么吧!~~