Wordpress on Vestacp with nginx + php-frm ( SSL certificate from Let's Encrypt) giving 500 Internal Server Error

September 11, 2018 87 views
Nginx LEMP WordPress DigitalOcean Ubuntu 16.04

If i remove WordPress and place a simple HTML file it works fine but when i remove it and place WordPress it gives internal server error. And auto redirect of http to https is also not working. I've worked with apache2 server in LAMP stack and it works fine with it but its my first time with LEMP stack. Am i doing something wrong??

I searched online about the problem and found a solution that nginx conf file should be modified and my both problems are gone but it did not work.

Here is the aipantomath.com.nginx.conf file that i edited from /home/admin/conf/web/

server {
    listen 80;
    listen [::]:80;
    server_name aipantomath.com www.aipantomath.com;

    return 301 https://$host$request_uri;
}

server {
    listen 443;
    listen [::]:443;
    server_name aipantomath.com www.aipantomath.com;
    root        /home/admin/web/aipantomath.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/aipantomath.com.log combined;
    access_log  /var/log/nginx/domains/aipantomath.com.bytes bytes;
    error_log   /var/log/nginx/domains/aipantomath.com.error.log error;

    location / {

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

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

        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:9001;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    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/aipantomath.com/document_errors/;
    }

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

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

    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.aipantomath.com.conf*;
}

Be the first one to answer this question.