Question

Wordpress doesn't start with installing Wordpress with LEMP on Ubuntu 20.04

Posted September 28, 2020 1.1k views
UbuntuWordPressConfiguration ManagementLEMPUbuntu 18.04Ubuntu 20.04

As I was following this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-18-04, I came a long way. But then after step 5, Wordpress doesn’t start on my website.

The website keeps displaying the html message that I programmed at step 4 of this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04, which I installed in this file: /var/www/your_domain/index.html

I have to say that the OS I am using is Ubuntu 20.04 (spec Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64)), but I don’t think that the problem is there.

My best guess is that the problem must have something to do with a redirection. Can anyone help me out here? There are also similar questions below the tutorial, but the answers proposed are not working for me.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi there @KatoVonKatz,

There are a couple of things which could be causing this problem.

  • If you installed WordPress at /var/www/html/, you would need to remove the index.html file from there, you can do that with the following command:
  • rm /var/www/html/index.html

This needs to be done as WordPress uses an index.php file and that index.html is not part of the WordPress core files anyway.

  • Make sure that the directory that you’ve installed WordPress in has the correct ownership:
  • sudo chown -R www-data:www-data /var/www/wordpress

Change the /var/www/wordpress part if this is not the directory where you installed WordPress at.

  • If none of the above helps, check your Nginx error log:
  • sudo tail -100 /var/log/nginx/error.log

Let me know how it goes!
Regards,
Bobby

  • Thank you so much! The solution was indeed to remove the index.html file.

    • Hi there @katovonkatz,

      No problem at all! Happy to hear that you’ve got it working now!

      Regards,
      Bobby

      • Hi @bobbyiliev , sorry, it’s me again. I am configuring this for the second time, but now I have the same problem.

        Following your previous advice, I have removed the full directory /var/www/html. This included the html file.

        Now, I have a /var/www/donutnetwerk.nl directory with the following files:

        index.html

        todo_list.php

        wp-comments-post.php

        wp-cron.php

        wp-login.php

        wp-trackback.php
        index.php

        wp-activate.php

        wp-config-sample.php

        wp-includes

        wp-mail.php

        xmlrpc.php
        license.txt

        wp-admin

        wp-config.php

        wp-links-opml.php

        wp-settings.php
        readme.html

        wp-blog-header.php

        wp-content

        wp-load.php

        wp-signup.php

        This is the content of my /etc/nginx/sites-available/donutnetwerk.nl file.

        server {
            server_name donutnetwerk.nl www.donutnetwerk.nl;
            root /var/www/donutnetwerk.nl;
        
            index index index.html index.htm index.php;
        
            location / {
                #try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php$is_args$args;
            }
        
            location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
             }
        
            location ~ /\.ht {
                deny all;
            }
        
            location = /favicon.ico { log_not_found off; access_log off; }
            location = /robots.txt { log_not_found off; access_log off; allow all; }
            location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
                expires max;
                log_not_found off;
            }
        
            listen 443 ssl; # managed by Certbot
            ssl_certificate /etc/letsencrypt/live/donutnetwerk.nl/fullchain.pem; # managed by Certbot
            ssl_certificate_key /etc/letsencrypt/live/donutnetwerk.nl/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.donutnetwerk.nl) {
                return 301 https://$host$request_uri;
            } # managed by Certbot
        
        
            if ($host = donutnetwerk.nl) {
                return 301 https://$host$request_uri;
            } # managed by Certbot
        
        
            listen 80;
            server_name donutnetwerk.nl www.donutnetwerk.nl;
            return 404; # managed by Certbot
        }
        

        And this is the result in my browser: https://donutnetwerk.nl/

        I have tried to follow this tutorial now about 10 times and everytime I run into this problem. Do you have any idea how I can troubleshoot?

        Thanks again, you save my life everytime :)

        • Hi there @katovonkatz,

          Yes, it is most likely the index.html file that is causing the problem for you. As it is not part of the WordPress installation you could just delete it:

          • sudo rm /var/www/donutnetwerk.nl/index.html

          The reason why the index.html is being served first and not the index.php file is this line here in your config file:

              index index index.html index.htm index.php;
          

          It basically tells Nginx to look first for an index.html file in the document root directory and if there is one it should be served first, and if there is no index.html then Nginx will look for index.htm and if there is no index.htm, then finally Nginx will look for index.php.

          To fix that you can either delete the inedx.html or/and update the line to:

              index index index.php index.html index.htm;
          

          That way the index.php will have a higher priority.

          Also besides that, at the moment if I try to visit yourdomain.com/index.php directly I can see a 500 error, for this I would recommend checking your Nginx or/and PHP error logs.

          Hope that this helps!
          Regards,
          Bobby

          • I found the problem!

            It was this line in the /var/www/wordpress/wp-config.php file:

            define('FS_METHOD', 'direct');
            

            When I uncomment it, I get redirected to the Installation of Wordpress.

            Do you have any idea why the author mentions this in the article? And also if it’s smart to leave it uncomment or that I should add a different line of code?

          • Hi there @katovonkatz,

            Usually setting FS_METHOD is needed so that you don’t have to specify FTP details when installing plugins and themes.

            Did you see any errors in your error log when having the FS_METHOD enabled?

            Regards,
            Bobby

