miércoles, 2 de noviembre de 2022

Unable to open primary script (Permission denied)



Cómo configurar nginx para funcionar como webserver en SLES 15.



Instalé NGINX en un SLES 15 SP4 para hospedar una web, pero al ir a ver el index.php me encontré con el siguiente mensaje de error en el navegador:

An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.


If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.

Al mirar los logs de error de nginx vi:

FastCGI sent in stderr: "Unable to open primary script: /srv/www/htdocs/index.php (Permission denied)" *3 FastCGI sent in stderr: "Unable to open primary script: /srv/www/htdocs/index.php (Permission denied)" while reading response header from upstream, client: 1.1.1.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "web.com"

Después de jugar con permisos durante algunas horas, di con que podría ser un problema de AppArmor, pero deshabilitarlo no surgió efecto.

Lo que sí funcionó fue poner AppArmor en modo "aa-complain" para php-fpm:

HOST # aa-complain php-fpm Setting /usr/sbin/php-fpm to complain mode. Warning: profile php-fpm represents multiple programs Warning: profile php-fpm represents multiple programs

Una vez hecho esto, reinicié el servicio nginx y la web empezó a funcionar :)


Fuentes:

https://documentation.suse.com/sles/15-SP4/html/SLES-all/cha-apparmor-intro.html
0