Well If you read my article about installing Nginx+Mysql+PHP-FPM on debian or linux server you might interested in knowing how to setup wordpress on your newly installed lnmp serve. If you didnt read my article about how to install lnmp its here-http://www.ruchirablog.com/nginxmysqlphpfpm-auto-installer-centos-5-debian/
LNMP is really nice installer program I only discovered only 1 bug in it. Actually its not about security, LNMP asks your domain when installing so if you provide www.yourdomain.com for lnmp it will only setup your domain with www. So if some one access yourdomain.com ( Without www) it will not placed on the server and your web browser wont resolve that domain and sidplay Not Found error. So don’t worry now im going to write about solving this error and configuring nginx.conf correctly for complete install for wordpress. I have modified nginx.conf forWordPress Permalinks + WP Super Cache + Non WWW to WWW. , So to setup this I have included modified nginx.conf below
You need to open your nginx.conf to put this if this is a single domain lnmp server setup just login to ssh and your nginx.conf file is located in
- /usr/local/nginx/conf/nginx.conf
To edit in type ,
- nano /usr/local/nginx/conf/nginx.conf
It will open nginx.conf file in nano text editor like this-

So backup current data in nginx.conf in case something go wrong! You can select the text in the nano text editor by like you do in notepad and Ctrl+C will copy the selected data to your clip board and then open notepad and paste it. After pasting all the text to notepad take a look at my modified nginx.conf below!
I have highlighted non www to www redirect in Red color while current text in black. (You need to replace ruchirablog.com with your own domain name)
And I have highlighted text that need for supercache to work in greeen ( You dont need to modify this)
And I have highlighted text which need for wordpress permalinks to work in blue ( You dont need to modify this)
So Just delete the text in your current nginx.conf file (Do backup like i said if something goes wrong) And copy and paste included nginx.conf text to your nginx.conf file (After modifying with your own domain name)
And after pasting just press Ctrl+O (Not zero) to save the data to your nginx.conf file and then press Ctrl+X to exit.
Thats it folks. Note that this edits your main nginx.conf file and only edit like this if you only host just single wordpress website on your server and its configured with lnmp installer (http://www.ruchirablog.com/nginxmysqlphpfpm-auto-installer-centos-5-debian/) . For multiple web sites and other nginx installs you need to modify some codes differently!
After saving your nginx.conf file you need to restart lnmp by
/root/lnmp restart
Thats it folks you have complete nginx setup for wordpress!
user www www;
worker_processes 1;
error_log /home/wwwroot/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;events
{
use epoll;
worker_connections 51200;
}http
{
include mime.types;
default_type application/octet-stream;server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;sendfile on;
tcp_nopush on;keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;#limit_zone crawler $binary_remote_addr 10m;
server
{
listen 80;server_name www.ruchirablog.com ruchirablog.com;
rewrite ^(.*) http://www.ruchirablog.com$1 permanent;
}index index.html index.htm index.php;
root /home/wwwroot;location / {
# enable search for precompressed files ending in .gz
# nginx needs to be complied using .-with-http_gzip_static_module
# for this to work, comment out if using nginx from aptitude# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}set $supercache_file ”;
set $supercache_uri $request_uri;if ($request_method = POST) {
set $supercache_uri ”;
}# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri ”;
}if ($http_cookie ~* “comment_author_|wordpress|wp-postpass_” ) {
set $supercache_uri ”;
}# if we haven’t bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}# all other requests go to WordPress
if (!-e $request_filename) {
rewrite . /index.php last;
}
}location ~ .*.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;include fcgi.conf;
}
location / {
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}location /status {
stub_status on;
access_log off;
}location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}location ~ .*.(js|css)?$
{
expires 12h;
}log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log /home/wwwroot/logs/access.log access;
}
include vhost/*.conf;
}
Last 5 posts by Ruchira
- Slotomania Free Slot Games Review - February 24th, 2015
- The Role of Social Media and SEO - October 25th, 2013
- Google announces uProxy to overcome internet censorship - October 22nd, 2013
- Command line bandwidth monitors for Linux - October 21st, 2013
- Problem Kids: When You Know How To Spy On iPhone Remotely, You Worry Less And Focus Better! - August 19th, 2013


