2차 도메인 설정 방법

올리고당

안녕하세요?

현재 esxi에 centos+nginx+php+mariadb+wordpress 셋팅중입니다.

 

내부 아이피로는 설정이 되었습니다만 도메인으로 설정하고 있습니다.

 

기본 도메인으로는 아무것도 연결이 안되어 php 정보만 나오는 화면으로 셋팅했습니다.

 

워드프레스를 2차 도메인을 설정하여 연결하고자 합니다.

 

우분투에서는 nginx에 default.conf에 vittual host가 있어 안에다가 추가적으로 작성하면 되는데.

 

centos용 nginx의 default.conf에는 기본적으로 virtual host가 없더군요.

 

인터넷을 찾아보면 site-available을 만들어서 하라고 하는데 예전에 site-avialable을 만들어 그 안에 

 

새로운 이름의 conf를 만들어 연결하면 된다고 해서 해봤다가 에러가 떠서 구글링을 하는 도중에

 

centos7 nginx의 최신버전에서는 site-available을 따로 만들필요없지 /etc/nginx/conf.d/안에

 

conf 파일을 만들어서 넣으면 된다고 한 기억이(가물가물)나서 새롭게 만들어서 넣어 봤는데

 

이상하게 워드프레스 안에  indexl.php를 다운로드 시켜버립니다.

 

여기서 궁금한점.

기본 default.conf를 복사하여 새로운 이름의 .conf를 파생 후 안에 내용만 2차 도메인으로 셋팅을 했습니다. 

    

erver {
    listen       80;
    server_name  blog.woongs357.com;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html/wordpress/;
        index   index.php index.html index.htm;
    }

    #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;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
       # root           /usr/share/nginx/html/wordpress;
       # fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
       # fastcgi_index  index.php;
       # fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/wordpress$fastcgi_script_name;
       # include        fastcgi_params;
    #}

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

 

1) 여기서 밑에 있는 fastcgi부분은 기본 default.conf에도 있는데 계속 파생되는 파일에 같이 넣어줘야 하는 건가요?

2) 기본적 웹서버 포트는 8080으로 셋팅을 했습니다만, 2차 도메인을 웹브라우져에서 기입할때도 blog.woongs357.com:8080처럼 넣어줘야 하는건가요? (리버스 프록시 적용전에..)

3) 제 기억에 새로운 conf를 만들어 어딘가 파일에 경로를 등록시킨것으로 기억을 하는데... 그냥 저렇게 만들어 놓으면 되는건지요?

    (nginx.conf 파일에 경로중

include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.

이 부분이 들어가 있긴 합니다만...

 

결론은 2차 도메인을 어떻게 설정하는지가 궁금합니다. ㅠㅠ

  

 

댓글
1
  • 달소
    2021.07.13

    Ubuntu + nginx 기준으로

    /etc/nginx/sites-availables/blog.woongs357.com

    이렇게 파일을 만들어주시고

    ln -s /etc/nginx/sites-availables/blog.woongs357.com /etc/nginx/sites-enable/

    이렇게 enable쪽에 심볼릭링크로 적용하시면 blog.woongs357.com으로 요청이 왔을때 해당 값으로 응답하게 됩니다.

    오타가 있을지도모르니 확인은 한번필요해보이네요 ㅎㅎ

댓글 쓰기
권한이 없습니다.