当前位置:首页 » 编程语言 » nginxphp被下载

nginxphp被下载

发布时间: 2023-04-01 23:42:36

1. nginx配置支持php

nginx本身不支持php解析,需要配合php-fpm来配置。

location~.php${
root/var/www;#指定php的根目录
fastcgi_pass127.0.0.1:9000;#php-fpm的默认端口是9000
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}

centos下安装php-fpm (php及其它组件已经安装过的情况)

yuminstallphp-fpm

启动php-fpm 并设置开机启动 (centos 7)

systemctlstartphp-fpm
systemctlenablephp-fpm

2. centos7 apache访问php文件变成下载index.php

nginx应该是先装的,已经关联php服务,httpd没有关联php,所以,就算你装了php也没用

3. nginx不解析php,访问php文件弹出直接下载该文件 系统是centos7

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
}

4. nginx搭建的服务器,提示下载index.php源码

你这个问题排查需要几点确认:

  1. 把你的index.php复制一个其它名字的文件,看是否能正常访问。

  2. 配置我建议你改成(原版的配置还少了一个括号)

server {
listen 80;
server_name localhost;
root "D:/wwwroot";


location / {
index index.html index.htm index.php;
}


location ~ .php {
root "D:/wwwroot";
fastcgi_pass 127.0.0.1:33669;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}


你先按我说的试试。

5. php页面变成下载页面,nginx+linux

浏览器不支持php格式,请升级或换用其它浏览器。

要不然你可以参考这个

网页链接

6. nginx 浏览php的时候会变成下载

php的时候会变成下载:这是因为nginx没有设置好碰到php文件时,要传递到后方的php解释器。

看看你的nginx.conf配置,里面有没有这样的设置:
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:9000;
}
上面的意思,就是说,碰到.php结尾的文件,传递给后方127.0.0.1的9000端口上。

当然啦,你的php-fpm解析器也需要正常运行,并监听好9000端口,才能最终生效并有效处理php脚本

windows下开启监听的办法,php-cgi.exe -b 127.0.0.1:9000 -c php\php.ini

热点内容
I编译环境 发布:2024-05-09 06:50:37 浏览:211
安卓手机怎么直接扫一扫连接wifi 发布:2024-05-09 06:21:50 浏览:596
传统行车记录仪存储卡在哪个位置 发布:2024-05-09 06:18:44 浏览:127
苹果设置的密码是多少 发布:2024-05-09 06:17:53 浏览:274
刷安卓系统需要什么条件 发布:2024-05-09 06:02:48 浏览:51
清楚谷歌浏览器的缓存文件 发布:2024-05-09 05:55:57 浏览:325
微商引流脚本方法 发布:2024-05-09 05:33:09 浏览:478
编译软件包 发布:2024-05-09 05:13:46 浏览:91
sql语句logon 发布:2024-05-09 05:04:28 浏览:557
阿里云服务器异地登录 发布:2024-05-09 05:04:27 浏览:935