I am working in a new Docker environment running PHP71 + Nginx. The Dockerfile is inherit from million12/docker-nginx.
This is the content of /etc/nginx/hosts.d/vhost.conf
(which I took from here):
server {
listen 80 default_server;
listen 81 default_server http2 proxy_protocol; ## Needed when behind HAProxy with SSL termination + HTTP/2 support
listen 443 default_server ssl http2;
ssl_certificate /etc/nginx/ssl/dummy.crt;
ssl_certificate_key /etc/nginx/ssl/dummy.key;
root /data/www;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
include /etc/nginx/conf.d/stub-status.conf;
include /etc/nginx/conf.d/default-*.conf;
include /data/conf/nginx/conf.d/default-*.conf;
}
I can't find why the file is downloaded instead of display it's content.
Inside the container this is what I have at /var/run
:
# ls -la /var/run/
total 8
drwxr-xr-x 11 root root 185 Dec 14 21:12 .
drwxr-xr-x 19 root root 299 Dec 14 21:12 ..
drwxr-xr-x 2 root root 6 Sep 5 10:19 blkid
drwxr-xr-x 2 root root 6 Jul 29 14:05 console
drwxr-xr-x 2 root root 6 Jul 29 14:05 faillock
drwxr-xr-x 4 root root 35 Jul 29 14:05 lock
drwxr-xr-x 2 root root 6 Jul 29 14:05 log
-rw-r--r-- 1 root root 2 Dec 14 21:12 php-fpm.pid
drwxr-xr-x 2 root root 6 Jul 29 14:05 sepermit
drwxr-xr-x 2 root root 6 Jul 29 14:05 setrans
-rw-r--r-- 1 root root 3 Dec 14 21:12 supervisord.pid
drwxr-xr-x 9 root root 113 Jul 29 14:05 systemd
drwxr-xr-x 2 root root 6 Jul 29 14:05 user
-rw-rw-r-- 1 root utmp 0 Jul 29 14:05 utmp
Maybe this line:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
Isn't working properly. Changing it to:
fastcgi_pass php-upstream;
Where php-upstream
is:
upstream php-upstream {
server 127.0.0.1:9000;
}
Doesn't work either. I am stuck at this point. I have checked all of this posts before open another a new one:
- https://stackoverflow.com/questions/39950129/nginx-doesnt-serve-php-files (this was open by myself time ago)
- https://stackoverflow.com/questions/21103328/nginx-downloads-php-instead-of-running-it
- https://stackoverflow.com/questions/27280977/nginx-php-page-downloads-instead-of-displaying
- https://stackoverflow.com/questions/20668886/nginx-and-fastcgi-downloads-php-files-instead-of-processing-them
- Install Nginx/PHP-FPM on Fedora 25/24, CentOS/RHEL 7.2/6.8
Can any give me some help on this one? Remember all this is running inside a Docker container so maybe some commands aren't available.