Nginx mit PHP (Rocky)
Version vom 11. November 2025, 05:49 Uhr von Thomas.will (Diskussion | Beiträge)
NGINX + PHP-FPM auf Rocky Linux 10
- dnf install nginx php-fpm -y
- systemctl enable --now nginx php-fpm
- echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php
- vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
}
}
- systemctl restart php-fpm nginx
- ss -ltnp | grep php-fpm
- curl -I http://127.0.0.1/info.php
- Browser: http://10.20.10.12/info.php
Fehlerbehebung
- „File not found“ → fastcgi_param SCRIPT_FILENAME prüfen.
- „502 Bad Gateway“ → prüfen, ob /run/php-fpm/www.sock existiert.
- „Permission denied“ → testweise SELinux deaktivieren: setenforce 0