nginx

nginx

설치


nginx (mac)

./configure --prefix=/Users/js/cleancode/project_management_nginx/nginx \
           --conf-path=conf/nginx.conf \
           --error-log-path=logs/error.log \
           --http-log-path=logs/access.log \
           --pid-path=logs/nginx.pid
make
make install
brew install nginx
brew services start nginx 또는 nginx
(brew services stop nginx 또는 nginx -s stop)
(brew services restart nginx 또는 nginx -s reload)
설치 정보 : brew info nginx (conf 파일 path 표기 예시 : /opt/homebrew/etc/nginx/nginx.conf)
worker_processes  1; # cpu 코어 수

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream; # 일반 바이너리 타입을 기본타입으로 설정
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen 80;
        server_name localhost; # 도메인 지정

        root /Users/js/cleancode/project_ai_controller;
        index index.html;

        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}

nginx (linux)

sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx       # 실행
sudo systemctl enable nginx      # 부팅 시 자동 실행
sudo systemctl status nginx      # 상태 확인
curl -I http://localhost
vim /etc/nginx/sites-available/default
sudo nginx -t           # 설정 문법 체크
sudo systemctl reload nginx
apt show nginx
which nginx
ps aux | grep nginx
sudo mkdir -p /etc/nginx/servers
/etc/nginx/ # 설치위치
http {
    include       mime.types;
    default_type  application/octet-stream;

    # ✅ include servers/*.conf
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    # 기타 설정...
}
sudo nano /etc/nginx/sites-available/vue-app.conf
sudo ln -s /etc/nginx/sites-available/vue-app.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx (sudo nginx -s reload)
curl -I http://localhost

nginx 재실행

# 포트 확인
sudo lsof -nP -iTCP -sTCP:LISTEN | grep nginx

# 제거
sudo pkill nginx
ps aux | grep nginx

# 수동 실행
nginx -t -c /opt/homebrew/etc/nginx/nginx.conf
sudo nginx -c /opt/homebrew/etc/nginx/nginx.conf