WordPress specific Nginx configurations, tweaks, and much more!
There are multiplpe advantages of using this repo as your go-to nginx configuration.
if
statement because ifisevil.Tested with the following servers...
Tested with the following Nginx versions...
For RPM based distros (Fedora, Redhat, CentOS and Amazon Linux AMI), the configuration mentioned in the repo is likely to work. Additional steps may be needed, though. See below for some details!
CentOS has a different file naming convention, yet simple directory structure, when compared to Debian derivatives. Let me describe them and I'd let you decide upon how you'd want to structure your files and name those files.
default.conf
and ssl.conf
in /etc/nginx/conf.d/
.sites-available
or sites-enabled
folder./etc/nginx/fastcgi_params
in Debian is named as /etc/nginx/fastcgi.conf
in CentOS.Short answer: Use WordPress in a box. It sets up your server with all the goodies, including this repo!
Long answer:
Note: For all the steps mentioned below, sudo or root privilege is required!
Step #1 - Install Nginx
You may use the official Nginx repo or just use the Nginx package that comes with the OS. Both would work fine! I will leave the decision to you. Since, the installation process varies across Operating Systems, please refer the official installation guide to complete this step.
If you prefer to use the Nginx packages that comes with the OS, you may need to run the following...
sudo apt install nginx
or
sudo yum install nginx
Step #2 - Please backup your existing configuration files. Probably, have /etc
under version control!
TIMESTAMP=$(date +%F_%H-%M-%S)
mkdir ~/nginx-backup-$TIMESTAMP
sudo cp -a /etc/nginx ~/nginx-backup-$TIMESTAMP
Step #3 - Copy this repo to your server.
git clone https://github.com/pothi/wordpress-nginx.git ~/git/wordpress-nginx
sudo cp -a ~/git/wordpress-nginx/* /etc/nginx/
sudo mkdir /etc/nginx/sites-enabled &> /dev/null
sudo cp /etc/nginx/nginx.conf /etc/nginx/
Further steps varies depending on your particular requirement:
WP_DOMAIN=example.com
WP_ROOT=/path/to/wordpress/for/example.com
sudo cp /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-available/$WP_DOMAIN.conf
sudo sed -i 's:/home/username/sites/example.com/public:'$WP_ROOT':gp' /etc/nginx/sites-available/$WP_DOMAIN.conf
sudo sed -i 's/example.com/'$WP_DOMAIN'/g' /etc/nginx/sites-available/$WP_DOMAIN.conf
cd /etc/nginx/sites-enabled/
sudo ln -s ../sites-available/$WP_DOMAIN.conf
sudo nginx -t && sudo systemctl restart nginx
Yes. I offer paid support and can implement it on your server. Minimum fee is USD50. Please contact me for any queries in this regard.
Please ping me on Twitter or send me a message.
If you find this repo useful, please spread the word! Suggestions, discussion on best practices, bug reports, future requests, forks are always welcome!