R作者phoenixcx (曼秀雷敦)
看板Linux
标题[问题] nginx的php读取问题
时间Thu Dec 29 13:25:19 2016
小弟环境是Centos 7
如果是指定ip:
http://192.168.1.1/test.php 可以读取
但如果用网域就会让你下载
http://test.ptt.com/test.php
location ~ \.php$ {
root /vhost/test.ptt.com/htdocs;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
try_files $uri =404;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
请问该如何是好 感谢各位!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.124.92.194
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Linux/M.1482989126.A.C3D.html
1F:推 hn12404988: 有没有可能是有别的web server也在运行?apache? 12/29 14:38
2F:推 cerebellum: 你有指定server_name吗? 12/29 14:55
3F:→ phoenixcx: server_name .ptt.com 12/29 16:23
4F:→ phoenixcx: 没有apache 12/29 16:23
5F:推 a34021501: CentOS不知道有没有和ubuntu一样long-term support版本 12/29 18:26
6F:→ a34021501: Kernel Version????????????????????????????????????? 12/29 18:27
7F:→ wsokwj: 修改www.conf 12/29 18:29
8F:→ wsokwj: listen=/var/run/php-fpm/php-fpm.sock 12/29 18:29
9F:→ wsokwj: user=nginx 12/29 18:29
10F:→ wsokwj: group=nginx 12/29 18:29
11F:→ wsokwj: listen.owner=nginx 12/29 18:29
12F:→ wsokwj: listen.group=nginx 12/29 18:29
13F:→ wsokwj: listen.mode=0660 12/29 18:29
14F:→ sasoric: 问题应该是在外层的server设定,方便贴完整的conf吗? 12/29 19:02
15F:→ kenduest: centos 本身就是 long-term support 的版本啊... 12/29 21:23
ssl_certificate /etc/nginx/certs/2015/test.pem;
ssl_certificate_key /etc/nginx/certs/2015/test.key;
ssl_session_timeout 2m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "HIGH:!aNULL:!MD5";
ssl_dhparam /etc/nginx/certs/2015/test-dh.pem;
server {
listen 80;
listen 443 ssl;
#server_name localhost;
server_name test.ptt.com, 192.168.1.1;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
location / {
root /vhost/test.ptt.com/htdocs;
index index.php index.html index.htm;
autoindex off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /vhost/test.ptt.com/htdocs;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
try_files $uri =404;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
还是说需要www.conf??
※ 编辑: phoenixcx (59.124.92.194), 12/30/2016 10:58:43
16F:→ phoenixcx: 另外www.conf设定是一样的 12/30 10:59
17F:→ pizzahut: 你test.ptt.com可以正常解到192.168.1.1吼 12/30 11:42
18F:→ phoenixcx: 其实我指向过内网IP 还是一样 所以现在我是指外网IP 12/30 12:58
19F:→ sasoric: 把server_name整个拿掉试试 01/05 20:53
20F:→ obitop2012: root 路径不要用域名看看 03/13 20:38