Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have this environment almost working, but permalinks and images are not working.

My site is deployed in /var/www/staging-site/current/public; My Wordpress blog is deployed in /var/deployer/www/blog;

http {
   server {
        listen  80;
        server_name www.mysite.com;
        access_log  logs/nosubdomain.access.log;
        return 301 $scheme://mysite.com$request_uri;

    server {
        listen       80;
        server_name  mysite.com *.mysite.com;
        #charset koi8-r;

        access_log  logs/subdomain.access.log;
        root /var/www/staging-site/current/public;

        location / {
            passenger_enabled on;
            rails_env staging;
                root /var/www/staging-site/current/public;

        location /blog/ {
           root          /home/deployer/www;
           fastcgi_index  index.php;

           if (!-e $request_filename) {
             rewrite  ^(.*)$  /blog/index.php?q=$1  last;
           fastcgi_param  SCRIPT_FILENAME    /home/deployer/www$fastcgi_script_name;
           fastcgi_pass   localhost:9000;  # port to FastCGI

        location ~* ^/assets/{
                root /var/www/staging-site/current/public;
                expires max;
                add_header Cache-Control public;

I want www.mysite.com to show my site, and www.mysite.com/blog to show wordpress blog. It works, but the links doesnt work. For example http://mysite.com/blog/wp-content/uploads/2012/04/bname-268x300.jpg&w=150&h=150&zc=1&q=90 doesnt show the image, that is there, it shows the root of the blog.

Any help?

share|improve this question
If at all possible, you should put these on separate subdomains. These configurations are extremely difficult or impossible to get right. –  Michael Hampton Feb 14 '13 at 22:02
Can you help me? What do you mean with separate subdomains? my site has different subdomains for each user: user1.mysite.com, user2.mysite.com but they are all managed by the rails server. –  Tony Feb 14 '13 at 22:04
I mean that blog.mysite.com should be used for the WordPress blog. –  Michael Hampton Feb 14 '13 at 22:05
I am new with nginx. Can you help me setting that up? –  Tony Feb 14 '13 at 22:05
You just make a new server section for blog.mysite.com and put the WordPress configuration in it. The WordPress wiki has a good example configuration. –  Michael Hampton Feb 14 '13 at 22:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.