Nginx WordPress Subdirectory Configuration

Have a Nginx Server and wordpress present at subdirectory like http://www.example.com/blog .Usually by using nginx we have problems with Permalink Settings of the wordpress.

i have searched the web to solve the problem and finally i got the solution it was easy though.this is simple configuration which will put index.php in the url to all the links of wordpress

here is the nginx configuration for wordpress in a blog subdirectory.
server {
listen 80;
root /var/www;
index index.php index.html index.htm;
server_name http://www.example.com;

location / {
index index.php index.html index.htm;
}

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

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

After updating the configuration files You need to reload the nginx configuration.

sudo service nginx reload

then goto http://www.example.com/blog/wp-admin/options-permalink.php. Change the Permalink structure to custom http://www.example.com/blog/index.php/%postname%/

this solved my problem of links ,File not Found in wordpress .

one more thing always WordPress Address (URL) and  Site Address (URL) should be same  in the above context it should be www.example.com/blog .you can change this in General Settings.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s