Question

Setting up multiple WP sites in a LEMP server

I want to use my LEMP server to host HTML and WP sites. I created my first WP site following this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04, the only thing that I changed is, that I didn’t install the WP on the root, I’ve installed my WP in /var/www/html/webs/wpsite because I will have many WP sites in /myfolder/

So what I’d like to have, is access to the WP site on this way myIP/webs/wpsite until I point the DNS to the domain, but I cant.

Supposedly I should get access to the WP site that I install through that URL, since I configured the nginx block on the below, but anytime that I go to myIP/webs/wpsite it automatically redirect me to the main IP, to the IP of my server, I can’t understand why. Here it is my configuration on sites-available:

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

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

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

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =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/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page 500 502 503 504 /50x.html;
        #location = /50x.html {
        #       root /usr/share/nginx/html;
        #}
       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       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;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Thanks for your help!

Now I’m understanding further how this works. I deployed my first web and made it works on my Lemp server being pointed by my domain hosted in godaddy.

Finally I realised that at least, in my case, I don’t need to create subdomains in my domain registar to point it to the server. What I did in godaddy, was just setting the IP and the name server, ns1.digitalocean.com and so- on…and then, in the nginx block, I just set the path on the root and the domain name on the server_name. Then, I think that when the request from godaddy comes to my server, it looks on the file to find the domain name to match, and then, the root path tell to the request where is the web hosted.

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

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

        # Make site accessible from http://localhost/
        server_name www.mydomain.com

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =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/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

So far is going good. But I’d like to access to my WP sites by something like myipserver/webs/anyWP, since sometimes, I do first the develop of the website without pointing the domain to the folder, and once the website is done, I point it…do you know how can I perform that? Maybe pointing my corporative domain to /var/www/html so I could access to that websites by mycorporativedomain/webs/anyWP?

Thanks.

yes you will need to create subdomains from your Godaddy Control Panel (Unless you setup a Nameserver using bind).

If you need help you just need I’m available through the day until about 10pm BST (UTC +1)

Affix I tried to set up Chef, but I’m stacked just in the first step. I didn’t have installed Yum, so I installed it without problems. Now, when I try to install the Chef core, says that I just can do it as a Root, and I’m accesing to my server as a user, since I restricted the access to root to prevent atacks.

Then I tried this sudo yum localinstall chef-server-core-12.0.7-1.el6.x86_64.rpm but says ``` Cannot open: chef-server-core-12.0.7-1.el6.x86_64.rpm. Skipping. Nothing to do


Anyway, I think that I could do this by myself, I just have to get it.

The thing is this. Currently I have a shared hosting in godaddy. There, I have my main domain (my corporative html website) and my wp sites, with all the domains hosted.

I don't what I have to do first, but could be pointing my main domain to my digital ocean server to start hosting my corporative website in  /var/www/html.

I didn't understand what you wrote about subdomains...what I want to do is pointing my domains from godaddy directly to the wp site directory...shoud I create first subdomains to perform this?