엔진엑스는 우분투 서버에 설치하는 웹 서비스 환경입니다. 여기에 PHP 와 SQL (MySQL 혹은 MariaDB) 를 설치한 다음 연동을 하면 우리가 기본적으로 사용할 수 있는 워드프레스 구축환경이 완성됩니다. 대체제로는 Apache 가 있습니다.
아래 자료는 핵심 파일 리스트입니다. 자세한 메뉴얼은 [공식 메뉴얼] 을 통해 볼 수 있습니다
엔진엑스의 가장 기초 설정파일은 nginx.conf 입니다. 여기서 모든 것이 시작되며,
어떻게 구성되어있는지 이해할 수록 더욱 수준 높은 서버 구성이 가능해집니다.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
types_hash_max_size 2048;
server_tokens off;
#413 에러 해결방법 -413 Request Entity Too Large
client_max_body_size 5000m;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_vary on;
# gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /home;
index index.html index.htm index.php;
server_name _;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
include snippets/xe-rewrite.conf;
}
기본 nginx 파일입니다. CMS XE 와 워드프레스 에 최적화되어 있으며 PHP 8.0 기반입니다.
# 설정 정보
# 글쓴이 : 정라잇
# 수정일자 : 22-05-06
# 수정방법 : https://www.light-coding.com
server {
listen 80;
return 301 https://$host$request_uri;
# 301 리디렉션 해결
if ($host = www.www.light-coding.com) {
return 301 https://www.light-coding.com$request_uri;
}
}
server {
listen 443 ssl http2;
ssl_certificate_key /etc/nginx/ssl_rdg/www.light-coding.com_2022042083189.key.pem;
ssl_certificate /etc/nginx/ssl_rdg/www.light-coding.com_2022042083189.ca-bundle.pem;
ssl_protocols TLSv1.2;
charset utf-8;
root /home;
index index.php index.html;
server_name _;
location / {
# 504 Gateway Time Out 에러 해결법
proxy_connect_timeout 500;
proxy_send_timeout 500;
proxy_read_timeout 500;
send_timeout 500;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# 504 Gateway Time Out 에러 해결법2
fastcgi_read_timeout 500;
fastcgi_buffers 64 16k;
fastcgi_buffer_size 256k;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
# robots.txt 접근
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
}
커스터마이징 된 자료입니다. SSL키를 주소에 맞추어 적용하면 됩니다.
확장자는 따로 없으며, 원한다면 이름을 다르게 지어 하나의 서버에 두개의 도메인을 활용하는 등 여러 방법을 활용할 수 있게 만드는 파일입니다. 이것을 버츄얼 호스팅 이라고 합니다.
nginx.conf 의 include /etc/nginx/sites-enabled/*; 를 통해서 연결되었습니다
이 자료를 보고 참고용도로 사용해야 하며, 바로 적용하는데는 문제가 있습니다