托管在 nginx ubuntu 上的 Wordpress 网站无法再加载

托管在 nginx ubuntu 上的 Wordpress 网站无法再加载

我刚刚发现 Wordpress 网站不再运行。打开时example.in,它只显示文本Error establishing a database connection。wp 网站是文件夹/var/www/examplewp

我在同一台服务器上运行着其他非基于 PHP 的网站,运行顺畅。即使xxx.example.in是非基于 PHP 的网站也可以正常运行。

我尝试打开我在 WP 的基本文件夹中创建的文件(例如example.in/readmore.html或) ,并且可以正常工作。example.in/hello.txt

详细信息如下:

php -v

PHP 7.2.19-0ubuntu0.18.10.1 (cli) (built: Jun  4 2019 14:46:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.19-0ubuntu0.18.10.1, Copyright (c) 1999-2018, by Zend Technologies

uname -a

Linux ubuntu-s-1vcpu-1gb-blr1-01 4.18.0-25-generic #26-Ubuntu SMP Mon Jun 24 09:32:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

这是我的 xxx_nginx.conf 文件

server {
        server_name example.in www.example.in;
        root /var/www/examplewp;
        access_log /var/log/nginx/wp_client_access.log;
        error_log /var/log/nginx/wp_client_error.log;

        location / {
                index   index.php index.html;
                #try_files      $uri $uri/ /index.php?$args;
        }
        # Specify a charset
        charset                         utf-8;
        # GZIP
        gzip                            off;

        # Add trailing slash to */wp-admin requests.
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;

        # Prevents hidden files (beginning with a period) from being served
        location ~ /\. {
                access_log                      off;
                log_not_found                   off;
                deny                            all;
        }
        ###########
        # SEND EXPIRES HEADERS AND TURN OFF 404 LOGGING
        ###########

        location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                access_log                      off;
                log_not_found                   off;
                expires                         max;
        }

        # Pass all .php files onto a php-fpm or php-cgi server
        location ~ \.php$ {
                try_files                       $uri =404;
                include                         /etc/nginx/fastcgi_params;
                fastcgi_read_timeout            3600s;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 128k;
                fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_pass                    unix:/run/php/php7.2-fpm.sock;
                fastcgi_pass                    unix:/run/php/php7.2-fpm.sock;
                fastcgi_index                   index.php;
        }

        # ROBOTS

         location = /robots.txt {
               allow all;
               log_not_found off;
               access_log off;
        }
        # RESTRICTIONS
        location ~* /(?:uploads|files)/.*\.php$ {
                deny all;
        }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.in/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.in/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = www.example.in) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.in) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        server_name example.in www.example.in;
    listen 80;
    return 404; # managed by Certbot
}

我尝试使用 重启服务器,sudo service nginx restart但无济于事。甚至 HTML 或 TXT 文件都无法打开。我尝试使用命令行sudo service php7-fpm restart,但得到的响应如下:

Failed to restart php7-fpm.service: Unit php7-fpm.service not found.

我可以打开包含以下内容的 info.php 文件phpinfo();并查看所有 PHP 相关文件。

我也检查了错误日志但它是空的:/var/log/nginx/wp_client_error.log

我尝试使用此命令 land: 重新启动 mysql,sudo /etc/init.d/mysql start但出现以下错误:

[....] Starting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 **failed!**

命令行得到这个:sudo netstat -tulpn

活动的 Internet 连接(仅服务器)Proto Recv-Q Send-Q 本地地址 外部地址 状态 PID/程序名称
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1048/mongod
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 24542/node
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4695/nginx: master
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 798/systemd-resolve tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1070/sshd
tcp 0 0 0.0.0.0:443 0.0.0.0:* 监听 4695/nginx:master
tcp 0 0 0.0.0.0:9000 0.0.0.0:* 监听 22853/node
tcp6 0 0 :::80 :::* 监听 4695/nginx:master
tcp6 0 0 :::22 :::* 监听 1070/sshd
udp 0 0 127.0.0.53:53 0.0.0.0:* 798/systemd-resolve

相关内容