[問題] nginx的php讀取問題

看板Linux作者時間9年前 (2016/12/29 13:25), 9年前編輯推噓3(3017)
留言20則, 9人參與, 最新討論串1/1
小弟環境是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://www.ptt.cc/bbs/Linux/M.1482989126.A.C3D.html

12/29 14:38, , 1F
有沒有可能是有別的web server也在運行?apache?
12/29 14:38, 1F

12/29 14:55, , 2F
你有指定server_name嗎?
12/29 14:55, 2F

12/29 16:23, , 3F
server_name .ptt.com
12/29 16:23, 3F

12/29 16:23, , 4F
沒有apache
12/29 16:23, 4F

12/29 18:26, , 5F
CentOS不知道有沒有和ubuntu一樣long-term support版本
12/29 18:26, 5F

12/29 18:27, , 6F
Kernel Version?????????????????????????????????????
12/29 18:27, 6F

12/29 18:29, , 7F
修改www.conf
12/29 18:29, 7F

12/29 18:29, , 8F
listen=/var/run/php-fpm/php-fpm.sock
12/29 18:29, 8F

12/29 18:29, , 9F
user=nginx
12/29 18:29, 9F

12/29 18:29, , 10F
group=nginx
12/29 18:29, 10F

12/29 18:29, , 11F
listen.owner=nginx
12/29 18:29, 11F

12/29 18:29, , 12F
listen.group=nginx
12/29 18:29, 12F

12/29 18:29, , 13F
listen.mode=0660
12/29 18:29, 13F

12/29 19:02, , 14F
問題應該是在外層的server設定,方便貼完整的conf嗎?
12/29 19:02, 14F

12/29 21:23, , 15F
centos 本身就是 long-term support 的版本啊...
12/29 21:23, 15F
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

12/30 10:59, , 16F
另外www.conf設定是一樣的
12/30 10:59, 16F

12/30 11:42, , 17F
你test.ptt.com可以正常解到192.168.1.1吼
12/30 11:42, 17F

12/30 12:58, , 18F
其實我指向過內網IP 還是一樣 所以現在我是指外網IP
12/30 12:58, 18F

01/05 20:53, , 19F
把server_name整個拿掉試試
01/05 20:53, 19F

03/13 20:38, , 20F
root 路徑不要用域名看看
03/13 20:38, 20F
文章代碼(AID): #1OP9v6mz (Linux)