How to fix nginx error 404

Joined
Apr 15, 2018
Messages
43
Best answers
0
Points
6
#1
I use Nginx on Wordpress site.
Every page disappeared, except homepage, and we got ''404 not found.''
I dont know how I triggered this problem.
How can I fix this problem ?
 

VirtuBox

Global Mod
Staff Member
Joined
May 3, 2016
Messages
1,524
Best answers
4
Ratings
398 12
Points
83
#2
I use Nginx on Wordpress site.
Every page disappeared, except homepage, and we got ''404 not found.''
I dont know how I triggered this problem.
How can I fix this problem ?
Hello,
you have to check your nginx configuration, 404 not found on wordpress mean the permalinks are not rewritten properly.

Your vhost should look like :
NGINX:
server {
        ## Your website name goes here.
        server_name domain.tld;
        ## Your only path reference.
        root /var/www/wordpress;
        ## This should be in your http block and if it is, it's not needed here.
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                # This is cool because no php is touched for static content.
                # include the "?$args" part so non-default permalinks doesn't break when using query string
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
                fastcgi_buffers 16 16k;
                fastcgi_buffer_size 32k;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}
more configuration examples are available in the wordpress codex
 

Dr. McKay

Well-known member
Joined
Nov 26, 2016
Messages
358
Best answers
0
Ratings
26
Points
18
#3
Dr. McKay
Nice codes but I afraid of using Nginx because I have to use codes to control configurations or setups. Is there a way that using nginx without using more codes or only using clicks only?
 

VirtuBox

Global Mod
Staff Member
Joined
May 3, 2016
Messages
1,524
Best answers
4
Ratings
398 12
Points
83
#4
VirtuBox
Excepted with some control panels like Plesk, VestaCP or CentosWebPanel (and even with them you may have to edit nginx configuration manually) Nginx is exactly like Apache, when you want to add a domain, you have to create a vhost and to set the proper settings for your domain.
But there are command line tools like EasyEngine or Centminmod to create nginx vhost automatically and to reduce as much as possible manual configuration. Otherwise, you can also find easily some configuration generator for nginx like https://nginxconfig.io/
 

Gmeister4

Well-known member
Joined
Apr 19, 2016
Messages
144
Best answers
0
Ratings
10
Points
18
#5
Gmeister4
Is Plesk still requiring manually configure some parts with it to work websites. I am confusing this because I have Plesk and hosting websites on it but problems are solved by my providers, I only submit tickets.

For example, I used Apache, I need setup rewrite rules in .htaccess file but how for Plesk? can I do a same file with Plesk or how?
 

VirtuBox

Global Mod
Staff Member
Joined
May 3, 2016
Messages
1,524
Best answers
4
Ratings
398 12
Points
83
#6
VirtuBox
Plesk use Apache + Nginx to make static content loading faster (because Nginx do the job better than Apache) but also to support .htaccess because php-fpm is managed by Apache. So it provide better performance, without impacting your application compatibility.

But you can also use Nginx to managed php-fpm process, but Nginx will not read .htaccess and it require to set your rewrite rules in the section Apache & Nginx settings > additional directives for Nginx
 
Older Threads
Replies
2
Views
154
Replies
20
Views
778
Replies
5
Views
327
Replies
9
Views
533
Newer Threads
Replies
8
Views
354
Replies
2
Views
203
Replies
0
Views
155
Latest Threads

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Latest Blog ArticlesMost Viewed Threads

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top