Question

404 Not Found error when loading the ulr of the second virtual block. What I am doing wrong?

Posted March 7, 2015 15.6k views
NginxUbuntuPHPWordPressDigitalOceanDNS

I followed this tutorial to configure the server for running 2 Wordpress installations:
https://www.digitalocean.com/community/tutorials/how-to-configure-single-and-multiple-wordpress-site-settings-with-nginx

I have configure it with nginx, hhvm, ubuntu 14.04 and mysql. All was running smooth with the first Wordpress single installation.

After that, I tried to set up a second virtual block to migrate there my multisite with subdomains and there is where the trouble started.

I imported the database with the same database name and user than in the previous hosting (Hostgator), and copied the whole wordpress installation into a new folder at var/www. But I get the “404 Not Found nginx/1.6.2” screen.

What can be wrong?

My server block for the new configuration is:

server {
server_name *.thecrazytravel.com;
root /var/www/thecrazytravel;
access_log /var/log/nginx/thecrazytravel.com.access.log;
error_log /var/log/nginx/thecrazytravel.com.error.log;
include global/common.conf;
include global/wordpress.conf;
include hhvm.conf;
}

It is enabled, the same than the first block.

I changed the DNS in my domain to point to digitalocean’s nameservers but I reverted it after noticing the error. I am testing now pointing from my computer to digitalocean server with my local host file (just in case you check it out and it works).

My DNS configuration on Digitalocean is:

http://i.imgur.com/7qMEjLX.png

I tried as well with the wild card (*) as CNAME but it didn’t make any difference.

Is it something wrong on the nginx configuration? Or a permissions problem?

I assigned var/www/thecrazytavel to the same user than var/www/workraw (the other block) and tried with the same permits and nothing changed.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

I solved it. I still have to polish it, but it is working. I just rewrote most of it instead of using the system of the tutorial I followed.

My code at the moment is:

server {
        ##DM - uncomment following line for domain mapping
        #listen 80 default_server;
        server_name thecrazytravel.com *.thecrazytravel.com ;
        ##DM - uncomment following line for domain mapping
        #server_name_in_redirect off;

        access_log   /var/log/nginx/thecrazytravel.com.access.log;
        error_log    /var/log/nginx/thecrazytravel.com.error.log;

        root /var/www/thecrazytravel;
        index index.php index.html index.htm;
        include hhvm.conf;

# PLUGINS : Enable Rewrite Rules for Yoast SEO SiteMap
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

# Rewrite rules for WordPress Multi-site.
rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;
if (!-e $request_filename)
{
rewrite ^.+?/?(/wp-.*) $1 last;
rewrite ^(.+)$ /index.php;
}

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

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
    # ENABLE : Enable PHP, listen fpm sock
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    include fastcgi_params;
        }

        location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
                access_log off; log_not_found off; expires 30d;
        }

        location = /robots.txt { access_log off; log_not_found off; }
        location ~ /\. { deny  all; access_log off; log_not_found off; }
}

It could be improved, but it is running now. I hope it helps somebody out there with the same problem.

Submit an Answer