Nested WordPress installations using Nginx
-
I’m trying to setup a WordPress site to sell “Premium WordPress Themes” using Nginx. Let’s say that the main domain is
example.comand the subdomain isthemes.example.comAt this point everything is working properly. This is how my config file looks right now:
# Main domain pointing to the main WordPress installation server { listen 80; root /srv/www/example.com/webdata; server_name example.com www.example.com localhost; include wordpress-site.conf; } # Subdomain pointing to another WordPress installation # This can be achieved using a WordPress Multisite setup, # but for this project, it needs to be separated. server { listen 80; root /srv/www/themes.example.com/webdata; server_name themes.example.com; include wordpress-site.conf; }Inside wordpress-site.conf are all the directives required for WordPress
index index.php; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; }I’m getting trouble setting up the demo sites (to preview the premium themes online). The URL should look like this:
themes.example.com/name-of-the-theme/demo.My first approach was to add a location block inside the subdomain directive. Something like this:
# Subdomain pointing to another WordPress installation server { listen 80; root /srv/www/themes.example.com/webdata; server_name themes.example.com; location /name-of-the-theme/demo { # Points to another WordPress installation root /srv/www/themes.example.com/themes/name-of-the-theme/webdata; } include wordpress-site.conf; }The problem is that instead of open the
index.phplocated in the specified root, I get a 404 error in themes.example.com because the page doesn’t exist (obviously).How can I tell Nginx to use the specified WordPress Installation when the user type themes.example.com/name-of-the-theme/demo?
I know that this can be achieved with Multisite Setup, but in this case I REALLY need separated installations.
Thanks in advance!PD: This is how my directory structure looks like, if it helps. In the webdata directory are located all the WordPress files required for each site.
[srv] |--[www] |--[example.com] <---- Main Site | |--[webdata] | |--[logs] |--[themes.example.com] <---- Subdomain |--[webdata] |--[logs] |--[themes] <---- Demo Sites |--[premium-theme-01] | |--[webdata] | |--[logs] |--[premium-theme-02] | |--[webdata] | |--[logs] |--[premium-theme-03] |--[webdata] |--[logs]
The topic ‘Nested WordPress installations using Nginx’ is closed to new replies.