0

I've posted this question on WP.SE, but got no replies. In the meantime I figured a solution involving proxy_pass, but it comes with a few downsides.

I have a subdomain installation of Wordpress that I'd like to serve instead at /blog. This must be an FAQ, but I haven't nailed the search terms for it (/blog being so common doesn't help).

Where can I find a full nginx config file and wp-config settings that have WordPress live at /blog? Do I need to alter any WP settings in its MySQL database? Is it practical to move my existing instance, or should I start from scratch?

0

If you already changed you site URL, as you stated in the other question, you can try with alias location, inside the existing server block.

It should look something like this

location ^~ /blog {
root /var/www/example.com;
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?$args;

location ~ \.php {
    fastcgi_split_path_info ^(.*\.php)(.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_pass 127.0.0.1:9000;
 }
}

This is assuming your WordPress install is in /var/www/blog, if not change accordingly.

You need to check if php5-fpm(assuming you are using this) actually listen on 127.0.0.1:9000 Most of the time the default socket on Debian/Ubuntu is unix:/var/run/php5-fpm.sock If you want to be sure what is the socket or change it, take a look at /etc/php5/fpm/pool.d/www.conf.

You can also take a look at this answer
Please note that in this answer configs are missing ?$args after index.php and this important for plugins like WooCommerce - they wont work properly without it.

If you want to be sure everything is correct, you can export a dump of your database, and then use find and replace with some text editor the old url with the new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.