Remark : apache 대신 Nginx 를 설치해 본다.
러시아의 프로그램 개발자인 이고르 시쇼브(Igor Sysoev)가 개발하여 2004년 발표한 모듈화 및 효율적으로 적은 메모리 사용으로 아파치(Apache) 보다 속도가 빠르다.
1. sudo yum update 업데이트
1 2 3 |
sudo yum update |
2. sudo yum install nginx 설치
1 2 3 |
sudo yum install -y nginx |
3. nginx 데몬 시작
1 2 3 4 |
sudo systemctl start nginx sudo systemctl enable nginx |
4. nginx 상태 확인
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-10-19 09:49:53 KST; 15min ago Main PID: 17249 (nginx) CGroup: /system.slice/nginx.service ├─17249 nginx: master process /usr/sbin/nginx ├─17250 nginx: worker process ├─17251 nginx: worker process ├─17252 nginx: worker process ├─17253 nginx: worker process ├─17254 nginx: worker process ├─17255 nginx: worker process ├─17256 nginx: worker process └─17257 nginx: worker process Oct 19 09:49:53 h24.com systemd[1]: Starting The nginx HTTP and r.... Oct 19 09:49:53 h24.com nginx[17243]: nginx: the configuration fi...k Oct 19 09:49:53 h24.com nginx[17243]: nginx: configuration file /...l Oct 19 09:49:53 h24.com systemd[1]: Started The nginx HTTP and re.... Hint: Some lines were ellipsized, use -l to show in full. |
5. nginx default site config
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# cd /etc/nginx/ # vi nginx.conf # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. 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. include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } # Settings for a TLS enabled server. # # server { # listen 443 ssl http2; # listen [::]:443 ssl http2; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } } |
6. 사이트 확인

7. 경로 수정
1 2 3 |
# yum install php-fpm -y |
8. PHP-FPM 설치
1 2 3 4 5 6 7 8 9 |
vi /etc/nginx/conf.d/default.conf yum-config-manager --enable remi-php73 yum install php php-mysqlnd php-fpm php --version |
9. PHP-FPM 세팅
1 2 3 4 5 6 7 8 9 10 11 12 |
# vi /etc/php-fpm.d/www.conf user = nginx group = nginx listen = /var/run/php-fpm/php-fpm.sock; listen.owner = nginx listen.group = nginx listen.mode = 0660 |
1 2 3 |
sudo systemctl start php-fpm |
9. new site 세팅
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# vi /etc/nginx/conf.d/default.conf server { listen 80; server_name server_domain_or_IP; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } |
1 2 3 |
sudo systemctl restart nginx |
10. test
1 2 3 4 5 6 7 |
# vi /var/www/html/ info.php <?php phpinfo(); |
