Setting up my web root directory

April 2, 2015 2.9k views
Nginx WordPress

I installed in my LEMP server wordpress under this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04 and it works fine.

Then when I go to my server IP it opens the wordpress site. But I need to have many WP sites, so what I did, is I created a directory called secure/ and I copied the content of the wordpress into another directory that I created in secure/ so now the wordpress site is in secure/wordpress/ but still when I go my server IP it shows the wordpress site and it shouldnt since I moved all the content to another directory.

How could that happens?

1 comment
  • Did you make sure to refresh the page in the browser after moving the files. Your nginx config should route requests to your index.php so you may need to update the configuration to reflect the new location and restart nginx but you should be seeing an error after just moving those files.

3 Answers

I restarted the nginx server and now the IP doesnt point to the site, thanks.

Then, I moved my wordpress installation folder into a folder that I called secure/ from /home/myserveruser to /home/myserveruser/secure/wordpress and I modified the Nginx config file to like the shown below, but not when I go to myserverIP/secure/wordpress nothing happens, it shows a 404 not found.

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/secure/wordpress;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name myserverIP;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?q=$uri&$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/www;
        }

        location ~ \.php$ {
                       try_files $uri =404;
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}

Did you reload your nginx configuration? By the way, you should remove default_server from the listen line.

Keep it as: listen IP:80; and comment the ipv6 version for test purpose.

What is default_server for? Why in the tuturial doesnt say anything about removing that?

One more thing, I installed again Wordpress in the LEMP server under the same tutorial, so what I have now, is WP located in a folder in the root of my server. I will need to have in my root server the HTML files of my main corporative website, and I'd like to have another folder, with all the rest of my WP sites that I have in another hosting and that I have to migrate to this new one.

How can I start creating new WP installations and how can I start migrating the old WP sites from my other hosting?

Have another answer? Share your knowledge.