linux nginx 无法执行php文件

linux nginx 无法执行php文件,第1张

为以前没有接触过nginx ,所以查了一天,查处原因有二:

一、网站根目录

默认是在 /usr/local/nginx/html文件

配置

location / {

root /home/www/wwwroot

index index.html index.htm

}

二、修改文件中对应的php配置部分

location ~ \.php$ {

root /home/www/wwwroot

fastcgi_pass 127.0.0.1:9000

fastcgi_index index.php

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name

includefastcgi_params

}

特别需要注意的是:fastcgi_param这个参数默认的是$fastcgi_script_name最好改为$document_root$fastcgi_script_name我在实际配置中出现了php找不到需要解析文件而返回404或者500错误的问题。所以最好是带上网站根目录的路径变量$document_root

1、安装nginx之前需要安装 PCRE库的安装 最新下载地址 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ tar –zxvf pcre-8.21.tar.gz,解压目录为:pcre-8.21 然后进入到 cd pcre-8.21,进行配置、编译、安装 配置 ./configure或./config 编译 make 安装 make install 2、安装zlib库安装 tar -zxvf zlib-1.2.5.tar.gz cd zlib-1.2.5 ./configure make makeinstall 3、安装openSSL库 下载页面:http://www.openssl.org/source/ tar –zxvf openssl-1.0.0.tar.gz,解压目录为:openssl-1.0.0 然后进入到 cd openssl-1.0.0,进行配置、编译、安装 配置 ./configure或./config 编译 make 安装 make install 4、以上三个库确保安装好后 接下来安装nginx tar zxvf nginx-1.1.12.tar.gz cd nginx-1.1.12/ ./configure --user=root --group=root--prefix=/usr/local/nginx--with-http_stub_status_module --with-openssl=/usr/local/ssl/include/openssl make &&make install cd ../ 安装完成后在/usr/local 下 会有个nginx目录 ok 具体你可以参照这个链接:http://blog.csdn.net/wanwang8/article/details/7200454

Linux下nginx重启:

#重启:先Kill 再启动

kill -9 $(ps -A | grep nginx | cut -d "?" -f 1 ) &>/dev/null 

/usr/local/nginx/sbin/nginx   

#判断Nginx配置是否正确:修改配置文件后先检查一下是否正确,以免重启后Nginx出现错误影响服务器稳定运行

nginx -t -c /usr/nginx/conf/nginx.conf 

#或者

/usr/nginx/sbin/nginx -t 

#平滑重启

/usr/nginx/sbin/nginx -s reload   

#查看进程 

ps -ef | grep nginx

#Kill进程

kill -9 9999

扩展资料

linux下关闭nginx:

查询nginx主进程号

ps -ef | grep nginx

从容停止kill -QUIT主进程号

快速停止kill -TERM主进程号

强制停止kill -9 nginx

若nginx.conf配置了pid文件路径,如果没有,则在logs目录下

kill-信号类型'/usr/local/nginx/logs/nginx.pid'

参考资料来源:百度百科—linux


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7139038.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-02
下一篇2023-04-02

发表评论

登录后才能评论

评论列表(0条)

    保存