Welcome! Log In Create A New Profile

Advanced

Browser downloads php pages

Posted by kl3mhao 
Browser downloads php pages
September 20, 2021 08:40AM
Hi,

As I explained everything here :
https://serverfault.com/questions/1077642/browser-downloads-the-file-instead-of-opening-php-files

my main problem is that : either the php page I try to access from http://www.my_domain.com/index.php is downloaded, either it return the 50x.html error file.

For the config files, I have the nginx.conf int he root /nginx folder and the /conf.d/default.conf
I'm not that so comfortable with the /site-available and /sites-enabled folder as they are not included in my /nginx folder naturally, as though I created them for my subdomains.

I haven't configures certbot yet, as the php doesn't work I don't want to make it more difficult, and I know Certbot can rewrite the default.conf file if necessary.

#######################################
## Config files ##
# #
# my domain name is anonymised as #
# my_domain.com #
# #
## ##
######################################

the nginx.conf is as follow :
user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log notice;

pid /var/run/nginx.pid;


events {
worker_connections 1024;

}

http {
include /etc/nginx/mime.types;
include /etc/nginx/sites-available/*.conf;
default_type application/octet-stream;


log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';



access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;

}

and the default.conf is as follows :
server {
listen 80;
server_name gout-cha.com www.gout-cha.com;

location / {
root /var/www/www.gout-cha.com;
index index.php index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/www.gout-cha.com;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
#if (!-f $document_root$fastcgi_script_name) {
# return 404;
#}
root /var/www/www.gout-cha.com;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
}


}

The /var/log/nginx/error.log file is as follows (since the last "$ sudo service nginx reload && sudo service php7.4-fpm restart") :
2021/09/20 20:08:38 [notice] 11708#11708: signal 1 (SIGHUP) received from 41584, reconfiguring
2021/09/20 20:08:38 [notice] 11708#11708: reconfiguring
2021/09/20 20:08:38 [notice] 11708#11708: using the "epoll" event method
2021/09/20 20:08:38 [notice] 11708#11708: start worker processes
2021/09/20 20:08:38 [notice] 11708#11708: start worker process 41585
2021/09/20 20:08:38 [notice] 11708#11708: start worker process 41586
2021/09/20 20:08:38 [notice] 41517#41517: gracefully shutting down
2021/09/20 20:08:38 [notice] 41517#41517: exiting
2021/09/20 20:08:38 [notice] 41517#41517: exit
2021/09/20 20:08:38 [notice] 41518#41518: gracefully shutting down
2021/09/20 20:08:38 [notice] 41518#41518: exiting
2021/09/20 20:08:38 [notice] 41518#41518: exit
2021/09/20 20:08:38 [notice] 11708#11708: signal 17 (SIGCHLD) received from 41517
2021/09/20 20:08:38 [notice] 11708#11708: worker process 41517 exited with code 0
2021/09/20 20:08:38 [notice] 11708#11708: worker process 41518 exited with code 0
2021/09/20 20:08:38 [notice] 11708#11708: signal 29 (SIGIO) received
2021/09/20 20:09:03 [error] 41585#41585: *508 open() "/var/www/www.my_domain.com/favicon.ico" failed (2: No such file or directory), client: 90.22.169.35, server: my_domain.com, request: "GET /favicon.ico HTTP/1.1", host: "www.my_domain.com", referrer: "http://www.my_domain.com/index.html"
2021/09/20 20:09:10 [crit] 41585#41585: *507 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 90.22.169.35, server: my_domain.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "www.my_domain.com"
2021/09/20 20:09:18 [crit] 41585#41585: *507 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 90.22.169.35, server: my_domain.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "www.my_domain.com"
2021/09/20 20:14:13 [crit] 41585#41585: *511 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 107.189.14.98, server: my_domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "47.242.156.85:80"
2021/09/20 20:26:23 [error] 41585#41585: *513 open() "/var/www/www.my_domain.com/robots.txt" failed (2: No such file or directory), client: 116.202.35.125, server: my_domain.com, request: "GET /robots.txt HTTP/1.1", host: "my_domain.com"
2021/09/20 20:26:23 [crit] 41585#41585: *514 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 116.202.35.125, server: my_domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "my_domain.com"
2021/09/20 20:30:26 [error] 41585#41585: *517 open() "/var/www/www.my_domain.com/robots.txt" failed (2: No such file or directory), client: 45.95.147.3, server: my_domain.com, request: "HEAD /robots.txt HTTP/1.0"

Thanks a lot for any help.
index.html works but not index.php
September 20, 2021 09:23AM
I post the following update :

the /var/run/php/php7.4-fpm.sock (I corrected the path mistake, still get the same problem) is owned by www-data:www-data by default, with a drwxr-xr-x permission. I changed the owner to root:root, nginx:nginx, nothing changes.

When I http://www.my_domain.com I end up on the 50x.html error page, but if I type http://www.my_domain.com/index.html I open it without problem. The http://www.my_domain.com/index.php file redirects me to the 50x.html.

I don't get why...

Thanks
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 60
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready