I have bought a dedicated server from DigitalOcean, and configured nginx
, mysql and php, its IP address is a.b.c.d
. I have bought two domains from GoDaddy
: siteone.com
and sitetwo.com
. I made a subdomain sub.siteone.com
, it will be a WordPress
site. I made sub.siteone.com
forward to a.b.c.d
in GoDaddy
.
By following this post and this post, I put the WordPress files under /var/www/sub.siteone.com/html/
. /etc/nginx/sites-available/sub.siteone.com
contains follows:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/sub.siteone.com/html;
index index.php index.html index.htm;
server_name sub.siteone.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
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;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
As a result, when I enter sub.siteone.com
in a browser, it redirects to a.b.c.d
and shows well the WordPress site.
The problem is that I want my server (a.b.c.d
) to contain several sites (i.e., domains). So a mechanism I imagine would be a.b.c.d/one/
contains the first domain, and a.b.c.d/two/
contains the second domain. As a result,
- when I enter
sub.siteone.com
in a browser, the url remains the same while the content is froma.b.c.d/one/
; - when I enter e.g.
sub.siteone.com/photos/
in a browser, the url remains the same while the content is froma.b.c.d/one/photos
; - when I enter
sitetwo.com
in a browser, the url remains the same while the content is froma.b.c.d/two/
; - when I enter e.g.
sitetwo.com/downloads/
in a browser, the url remains the same while the content is froma.b.c.d/two/downloads
Could anyone tell me if this mechanism makes sense? And how could I modify the setting of nginx and GoDaddy to realise that?