ArchLinux の Nginx の設定ファイルは、/etc/nginx/nginx.conf です。
PHP と Python を使う設定です。
PHP だけを使う設定はこちら
ArchLinux: Nginx で PHP を使う
インストール
sudo pacman -S nginx
sudo pacman -S php
sudo pacman -S php-fpm
sudo pacman -S fcgiwrap
sudo pacman -S certbot-nginx
設定ファイル
/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 に注意
ここまでで、http としての動作が問題ないか確認
Let's Encrypt の設定
MAIL="useraa@example.com"
#
sudo certbot certonly \
--webroot -w /var/www/html -d example.com \
--email $MAIL
nginx.conf への設定の追加
/etc/nginx/nginx.conf
(省略)
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name ekzemplaro.org;
access_log /var/log/nginx/access.log;
root /var/www/html;
ssl_certificate /etc/letsencrypt/live/ekzemplaro.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ekzemplaro.org/privkey.pem;
location ~ \.php$ {
root /var/www/html;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
}
location ~ \.py$ {
gzip off;
fastcgi_pass unix:/run/fcgiwrap.sock;
fastcgi_index index.py;
include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
}
#error_page 404 /404.html;
}
(省略)
確認したバージョン
$ nginx -v
nginx version: nginx/1.28.0
$ php --version
PHP 8.5.1 (cli) (built: Dec 16 2025 18:26:57) (NTS)
$ python --version
Python 3.13.11
$ certbot --version
certbot 5.2.2