1. 도메인 DNS 설정
도메인을 구매하신 곳에서 DNS 설정에 들어갑니다.
아직 도메인이 없으신 분들은 아래 URL에서 무료로 만드실 수 있습니다.
Freenom - A Name for Everyone
Cost Price Free Special
www.freenom.com

Name, Type, TTL, Taget 위와 동일하게 설정해줍니다.
설정방법은 도메인 구매처별로 상이합니다.
2. Nginx 라우팅 설정
EditPlus로 /etc/nginx/sites-available/default 열기 합니다.
# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name 도메인.com;
location / {
try_files $uri $uri/ =404;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}
server_name 옆에 도메인 주소를 입력합니다.
끝에 ; 을 잊지마세요.
try_files $uri $uri/ =404; 아래
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
입력 합니다.
location ~ /\.ht {
deny all;
}
}
### HTTP (CNAME 연결 www.도메인.com to 도메인.com ) ###
server {
listen 80;
listen [::]:80;
server_name www.도메인.com;
location / {
return 301 http://도메인.com$request_uri; ### http://도메인.com 로 리다이렉팅
}
}
location ~ /\.ht {
deny all;
}
}
하단부에
### HTTP (CNAME 연결 www.도메인.com to 도메인.com ) ###
server {
listen 80;
listen [::]:80;
server_name www.도메인.com;
location / {
return 301 http://도메인.com$request_uri; ### http://도메인.com 로 리다이렉팅
}
}
입력을 합니다.
# Default server configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name 도메인.com;
location / {
try_files $uri $uri/ =404;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
### HTTP (CNAME 연결 www.도메인.com to 도메인.com ) ###
server {
listen 80;
listen [::]:80;
server_name www.도메인.com;
location / {
return 301 http://도메인.com$request_uri; ### http://도메인.com 로 리다이렉팅
}
}
주석(#)을 빼고 전체코드를 보면 이렇습니다.
sudo nginx -t
아래 메시지가 나오면 Nginx가 정상적으로 작동하는 것입니다.
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo service nginx restart
Nginx를 재시작 합니다.
+
본 게시글은 아래 출처내용을 조금 수정보완한 내용입니다.
'XE(라이믹스)' 카테고리의 다른 글
8. HTTPS 적용을 위해 Let's Encrypt에서 제공하는 무료 SSL 인증서를 적용하고 SSL 인증서 자동갱신하기 (0) | 2021.01.03 |
---|---|
7. Sendmail 설치하기 (0) | 2021.01.03 |
5. MariaDB 및 phpMyAdmin 설치하기 (0) | 2021.01.03 |
4. 오라클 클라우드에서 Nginx 서버 설치 및 PHP7.2 설치 (0) | 2021.01.03 |
3. 오라클 클라우드에서 Ubuntu(우분투) 서버환경 설정 (0) | 2021.01.03 |