react linux 를 사용해서 nginx 배포하기 (젠킨스 연동 )
mobaxterm 사용
sudo apt install nginx
sudo rm /homw/nginx/sites-available/default
sudo rm /homw/nginx/sites-enabled/default
sudo vi /homw/nginx/sites-available/myapp.conf
server {
listen 3000;
location / {
root /home/build;
index index.html;
try_files $uri /index.html;
}
}
파일이 작성 완료되면 site-enabled 폴더에 심볼릭 링크를 만든다
sudo ln -s /homw/nginx/sites-available/myapp.conf /homw/nginx/sites-enabled/myapp.conf
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl status nginx
결과 확인중 start가 안되었다
에러 내용
root@zabbix:/home/appliance# systemctl status nginx.service nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2018-07-25 18:33:26 UTC; 1min 27s ago Process: 30040 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) Process: 30037 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) Jul 25 18:33:25 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: Address already in use) Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use) Jul 25 18:33:26 zabbix nginx[30040]: nginx: [emerg] still could not bind() Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Control process exited, code=exited status=1 Jul 25 18:33:26 zabbix systemd[1]: *******Failed to start A high performance web server*** and a reverse proxy server.**** Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Unit entered failed state. Jul 25 18:33:26 zabbix systemd[1]: nginx.service: Failed with result 'exit-code'.
해결 : 80포트를 죽임으로써 해결됐다
sudo fuser -k 80/tcp sudo systemctl restart nginx
nginx 실행이 완료되면 해당 브라우저로 ip:port를 입력하여 확인
10.10.293.323:3000
에러발생
nginx 500 server internal error
에러 로그 명령어 실행
/var/log/nginx/error.log
"/home/build/index.html" failed (13: Permission denied)
라는 로그가 떠 있었고 해당 경로에 권한이 없어 접근하지 못하는 이슈였다.
해결방법:
- nginx에서 root로 설정한 디렉토리 경로의 권한을 확인
- 해당 권한을 /etc/nginx/nginx.conf에서 일치시킴
vi /etc/nginx/nginx.conf 명령어를 통해 vi 편집기로 user를 변경해주는 것으로 해결# user www-data; user root;
https://super-devstory.tistory.com/140
https://stackoverflow.com/questions/51525710/nginx-failed-to-start-a-high-performance-web-server-and-a-reverse-proxy-server
https://rnokhs.tistory.com/entry/Nginx-403-13-Permission-denied-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0