서브도메인을 하기 위해 찾아보다가... 나중에 또 까먹을거같아서 대략적으로 정리

막상 찾아보니 어렵진 않다....



1. Ubuntu /etc/nginx/sites-available/default 파일 수정


$ sudo
nano /etc/nginx/sites-available/default
server{

listen 80;

listen [::]:80; #서버 기본세팅을 해주었기 때문에 (위쪽) 중복으로 ipv6, default_server와같은 세팅X


root /home/경로

index index.php index.html index.htm


#Make site accessible from http://localhost/

server_name sub.domain.com;

}



$ sudo service nginx restart


2. Creating or pointing domains/subdomains to the server's ip address.

Go to your domain register or to the DNS where your domain records are stored and point them to your server ip address (you can do this with a subdomain too). If you are trying this locally modify the "/etc/hosts" files and create a new record.

$ sudo nano /etc/hosts

And add something like.

127.0.0.1    example.com
127.0.0.1    example2.com
127.0.0.1    my.example.com



3. DigitalOcean(내가 쓰는 서버 호스팅) 에서 DNS 세팅 - CNAME 설정






참고 : http://albertogrespan.com/blog/running-multiple-domains-or-subdomains-in-nginx-with-server-blocks/

+ Recent posts