He configurado un servidor Nginx php en una máquina Linux REHL. Al acceder a los archivos html, todo va bien, pero al intentar acceder al archivo php, el archivo se descarga en lugar de ejecutarse.
Este es mi nginx.conf:
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }...y este es el bloque del servidor:
server { listen 80; server_name {mywebsitename}; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html/{mywebsitename}/; } location /ngx_status_2462 { stub_status on; access_log off; allow all; } location ~ \.php$ { # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/{mywebsitename}$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }Puede ser debido al tipo MIME que estás enviando:
default_type application/octet-stream;Acabo de tener exactamente este mismo problema. Estaba usando Ubuntu 12.04 y Linux Mint 14, un sistema operativo diferente, pero es probable que tenga los mismos problemas.
Pueden ocurrir un par de problemas. En primer lugar, debe tener instalado php5-fpm (FastCGI Process Manager). Estaba tratando de ejecutarlo con mi versión estándar de PHP pero no funcionaba: http://www.php.net/manual/en/install.fpm.php
También tenía instalado Apache, e incluso si no se estaba ejecutando, debe haber tenido algún conflicto porque una vez que desinstalé Apache pude ejecutar los archivos PHP.
yo tambien miraria esta linea
fastcgi_pass 127.0.0.1:9000;Y considere cambiarlo a
fastcgi_pass unix:/var/run/php5-fpm.sock;Aquí hay una guía detallada para la instalación de Nginx y PHP5-FPM para RHEL (y otros sistemas operativos)
http://www.if-not-true-then-false.com/2011/install-nginx-php-fpm-on-fedora-centos-red-hat-rhel/
Debe cambiar el usuario a nginx en lugar de apache en este archivo a/etc/php-fpm.d/www.conf
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache Choosed to be able to access some dir as httpd ;user = apache user = nginx ; RPM: Keep a group allowed to write in log dir. ;group = apache group = nginxy, por supuesto, reiniciar el servicio de reinicio de php-fpm y el servicio de reinicio de nginx