1

I have setup an nginx + php + wordpress site at www.example.com When I go to example.com on my browseer I see my wordpress blog as I expect and can work with it flawlessly, no problem there. But now I wanted to keep using nginx for other webapps without losing the blog.

Ningx content root is at /srv/www/html Wordpress root is at /srv/www/wordpress/public_html

I wanted to for example create /srv/www/newsite and drop some webapp in there and be able to access it through example.com/newsite, is that possible?

I tried creating the equivalent in sites-available with the following content:

server {
    server_name example.com/newsite www.example.com/newsite;
    access_log /srv/www/newsite/logs/access.log;
    error_log /srv/www/newsite/logs/error.log;
    root /srv/www/newsite;

but it gives me a wordpress page-not-found.

Just to be clear, I want to keep wordpress the way it is now, I want example.com to show me worpdress by default. I just want example.com/newsite to be able to serve its own files.

1 Answer 1

1

Instead of declaring a separate server block, within your example.com server block for wordpress, you can open a new location block, like so:

location ~ /newsite/ {
  root /srv/www/;
}
4
  • you mean to modify the sites-available file for wordpress? I think that would be against good practices. This wouldnt be an app related to worpress but something completely unrelated.
    – keponk
    Apr 17, 2013 at 14:43
  • I'm referring to the nginx configuration file for your domain example.com. The fact that it's wordpress is less relevant than the fact that it's what is managing the domain. Nginx doesn't support URL's in the server_name directive, and you can only have one server {} code block per server_name.
    – Andrew Ty.
    Apr 17, 2013 at 21:10
  • I tried your advice but same issue remains. I added the new location block on the wordpress config file for nginx. Whe I try to access newsite it still shows me the 404 of wordpress.
    – keponk
    Apr 18, 2013 at 13:45
  • Have you tried moving up the location block higher in the wordpress configuration? What errors are provided in the error log? On CentOS it's located at: /var/log/nginx/error_log
    – Andrew Ty.
    Apr 18, 2013 at 17:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .