'Nginx downloads php files
I read about this problem and tried many fixes, but none has worked. I use Ubuntu 22.04 and PHP 8.1.
My Nginx config file is now
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html/;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
# include fastcgi_params;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
The output of ls -l /var/run/php/ is
total 4
-rw-r--r-- 1 root root 5 kvě 5 16:21 php8.1-fpm.pid
srw-rw---- 1 www-data www-data 0 kvě 5 16:21 php8.1-fpm.sock
lrwxrwxrwx 1 root root 30 kvě 5 11:12 php-fpm.sock -> /etc/alternatives/php-fpm.sock
Strange is that which apache2 returns
/usr/sbin/apache2
but sudo apt remove/purge apache returns that apache is not installed. I did not install apache explicitly, so I don't know where the file /usr/sbin/apache2 come from.
Do you have any ideas how to proceed. Thanks a lot.
EDIT: I added debug keyword into nginx error log settings, now the following lines emerge in the error log when I restart nginx:
2022/05/07 19:16:31 [debug] 87790#87790: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87791#87791: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87790#87790: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87791#87791: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87792#87792: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87792#87792: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87793#87793: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87793#87793: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87794#87794: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87794#87794: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87795#87795: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87795#87795: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87796#87796: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87796#87796: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87797#87797: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87797#87797: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87798#87798: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87798#87798: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87800#87800: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87800#87800: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87802#87802: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87802#87802: epoll add event: fd:8 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87805#87805: epoll add event: fd:7 op:1 ev:10000001
2022/05/07 19:16:31 [debug] 87805#87805: epoll add event: fd:8 op:1 ev:10000001
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|