搭建了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配置如下:
-
events {
-
worker_connections 1024;
-
}
-
http {
-
include mime.types;
-
default_type application/octet-stream;
-
sendfile on;
-
keepalive_timeout 65;
-
server {
-
listen 80;
-
server_name localhost;
-
location / {
-
root /usr/local/nginx/html;
-
index index.php index.html index.htm ;
-
}
-
error_page 500 502 503 504 /50x.html;
-
location = /50x.html {
-
root /usr/local/nginx/html;
-
}
-
location ~ \.php$ {
-
root /usr/local/nginx/html;
-
fastcgi_pass unix:/tmp/php-fcgi.sock;
-
fastcgi_index index.php;
-
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
-
include /etc/nginx/fastcgi_params;
-
}
-
}
-
}
但是这样解析不了php。于是,ps -aux | grep nginx 查看一下进程,结果如下:
-
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,也可以解析了。对于这个案例来说,是配置文件载入错误造成的。
阅读(2744) | 评论(0) | 转发(0) |