@bobbyiliev , I will start a new threat here, because I can’t reply to you anymore via the above.

Yes, I did get an error report when I requested the nginx error log, but I can’t replicate that anymore.

But… now that I have the website up and running, as soon as I activate the code below, my website is down with an HTTP ERROR 500 message.

define('FS_METHOD', 'direct');

As soon as I remove the command, the website is active again. So, this really is the problem. I will share with you my error log. Maybe this has something to do with the transition from Ubuntu 18.04 to Ubuntu 20.04?

sudo tail -100 /var/log/nginx/error.log
2020/10/27 00:17:45 [error] 88235#88235: *2262 directory index of "/var/www/html/" is forbidden, client: 61.58.80.242, server: _, request: "GET / HTTP/1.1", host: "127.0.0.1"
2020/10/27 00:30:59 [error] 88235#88235: *2263 directory index of "/var/www/html/" is forbidden, client: 176.173.255.186, server: _, request: "GET / HTTP/1.1", host: "134.122.61.246"
2020/10/27 01:17:53 [error] 88235#88235: *2284 directory index of "/var/www/html/" is forbidden, client: 203.76.115.83, server: _, request: "GET / HTTP/1.1", host: "127.0.0.1"
2020/10/27 03:34:30 [error] 88235#88235: *2325 directory index of "/var/www/html/" is forbidden, client: 178.128.194.144, server: _, request: "GET / HTTP/1.1", host: "134.122.61.246"
2020/10/27 03:35:49 [error] 88235#88235: *2327 directory index of "/var/www/html/" is forbidden, client: 162.243.128.230, server: _, request: "GET / HTTP/1.1", host: "134.122.61.246"
2020/10/27 05:44:42 [error] 88235#88235: *2377 directory index of "/var/www/html/" is forbidden, client: 209.194.163.115, server: _, request: "GET / HTTP/1.1", host: "127.0.0.1"
2020/10/27 05:55:08 [error] 88235#88235: *2382 directory index of "/var/www/html/" is forbidden, client: 192.35.168.96, server: _, request: "GET / HTTP/1.1", host: "134.122.61.246"
2020/10/27 07:47:45 [error] 88235#88235: *2419 directory index of "/var/www/html/" is forbidden, client: 193.27.229.26, server: _, request: "GET /?XDEBUG_SESSION_START=phpstorm HTTP/1.1", host: "134.122.61.246:80"
2020/10/27 07:50:22 [error] 88235#88235: *2424 directory index of "/var/www/html/" is forbidden, client: 220.132.207.155, server: _, request: "GET / HTTP/1.1", host: "127.0.0.1"
2020/10/27 07:59:31 [error] 88235#88235: *2426 directory index of "/var/www/html/" is forbidden, client: 193.27.229.26, server: _, request: "GET /?a=fetch&content=<php>die(@md5(HelloThinkCMF))</php> HTTP/1.1", host: "134.122.61.246:80"
2020/10/27 08:28:36 [notice] 94444#94444: signal process started
2020/10/27 08:28:43 [error] 94445#94445: *2447 FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected 'define' (T_STRING) in /var/www/donutnetwerk.nl/wp-config.php on line 52" while reading response header from upstream, client: 91.141.140.37, server: donutnetwerk.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "donutnetwerk.nl"
2020/10/27 08:28:49 [error] 94445#94445: *2448 FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected 'define' (T_STRING) in /var/www/donutnetwerk.nl/wp-config.php on line 52" while reading response header from upstream, client: 91.141.140.37, server: donutnetwerk.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "donutnetwerk.nl"
2020/10/27 08:28:55 [error] 94445#94445: *2452 FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected 'define' (T_STRING) in /var/www/donutnetwerk.nl/wp-config.php on line 52" while reading response header from upstream, client: 91.141.140.37, server: donutnetwerk.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "donutnetwerk.nl

  • Hey there @katovonkatz,

    I’ve just tried to recreate this at my end and it seems to work fine with define('FS_METHOD', 'direct');, but the error would occur if there is another define not closed correctly with ; before that.

    It is possible that the WordPress secret keys could be causing that. You could try regenerating the secret keys and also try to add the define('FS_METHOD', 'direct'); part right after define( 'DB_COLLATE', '' ); line for example.

    If you wish feel free to share your wp-config.php file here so I could have a look, just make sure to remove any sensitive information like database password, user and etc.

    Regards,
    Bobby

    • O my, you are right, I was missing the semicolon after the

      define('FS_METHOD', 'direct');
      

      command! I am so embarrased!

      But honestly, I can’t imagine that I made this mistake the several times I tried to re-install. So I will leave this post open, maybe someone else in the community can benefit from all your help!