Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

955
Views
Nginx descarga php en lugar de ejecutarlo

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; } }
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede ser debido al tipo MIME que estás enviando:

 default_type application/octet-stream;

Ver: http://mimeapplication.net/octet-stream

over 4 years ago · Santiago Trujillo Report

0

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/

over 4 years ago · Santiago Trujillo Report

0

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 = nginx

y, por supuesto, reiniciar el servicio de reinicio de php-fpm y el servicio de reinicio de nginx

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!