Estoy usando nginx y php-fpm7.2 en mi servidor. Cuando trato de abrir mi sitio web de WordPress, no se carga y solo descarga la página. Puedo acceder a todas las demás páginas excepto a la página de inicio a través de url. Ocurre hoy y no modifiqué ningún archivo de configuración. El fastcgi y los otros sitios en el mismo servidor están funcionando. He intentado todas las soluciones que puedo encontrar y ninguna de ellas puede resolver. La descarga del archivo por el sitio web se encuentra a continuación.
<?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define( 'WP_USE_THEMES', true ); /** Loads the WordPress Environment and Template */ require __DIR__ . '/wp-blog-header.php';Este es el archivo de configuración de mi sitio web.
server { listen 80; #listen [::]:80; server_name sur.net.cn ; index index.php ; root /home/wwwroot/sur.net.cn; include rewrite/none.conf; #error_page 404 /404.html; include enable-php.conf; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log off; } server { listen 443 ssl http2; #listen [::]:443 ssl http2; server_name sur.net.cn ; index index.php ; root /home/wwwroot/sur.net.cn; ssl_certificate /home/wwwroot/ssl/5176542_sur.net.cn.pem; ssl_certificate_key /home/wwwroot/ssl/5176542_sur.net.cn.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_session_cache builtin:1000 shared:SSL:10m; # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048 ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem; include rewrite/none.conf; #error_page 404 /404.html; include enable-php.conf; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log off; }Intenta agregar algo como
location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; }como está escrito aquí: https://dariuscoder.com/2021/09/29/wordpress-nginx-config/ Si elimino esta parte, obtengo el mismo efecto: se descarga en lugar de ejecutarse.
Además, si aún se descarga, asegúrese de haber reiniciado nginx y de borrar la memoria caché del navegador. Chrome estaba descargando el archivo incluso con nginx detenido hasta que borré el caché.