Hallo Community,
ich möchte in einer VM eine Web-Software ausprobieren und scheitere daran, PHP zur Zusammenarbeit zu überreden. Wahrscheinlich irgendein ziemlich dummer Fehler, aber ich komm einfach nicht dahinter...
Ich hatte hier eine Manjaro-VM rumfliegen und dachte, ich mach das direkt dort. Die Verzeichnisstruktur ist hier etwas anders, als ich es von Debian gewohnt bin, statt /var/www/html gibt es /usr/share/nginx/html. Und es gibt den User http, von dem PHP ausgeführt wird.
Nginx an sich funktioniert und zeigt brav die index.html Datei an. Allerdings gibt es beim Versuch eine PHP-Datei aufzurufen ein "Access denied". Im Nginx-Log finde ich dann Folgendes:
Der betreffende Unterordner hatte ursprünglich dem Nutzer root und auch der Gruppe root gehört. Ich habe es auch schon mit Nutzer http und Gruppe root probiert. Und es ist testweise alles erlaubt, also chmod 777. Trotzdem kriege ich immer wieder die Fehlermeldung "Access denied" im Browser und die obige Fehlermeldung im Nginx-Log.
Hier noch die Konfiguration von Nginx (fast alles auf Standard):
Und hier noch die Konfiguration in "sites-enabled":
Vielen Dank für alle Tipps!
Viele Grüße
Photon
ich möchte in einer VM eine Web-Software ausprobieren und scheitere daran, PHP zur Zusammenarbeit zu überreden. Wahrscheinlich irgendein ziemlich dummer Fehler, aber ich komm einfach nicht dahinter...
Ich hatte hier eine Manjaro-VM rumfliegen und dachte, ich mach das direkt dort. Die Verzeichnisstruktur ist hier etwas anders, als ich es von Debian gewohnt bin, statt /var/www/html gibt es /usr/share/nginx/html. Und es gibt den User http, von dem PHP ausgeführt wird.
Nginx an sich funktioniert und zeigt brav die index.html Datei an. Allerdings gibt es beim Versuch eine PHP-Datei aufzurufen ein "Access denied". Im Nginx-Log finde ich dann Folgendes:
Less:
2025/02/04 17:57:20 [error] 14446#14446: *1 FastCGI sent in stderr: "PHP message: PHP Warning: PHP Request Startup: Failed to open stream: Permission denied in Unknown on line 0; Unable to open primary script: /usr/share/nginx/html/GibbonEduCore-InstallBundle/index.php (Permission denied)" while reading response header from upstream, client: ::1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock:", host: "localhost:8000"
Der betreffende Unterordner hatte ursprünglich dem Nutzer root und auch der Gruppe root gehört. Ich habe es auch schon mit Nutzer http und Gruppe root probiert. Und es ist testweise alles erlaubt, also chmod 777. Trotzdem kriege ich immer wieder die Fehlermeldung "Access denied" im Browser und die obige Fehlermeldung im Nginx-Log.
Hier noch die Konfiguration von Nginx (fast alles auf Standard):
NGINX:
#user http;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
# load configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html/;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
Und hier noch die Konfiguration in "sites-enabled":
NGINX:
server {
# Example PHP Nginx FPM config file
listen 8000 default_server;
listen [::]:8000 default_server;
root /usr/share/nginx/html/GibbonEduCore-InstallBundle;
# Add index.php to setup Nginx, PHP & PHP-FPM config
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
# pass PHP scripts on Nginx to FastCGI (PHP-FPM) server
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# deny access to Apache .htaccess on Nginx with PHP,
# if Apache and Nginx document roots concur
location ~ /\.ht {
deny all;
}
} # End of PHP FPM Nginx config example
Vielen Dank für alle Tipps!
Viele Grüße
Photon
Zuletzt bearbeitet: