728x90
반응형

 

# OS환경은 CentOS 7.0으로 진행되었습니다.

 

이전글에서 nginx를 설치 하였습니다.

 

 

 

nginx의 기본 설정을 확인해 보겠습니다.

 

http 속성은 /etc/nginx/nginx.conf 에 있습니다.

[root@NGINX /]# vi /etc/nginx/nginx.conf  
user  nginx;                                                                                                                                     
worker_processes  1;                                                                                                                             
                                                                                                                                                 
error_log  /var/log/nginx/error.log warn;                                                                                                        
pid        /var/run/nginx.pid;                                                                                                                   
                                                                                                                                                 
                                                                                                                                                 
events {                                                                                                                                         
    worker_connections  1024;                                                                                                                    
}                                                                                                                                                
                                                                                                                                                 
                                                                                                                                                 
http {                                                                                                                                           
    include       /etc/nginx/mime.types;                                                                                                         
    default_type  application/octet-stream;                                                                                                      
                                                                                                                                                 
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                                                                    
                      '$status $body_bytes_sent "$http_referer" '                                                                                
                      '"$http_user_agent" "$http_x_forwarded_for"';                                                                              
                                                                                                                                                 
    access_log  /var/log/nginx/access.log  main;                                                                                                 
                                                                                                                                                 
    sendfile        on;                                                                                                                          
    #tcp_nopush     on;                                                                                                                          
                                                                                                                                                 
    keepalive_timeout  65;                                                                                                                       
                                                                                                                                                 
    #gzip  on;                                                                                                                                   
                                                                                                                                                 
    include /etc/nginx/conf.d/*.conf;                                                                                                            
} 

 

 

 

 

server 속성은 /etc/nginx/conf.d/default.conf 에 있습니다.

 

아래의 경로에 있는 default.conf 파일을 열어봅니다.

[root@NGINX /]# vi /etc/nginx/conf.d/default.conf  

 

 

 

 

현재 보여지는 설정은 기본 설치 후 설정입니다.

 

각종 설정들이 주석처리 되어있지만 필요에 의해 주석을 해제하고 사용하면 됩니다.

server {                                                                                                                                         
    listen       80;                                                                                                                             
    server_name  localhost;                                                                                                                      
                                                                                                                                                 
    #charset koi8-r;                                                                                                                             
    #access_log  /var/log/nginx/host.access.log  main;                                                                                           
                                                                                                                                                 
    location / {                                                                                                                                 
        root   /usr/share/nginx/html;                                                                                                            
        index  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           html;                                                                                                                    
    #    fastcgi_pass   127.0.0.1:9000;                                                                                                          
    #    fastcgi_index  index.php;                                                                                                               
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$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;                                                                                                                              
    #}                                                                                                                                           
} 

 

 

 

80포트로 방화벽이 걸려있으면 아래와 같이 80포트 방화벽을 열어줍니다.

firewall-cmd --permanent --zone=public --add-port=80/tcp 
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https

 

 

 

nginx 자동시작 설정을 합니다.

systemctl enable nginx
[root@NGINX /]# systemctl enable nginx                                                                                                           
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service, pointing to /usr/lib/systemd/system/nginx.service.

 

 

 

 

nginx를 시작합니다.

systemctl start nginx

 

 

 

 

 

방화벽을 reload합니다.

firewall-cmd --reload

 

 

 

그외 명령어와 설정파일들 위치 입니다.

 

- nginx 관련 명령어

서버 시작 : sudo systemctl start nginx

서버 자동 시작 등록 : sudo systemctl enable nginx

서버 상태 확인 : sudo systemctl status nginx

서버 정지 : sudo systemctl stop nginx

서버 재시작 : sudo systemctl restart nginx

설정 리로드 : sudo systemctl reload nginx

 

- nginx 설정파일

/etc/nginx/ : nginx 설정파일 디렉토리

/etc/nginx/nginx.conf : 메인 설정파일(접속자 수, 동작 프로세스 수 등 퍼포먼스에 대한 설정)

/etc/nginx/conf.d/ : nginx.conf에서 불러들일 수 있는 파일 저장

/etc/nginx/fastcgi.conf : FastCGI 환경설정 파일

/etc/nginx/sites-available/ : 비활성화된 사이트 파일

/etc/nginx/sites-enabled/ : 활성화된 사이트 파일

728x90
반응형
728x90
반응형

# OS환경은 CentOS 7.0으로 진행되었습니다.

 

CentOS7에 웹서버 Nginx를 설치해보도록 하겠습니다.

 

 

 

아래의 명령어로 firewall을 설치를 시작합니다.

 

정상적으로 설치가 완료되면 Complete! 문자가 출력됩니다.

yum install firewalld
[root@NGINX /]# yum install firewalld                                                                                                            
Loaded plugins: fastestmirror, ovl                                                                                                               
Loading mirror speeds from cached hostfile                                                                                                       
 * base: mirror.kakao.com                                                                                                                        
 * extras: mirror.kakao.com                                                                                                                      
 * updates: mirror.kakao.com                                                                                                                     
Resolving Dependencies                                                                                                                           
--> Running transaction check                                                                                                                    
---> Package firewalld.noarch 0:0.6.3-8.el7_8.1 will be installed                                                                                
--> Processing Dependency: python-firewall = 0.6.3-8.el7_8.1 for package: firewalld-0.6.3-8.el7_8.1.noarch                                       
--> Processing Dependency: firewalld-filesystem = 0.6.3-8.el7_8.1 for package: firewalld-0.6.3-8.el7_8.1.noarch                                  
--> Processing Dependency: iptables for package: firewalld-0.6.3-8.el7_8.1.noarch                                                                
--> Processing Dependency: ipset for package: firewalld-0.6.3-8.el7_8.1.noarch                                                                   
--> Processing Dependency: ebtables for package: firewalld-0.6.3-8.el7_8.1.noarch                                                                
--> Running transaction check                                                                                                                    
---> Package ebtables.x86_64 0:2.0.10-16.el7 will be installed                                                                                   
---> Package firewalld-filesystem.noarch 0:0.6.3-8.el7_8.1 will be installed                                                                     
---> Package ipset.x86_64 0:7.1-1.el7 will be installed                                                                                          
--> Processing Dependency: ipset-libs(x86-64) = 7.1-1.el7 for package: ipset-7.1-1.el7.x86_64                                                    
--> Processing Dependency: libipset.so.13(LIBIPSET_4.8)(64bit) for package: ipset-7.1-1.el7.x86_64                                               
--> Processing Dependency: libipset.so.13(LIBIPSET_2.0)(64bit) for package: ipset-7.1-1.el7.x86_64                                               
--> Processing Dependency: libipset.so.13()(64bit) for package: ipset-7.1-1.el7.x86_64                                                           
---> Package iptables.x86_64 0:1.4.21-34.el7 will be installed                                                                                   
--> Processing Dependency: libnfnetlink.so.0()(64bit) for package: iptables-1.4.21-34.el7.x86_64                                                 
--> Processing Dependency: libnetfilter_conntrack.so.3()(64bit) for package: iptables-1.4.21-34.el7.x86_64                                       
---> Package python-firewall.noarch 0:0.6.3-8.el7_8.1 will be installed                                                                          
--> Processing Dependency: python-slip-dbus for package: python-firewall-0.6.3-8.el7_8.1.noarch                                                  
--> Processing Dependency: python-decorator for package: python-firewall-0.6.3-8.el7_8.1.noarch                                                  
--> Running transaction check                                                                                                                    
---> Package ipset-libs.x86_64 0:7.1-1.el7 will be installed                                                                                     
--> Processing Dependency: libmnl.so.0(LIBMNL_1.0)(64bit) for package: ipset-libs-7.1-1.el7.x86_64                                               
--> Processing Dependency: libmnl.so.0()(64bit) for package: ipset-libs-7.1-1.el7.x86_64                                                         
---> Package libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3 will be installed                                                                     
---> Package libnfnetlink.x86_64 0:1.0.1-4.el7 will be installed                                                                                 
---> Package python-decorator.noarch 0:3.4.0-3.el7 will be installed                                                                             
---> Package python-slip-dbus.noarch 0:0.4.0-4.el7 will be installed                                                                             
--> Processing Dependency: python-slip = 0.4.0-4.el7 for package: python-slip-dbus-0.4.0-4.el7.noarch                                            
--> Running transaction check                                                                                                                    
---> Package libmnl.x86_64 0:1.0.3-7.el7 will be installed                                                                                       
---> Package python-slip.noarch 0:0.4.0-4.el7 will be installed                                                                                  
--> Processing Dependency: libselinux-python for package: python-slip-0.4.0-4.el7.noarch                                                         
--> Running transaction check                                                                                                                    
---> Package libselinux-python.x86_64 0:2.5-15.el7 will be installed                                                                             
--> Finished Dependency Resolution 

Dependencies Resolved                                                                                                                            
                                                                                                                                                 
=================================================================================================================================================
 Package                                     Arch                        Version                              Repository                    Size 
=================================================================================================================================================
Installing:                                                                                                                                      
 firewalld                                   noarch                      0.6.3-8.el7_8.1                      updates                      443 k 
Installing for dependencies:                                                                                                                     
 ebtables                                    x86_64                      2.0.10-16.el7                        base                         123 k 
 firewalld-filesystem                        noarch                      0.6.3-8.el7_8.1                      updates                       51 k 
 ipset                                       x86_64                      7.1-1.el7                            base                          39 k 
 ipset-libs                                  x86_64                      7.1-1.el7                            base                          64 k 
 iptables                                    x86_64                      1.4.21-34.el7                        base                         432 k 
 libmnl                                      x86_64                      1.0.3-7.el7                          base                          23 k 
 libnetfilter_conntrack                      x86_64                      1.0.6-1.el7_3                        base                          55 k 
 libnfnetlink                                x86_64                      1.0.1-4.el7                          base                          26 k 
 libselinux-python                           x86_64                      2.5-15.el7                           base                         236 k 
 python-decorator                            noarch                      3.4.0-3.el7                          base                          27 k 
 python-firewall                             noarch                      0.6.3-8.el7_8.1                      updates                      354 k 
 python-slip                                 noarch                      0.4.0-4.el7                          base                          31 k 
 python-slip-dbus                            noarch                      0.4.0-4.el7                          base                          32 k 
                                                                                                                                                 
Transaction Summary                                                                                                                              
=================================================================================================================================================
Install  1 Package (+13 Dependent packages)                                                                                                      
                                                                                                                                                 
Total download size: 1.9 M                                                                                                                       
Installed size: 6.8 M                                                                                                                            
Is this ok [y/d/N]: y                                                                                                                            
Downloading packages:                                                                                                                            
(1/14): ebtables-2.0.10-16.el7.x86_64.rpm                                                                                 | 123 kB  00:00:00     
(2/14): firewalld-filesystem-0.6.3-8.el7_8.1.noarch.rpm                                                                   |  51 kB  00:00:00     
(3/14): ipset-libs-7.1-1.el7.x86_64.rpm                                                                                   |  64 kB  00:00:00     
(4/14): ipset-7.1-1.el7.x86_64.rpm                                                                                        |  39 kB  00:00:00     
(5/14): firewalld-0.6.3-8.el7_8.1.noarch.rpm                                                                              | 443 kB  00:00:00     
(6/14): iptables-1.4.21-34.el7.x86_64.rpm                                                                                 | 432 kB  00:00:00     
(7/14): libmnl-1.0.3-7.el7.x86_64.rpm                                                                                     |  23 kB  00:00:00     
(8/14): libnetfilter_conntrack-1.0.6-1.el7_3.x86_64.rpm                                                                   |  55 kB  00:00:00     
(9/14): libnfnetlink-1.0.1-4.el7.x86_64.rpm                                                                               |  26 kB  00:00:00     
(10/14): python-decorator-3.4.0-3.el7.noarch.rpm                                                                          |  27 kB  00:00:00     
(11/14): libselinux-python-2.5-15.el7.x86_64.rpm                                                                          | 236 kB  00:00:00     
(12/14): python-slip-0.4.0-4.el7.noarch.rpm                                                                               |  31 kB  00:00:00     
(13/14): python-slip-dbus-0.4.0-4.el7.noarch.rpm                                                                          |  32 kB  00:00:00     
(14/14): python-firewall-0.6.3-8.el7_8.1.noarch.rpm                                                                       | 354 kB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                            2.8 MB/s | 1.9 MB  00:00:00     
Running transaction check                                                                                                                        
Running transaction test                                                                                                                         
Transaction test succeeded                                                                                                                       
Running transaction                                                                                                                              
  Installing : python-decorator-3.4.0-3.el7.noarch                                                                                          1/14 
  Installing : libmnl-1.0.3-7.el7.x86_64                                                                                                    2/14 
  Installing : libnfnetlink-1.0.1-4.el7.x86_64                                                                                              3/14 
  Installing : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                                                                                  4/14 
  Installing : iptables-1.4.21-34.el7.x86_64                                                                                                5/14 
  Installing : ipset-libs-7.1-1.el7.x86_64                                                                                                  6/14 
  Installing : ipset-7.1-1.el7.x86_64                                                                                                       7/14 
  Installing : ebtables-2.0.10-16.el7.x86_64                                                                                                8/14 
  Installing : firewalld-filesystem-0.6.3-8.el7_8.1.noarch                                                                                  9/14 
  Installing : libselinux-python-2.5-15.el7.x86_64                                                                                         10/14 
  Installing : python-slip-0.4.0-4.el7.noarch                                                                                              11/14 
  Installing : python-slip-dbus-0.4.0-4.el7.noarch                                                                                         12/14 
  Installing : python-firewall-0.6.3-8.el7_8.1.noarch                                                                                      13/14 
  Installing : firewalld-0.6.3-8.el7_8.1.noarch                                                                                            14/14 
  Verifying  : ipset-7.1-1.el7.x86_64                                                                                                       1/14 
  Verifying  : libnfnetlink-1.0.1-4.el7.x86_64                                                                                              2/14 
  Verifying  : python-firewall-0.6.3-8.el7_8.1.noarch                                                                                       3/14 
  Verifying  : libmnl-1.0.3-7.el7.x86_64                                                                                                    4/14 
  Verifying  : iptables-1.4.21-34.el7.x86_64                                                                                                5/14 
  Verifying  : firewalld-0.6.3-8.el7_8.1.noarch                                                                                             6/14 
  Verifying  : libselinux-python-2.5-15.el7.x86_64                                                                                          7/14 
  Verifying  : firewalld-filesystem-0.6.3-8.el7_8.1.noarch                                                                                  8/14 
  Verifying  : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                                                                                  9/14 
  Verifying  : python-slip-0.4.0-4.el7.noarch                                                                                              10/14 
  Verifying  : python-slip-dbus-0.4.0-4.el7.noarch                                                                                         11/14 
  Verifying  : python-decorator-3.4.0-3.el7.noarch                                                                                         12/14 
  Verifying  : ipset-libs-7.1-1.el7.x86_64                                                                                                 13/14 
  Verifying  : ebtables-2.0.10-16.el7.x86_64                                                                                               14/14 
                                                                                                                                                 
Installed:                                                                                                                                       
  firewalld.noarch 0:0.6.3-8.el7_8.1                                                                                                             
                                                                                                                                                 
Dependency Installed:                                                                                                                            
  ebtables.x86_64 0:2.0.10-16.el7                   firewalld-filesystem.noarch 0:0.6.3-8.el7_8.1     ipset.x86_64 0:7.1-1.el7                   
  ipset-libs.x86_64 0:7.1-1.el7                     iptables.x86_64 0:1.4.21-34.el7                   libmnl.x86_64 0:1.0.3-7.el7                
  libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3     libnfnetlink.x86_64 0:1.0.1-4.el7                 libselinux-python.x86_64 0:2.5-15.el7      
  python-decorator.noarch 0:3.4.0-3.el7             python-firewall.noarch 0:0.6.3-8.el7_8.1          python-slip.noarch 0:0.4.0-4.el7           
  python-slip-dbus.noarch 0:0.4.0-4.el7                                                                                                          
                                                                                                                                                 
Complete!

 

 

 

 

firewall 자동시작 설정을 합니다.

systemctl enable firewalld

 

 

 

 

firewall을 시작합니다.

systemctl start firewalld

 

728x90
반응형

+ Recent posts