0

I just found out the Wordpress website isn't running anymore. When opening example.in, it simply shows the text Error establishing a database connection. The wp website is the folder /var/www/examplewp

I have other non-PHP based websites running smoothly on the same server. Even the xxx.example.in which is a non-php based website is working.

I tried opening files such as example.in/readmore.html or example.in/hello.txt which I created in the base folder of the WP and that's working.

Here's the details:

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

This is my xxx_nginx.conf file

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
}

I tried restarting the server with sudo service nginx restart but it doesn't help. Even the HTML or TXT files aren't opening. I tried with the command line sudo service php7-fpm restart but got the response:

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

I can open info.php file though which has the phpinfo(); and see all the PHP related files.

I also check the error log but it's empty: /var/log/nginx/wp_client_error.log

I tried restarting the mysql with this command land: sudo /etc/init.d/mysql start and got the following error:

[....] 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!**

Command Line got this: sudo netstat -tulpn

Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
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:* LISTEN 4695/nginx: master
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 22853/node
tcp6 0 0 :::80 :::* LISTEN 4695/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1070/sshd
udp 0 0 127.0.0.53:53 0.0.0.0:* 798/systemd-resolve

Nikita Gupta
  • 113
  • 4
  • 1
    The error message says it is a problem connecting to the database. Can you connect to your database via phpmyadmin or some other tool? Verify the database name and username are correct in wp-config.php. – Admiral Noisy Bottom May 16 '20 at 06:23
  • Yeah I'm doing that. I'm beginning to wonder if someone deleted mysql because it's not installed. When I run this command line `dpkg --get-selections | grep mysql`, I get the following: mysql-client-5.7 install mysql-client-core-5.7 install mysql-common install mysql-server install mysql-server-5.7 install mysql-server-core-5.7 install php-mysql install php7.2-mysql install – Nikita Gupta May 16 '20 at 06:24
  • What OS are you on? systemctl start mysqld.service doesn't yield any results? Your data bases, from memory, are in /var/lib/mysql/data or similar. – Admiral Noisy Bottom May 16 '20 at 06:27
  • What is the output of ```sudo netstat -tulpn``` ? – Yasitha Bogamuwa May 16 '20 at 07:49
  • @AdmiralNoisyBottom I got this: `Failed to start mysqld.service: Unit mysqld.service not found.` – Nikita Gupta May 17 '20 at 14:12
  • @YasithaB updated the question. – Nikita Gupta May 17 '20 at 14:13
  • @NikitaGupta As you can see in the output, MySQL is not running. That's why you get that error. What is the output of ```systemctl status mysql.service``` and ```journalctl -xe```? – Yasitha Bogamuwa May 17 '20 at 15:31

0 Answers0