Title: WordPress and Nginx (OpenResty)
Author: Immanuel Raj
Published: January 23, 2024
Last modified: November 21, 2025

---

# WordPress and Nginx (OpenResty)

[January 23, 2024](https://immanuelraj.dev/wordpress-and-nginx-openresty/)

—

by

[Immanuel Raj](https://immanuelraj.dev/author/iamimmanuelraj/)

in [Linux](https://immanuelraj.dev/category/linux/), [Networking](https://immanuelraj.dev/category/networking/),
[WordPress](https://immanuelraj.dev/category/wordpress/)

Read Time

2–3 minutes

## WordPress

WordPress is a web content management system. It was originally created as a tool
to publish blogs but has evolved to support publishing other web content, including
more traditional websites, mailing lists and Internet forum, media galleries, membership
sites, learning management systems and online stores.

---

## Ngins (Open Resty)

OpenResty^(®) is a full-fledged web platform that integrates our enhanced version
of the [Nginx](https://openresty.org/en/nginx.html) core, our enhanced version of
[LuaJIT](https://github.com/openresty/luajit2), many carefully written Lua libraries,
lots of high quality [3rd-party Nginx modules](https://openresty.org/en/components.html),
and most of their external dependencies. It is designed to help developers easily
build scalable web applications, web services, and dynamic web gateways.

---

## File Structure

The file structure is important to know which files to modify and which ones to 
not. Some are auto generated and auto modified (as we modify the settings in the
admin GUI dashboard. Some are done manually [Only a very few things, that too very
rarely])

    ```wp-block-code
    https://www.wpbeginner.com/beginners-guide/beginners-guide-to-wordpress-file-and-directory-structure/
    ```

The above link talks about some basic file structure.

---

## Working

![](https://www.wpbeginner.com/wp-content/uploads/2017/05/wp-behind-the-scenes.png)

---

## Installing

The installation can be done by 2 methods

 * Manually unpacking files (from tar)
 * Using WP-CLI (Almost Automated)

#### Manual Installation

Manual installation implies creating a repository, then downloading the package(
tar) from wordpress and then unpacking it in a repository and then setting up the
configs and database that is needed.

    ```wp-block-code
    https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-18-04
    ```

More about the manual method above.

#### WP-CLI

[WP-CLI](https://wp-cli.org/) basically stands for WordPress CLI and can be used
to automate some task like creating db, site root directory, installation , configuration
etc. This makes it easier to install WordPress on any machine at ease.

    ```wp-block-code
    https://make.wordpress.org/cli/handbook/guides/installing/#recommended-installationhttps://make.wordpress.org/cli/handbook/guides/quick-start/#practical-examples
    ```

Steps to follow for automatic(wp-cli) method is above

## Nginx Config

Both of these needs nginx configs setup manually only (Can be automated)

    ```wp-block-code
    ...http {    include       mime.types;    default_type  application/octet-stream;    server {...   	root /var/www/wordpress/wordpress.example.com;	index index.php index.html;...	location / {		index index.php index.html;    		try_files $uri $uri/ /index.php$is_args$args;	}	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;    		}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        location ~ \.php$ {            root           /var/www/wordpress/wordpress.example.com;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        location ~ /\.ht {            deny  all;        }...
    ```

This is a basic config that needs to be done in order to have a fully working wordpress
instalaltion.

---

## Possible Issues

You can face issues in CSS breaking in the site if nginx is not configured properly
or if ssl is not configured properly.

Php Dependencies

[linux](https://immanuelraj.dev/tags/linux/) [nginx](https://immanuelraj.dev/tags/nginx/)
[openresty](https://immanuelraj.dev/tags/openresty/) [self-hosting](https://immanuelraj.dev/tags/self-hosting/)
[ubuntu](https://immanuelraj.dev/tags/ubuntu/) [wordpress](https://immanuelraj.dev/tags/wordpress/)

[Previous:  Linux Saviours](https://immanuelraj.dev/linux-saviours/)

[Next:  Power to you.](https://immanuelraj.dev/power-to-you/)

![Immanuel Raj Avatar](https://secure.gravatar.com/avatar/88db6e1fa27cf854075acbaa156189ace30cf3701b2d8640cd774280ead1d4d3?
s=80&d=mm&r=g)

## About the author

Software Developer & Technology Consultant

---

## Popular Categories

 * [Bible](https://immanuelraj.dev/category/bible/) (1)
 * [Cloudflare](https://immanuelraj.dev/category/cloudflare/) (1)
 * [Databases](https://immanuelraj.dev/category/databases/) (1)
 * [Docker](https://immanuelraj.dev/category/docker/) (1)
 * [Email](https://immanuelraj.dev/category/email/) (1)
 * [ERPNext](https://immanuelraj.dev/category/erpnext/) (3)
 * [Frappe](https://immanuelraj.dev/category/frappe/) (2)
 * [Github Actins](https://immanuelraj.dev/category/github-actins/) (1)
 * [God](https://immanuelraj.dev/category/god/) (1)
 * [Google Cloud](https://immanuelraj.dev/category/gcp/) (1)
 * [Hosting](https://immanuelraj.dev/category/hosting/) (2)
 * [Life](https://immanuelraj.dev/category/life/) (1)
 * [Linux](https://immanuelraj.dev/category/linux/) (13)
 * [ML](https://immanuelraj.dev/category/ml/) (1)
 * [Networking](https://immanuelraj.dev/category/networking/) (2)
 * [Security](https://immanuelraj.dev/category/security/) (2)
 * [Self Hosting](https://immanuelraj.dev/category/self-hosting/) (7)
 * [SSL](https://immanuelraj.dev/category/ssl/) (3)
 * [Terminal](https://immanuelraj.dev/category/terminal/) (1)
 * [Tools](https://immanuelraj.dev/category/tools/) (2)
 * [Uncategorized](https://immanuelraj.dev/category/uncategorized/) (8)
 * [Web](https://immanuelraj.dev/category/web/) (2)
 * [WordPress](https://immanuelraj.dev/category/wordpress/) (1)

---

## Useful Links

Links I found useful and wanted to share.

 * [Sponsor Me](https://github.com/sponsors/iamimmanuelraj)

---

## Search the website

Search