Welcome! Log In Create A New Profile

Advanced

Re: Domain Names and directory configuration

Styopa Semenukha
November 24, 2014 10:34PM
On Monday, November 24, 2014 09:08:08 PM angelox wrote:
> I'm starting out with nginx and I'm stumbling at something I thought simple,
> but that I haven't been able to figure out, yet.
>
> I need to map three domain names, each one to its own subdirectory under the
> document root directory (/usr/share/nginx/html/) on a shared host:
>
> domain1 ---> ../html/blog
> domain2 ---> ../html/wiki
> domain3 ---> ../html/forum
>
> If this is feasible, and I'd guess it is, then I'm not sure how to begin
> setting up locations that will serve requests from those subdirectories.
>
> In all cases, when trying something like www.domain1.com, nginx invariably
> maps to the root directory. Typing www.domain1.com/blog, for example, works
> just fine. I know I must be missing some essential info on how to configure
> nginx for this type of thing, and any hint or direction would be
> appreciated.
>
> Leon

Hi,

My personal off-topic advice is to put your website data to something like /var/www instead of /usr/share/nginx in order to keep your package manager happy and to comply with the FHS recommendations:
http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

To answer your question, the config can be as follows:
server {
server_name blog.example.org;
root /var/www/blog;
....
}
server {
server_name wiki.example.org;
root /var/www/wiki;
....
}

Thus, it will serve /var/www/wiki/index.html at http://wiki.example.org/index.html.
--
Sincerely yours,
Styopa Semenukha.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Domain Names and directory configuration

angelox November 24, 2014 09:08PM

Re: Domain Names and directory configuration

Styopa Semenukha November 24, 2014 10:34PM

Re: Domain Names and directory configuration

angelox November 28, 2014 11:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 192
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready