Question

Installing WordPress on Lemp Stack - 403 forbidden

Posted January 1, 2021 609 views
NginxWordPressDigitalOceanLEMP

Hello,

I have been following through https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-20-04

However I have got to the end bit, and I cant login to the dashboard. it came up with the initial welcome page and success page then just shows, 403 forbidden.
What have I done wrong or missed out?

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

Hello, @patrickb

Can you please confirm if you’ve also followed the steps from the Prerequisites part of the article, e.g the initial LEMP stack part.

If you’ve followed that you should have UFW enabled and you can double check if Nginx HTTP is enabled.

You can also try to clear your browser’s cache or try to access the WordPress admin area using an alternative browser.

Regards,
Alex

  • Hello @alexdo

    Yes I followed https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-20-04

    and tested on the way through.

    It did cross my mind about UFW, however this is enabled and Nginx HTTP is added.

    I have tried accessing it on a different pc and it is the same.

    by Erika Heidi
    The LEMP software stack is a group of software that can be used to serve dynamic web pages and web applications written in PHP. This is an acronym that describes a Linux operating system, with an Nginx (pronounced like “Engine-X”) web server. The backend data is stored in a MySQL database, and dynamic processing is handled by PHP. In this guide, we'll set up a LEMP stack on an Ubuntu 20.04 server.
    • Thanks for getting back.

      Can I ask if you’re able to visit the site if you use the droplet’s IP address instead of the domain name?

      403 errors commonly occur when the user that is running the web server process does not have sufficient permissions to read the file that is being accessed.

      You can make sure that the www-data user has sufficient permissions to read the files. Typically, this means that the other permissions of the file should be set to read.

      Run these two find commands to set the correct permissions on the WordPress directories and files:

      sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;
      
      sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;
      

      I will also recommend you to examine the Nginx error_log file as the cause of the problem is likely to be logged in that file.

      Usually if there is not an index file a 403 Forbidden message will be displayed as well, but you already mentioned that the page was working initially and then the error came so this should not be the issue here.

      Hope that this helps!
      Regards,
      Alex

      • Thanks @alexdo

        I have set the permisions but now its giving me 404 on domain.com/wp-admin and 403 on domain.com, whereas both were 403…so slightly better but not quite right!

        log shows…
        2021/01/02 13:51:29 [crit] 4250#4250: *9 stat() “/var/www/domain.com/index.php” failed (13: Permission denied), client: 192.168.x.1, server: domain.com, request: “GET /wp-admin HTTP/1.1”, host: “www.domain.com

        • Thanks for getting back.

          Regarding the 404 error, would you mind checking the virtual host for that domain name? You can make sure that the defined root directory is not empty.

          As for the 403 error message can you confirm if you’re using SELinux?

          Regards,
          Alex

          • Bingo Thanks @alexdo

            I was following an article that pointed the root to domin.com/html/ and wordpress is not in the html folder!

            Thanks for all the help, got there in the end!

Hello, @patrickb

Glad that you’ve sorted this in the end.

Regards,
Alex