Report this

What is the reason for this report?

how to configure ngnix.config for wordpress ?[Permalink error] Using VestaCP - Ngnix php FPM

Posted on February 2, 2017

Hello. i am facing problem configuring ngnix.config block to support wordpress.

my wordpress shows 404 error when i put is to postname. others except plain text doesnt seems to be working.

after going through some doc , i figured that ngnix.config need modification to support .htaccess like behavior.

please can anyone check whats the problem?

server block is configured as below server { listen 139.59.10.214:80; server_name chetantest.tk www.chetantest.tk; root /home/admin/web/chetantest.tk/public_html; index index.php index.html index.htm; access_log /var/log/nginx/domains/chetantest.tk.log combined; access_log /var/log/nginx/domains/chetantest.tk.bytes bytes; error_log /var/log/nginx/domains/chetantest.tk.error.log error;

location / {

    location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
        expires     max;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        if (!-f $document_root$fastcgi_script_name) {
            return  404;
        }

        fastcgi_pass    127.0.0.1:9003;
        fastcgi_index   index.php;
        include         /etc/nginx/fastcgi_params;
    }

    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
    
    if ($scheme = http) {
           	return 301 https://$server_name$request_uri;
    }

}

error_page  403 /error/404.html;
error_page  404 /error/404.html;
error_page  500 502 503 504 /error/50x.html;

location /error/ {
    alias   /home/admin/web/chetantest.tk/document_errors/;
}

location ~* "/\.(htaccess|htpasswd)$" {
    deny    all;
    return  404;
}

location /vstats/ {
    alias   /home/admin/web/chetantest.tk/stats/;
    include /home/admin/web/chetantest.tk/stats/auth.conf*;
}

include     /etc/nginx/conf.d/phpmyadmin.inc*;
include     /etc/nginx/conf.d/phppgadmin.inc*;
include     /etc/nginx/conf.d/webmail.inc*;

include     /home/admin/conf/web/nginx.chetantest.tk.conf*;

}

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.