ArchLinux:使用Nginx来运行PHP和Python

ArchLinux中Nginx的配置文件位于/etc/nginx/nginx.conf。
这是一个配置文件用于使用PHP和Python。
使用PHP的单独配置在此处
在ArchLinux上,使用Nginx来使用PHP

安装

sudo pacman -S nginx
sudo pacman -S php-fpm
sudo pacman -S fcgiwrap

配置文件

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /var/www;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        location ~ \.php$ {
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
            include        fastcgi_params;
        }

        location ~ \.py$ {
        gzip off;
        fastcgi_pass unix:/run/fcgiwrap.sock;
        fastcgi_index index.py;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
        }

    }
}

确认设置文件

sudo nginx -t

重新启动

sudo systemctl restart php-fpm
sudo systemctl restart fcgiwrap.socket
sudo systemctl restart nginx

请注意 fcgiwrap.socket

确认的版本

$ nginx -v
nginx version: nginx/1.24.0