0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ArchLinux: Nginx で PHP と Python を使う

Last updated at Posted at 2023-02-13

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

設定ファイル

/etc/nginx/nginx.conf
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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?