Nginx Configuration to Working with WordPress

nginx wordpress

Nginx is a high-performance web server, in fact some people call it better than Apache. I also think so. Nginx has good performance and potential. In the future, nginx will replace the apache web server.

Unfortunately, configuring Nginx is not as easy as Apache. For some CMS, special configuration is needed, such as wordpress. Nginx needs to be configured in order to work with wordpress.

Because of that, until now there is no shared hosting using Nginx as the default web server. Most still use apache and litespeed. Even though Nginx is much faster than Apache and uses far less resources. More effective and efficient.

For that, instead of missing, I want to save the nginx configuration file for wordpress. Proven to work on the server that I use.

    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$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.