Sorry but I am having a little issue after following this guide.
It seems to be coming from the config file that Nginx uses to locate WordPress

My current syntax is:

server {

    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;
    }



        location / {
                try_files $uri / /index.php$is_args$args;
        }
}

I am using a Linux mint 19 system (runs Ubuntu 18.04), and all things related to the LEMP stack are well set, and I am hosting on my laptop’s localhost but when I enter ‘localhost’ in browser I get a 403 error.

Seems there is no file for Nginx to process, please help me get through this issue.

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.

×
2 answers

Hi there @stealthman,

I believe that you need to follow the prerequisites as well, for example, if you go through this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04

You will notice that there are two additiaonal settings that you have to add:

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

And that you also need to have PHP FPM installed.

Let me know how it goes!
Regards,
Bobby

by Justin Ellingwood
by Mark Drake
This tutorial details the process for installing and configuring the components that constitute a LEMP stack on an Ubuntu 18.04 server, including Nginx, MySQL, and PHP. It also includes instructions for testing that these components can communicate effectively and serve your content correctly.
  • Thanks, Bobby I will do that right away

  • Hey, Bobby, I do have all these in my FastCGI conf file, my question is what exactly should be the contents of the WordPress conf file?
    I have FastCGI installed and enabled already, this is what its config file in /etc/nginx/sites-available look like:

    server {
            listen 80;
            root /var/www/html;
            index index.php index.html index.htm index.nginx-debian.html;
            server_name localhost;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            }
    
            location ~/\.ht {
                    deny all;
            }
    
    
    }
    

    And that for WordPress currently looks like this:

    server {
            listen 80;
            root /var/www/html;
            index index.php index.html index.htm index.nginx-debian.html;
            server_name localhost;
    
            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.2-fpm.sock;
            }
    
            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;
        }
    
            location ~/\.ht {
                    deny all;
            }
    
    
    }
    

    What am I missing? It still gives a 403 error when I visit localhost.

    • Hey, Bobby, I think I have figured out the whole config file thing.
      Right now the error is now showing this:

      This page isn’t working localhost is currently unable to handle this request.
      HTTP ERROR 500
      

      Using a single config file now:

      server {
              listen 80;
              root /var/www/wordpress;
              index index.php index.html index.htm index.nginx-debian.html;
              server_name localhost;
      
              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;
          }
      
              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.2-fpm.sock;
              }
      
      }
      
      
      

waoo this is a great resource
I would study it deeply

Submit an Answer