Nginx mit PHP (Rocky): Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Die Seite wurde neu angelegt: „*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.…“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
= NGINX + PHP-FPM auf Rocky Linux 10 = | |||
*dnf install nginx php-fpm -y | *dnf install nginx php-fpm -y | ||
*systemctl enable --now nginx php-fpm | *systemctl enable --now nginx php-fpm | ||
*echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php | *echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php | ||
*vi /etc/nginx/conf.d/default.conf | *vi /etc/nginx/conf.d/default.conf | ||
<pre> | <pre> | ||
server { | 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; | |||
} | |||
} | } | ||
</pre> | </pre> | ||
*systemctl | |||
*http://10.20.10.12/info.php prüfen | *vi /etc/php-fpm.d/www.conf | ||
<pre> | |||
; Prüfen und ggf. anpassen: | |||
listen = /run/php-fpm/www.sock | |||
user = nginx | |||
group = nginx | |||
listen.owner = nginx | |||
listen.group = nginx | |||
listen.mode = 0660 | |||
</pre> | |||
*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 | |||
Version vom 11. November 2025, 05:43 Uhr
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;
}
}
- vi /etc/php-fpm.d/www.conf
; Prüfen und ggf. anpassen: listen = /run/php-fpm/www.sock user = nginx group = nginx listen.owner = nginx listen.group = nginx listen.mode = 0660
- 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