"Nginx"의 두 판 사이의 차이
잔글 |
잔글 (→업로드 파일 크기 변경) |
||
375번째 줄: | 375번째 줄: | ||
|} | |} | ||
+ | |||
+ | === Server를 domain에 연결 === | ||
+ | server { | ||
+ | listen 80; | ||
+ | server_name docs.jopenbusiness.com docs.obcon.biz docs.obcon.co.kr; | ||
+ | root /work/appl/obcon_scada/manual; | ||
+ | charset UTF-8; | ||
+ | |||
+ | location / { | ||
+ | proxy_no_cache 1; | ||
+ | proxy_pass http://127.0.0.1:4000; | ||
+ | } | ||
+ | |||
+ | error_page 404 /404.html; | ||
+ | location = /40x.html { | ||
+ | } | ||
+ | |||
+ | error_page 500 502 503 504 /50x.html; | ||
+ | location = /50x.html { | ||
+ | } | ||
+ | } | ||
== 참고 문헌 == | == 참고 문헌 == |
2019년 7월 15일 (월) 16:13 판
비동기 이벤트 기반의 Web Server인 nginx를 정리 합니다.
- 홈페이지 : http://www.nginx.net/
- 다운로드 : http://wiki.nginx.org/Install
- 라이선스 :
- 플랫폼 : C
목차
nginx 개요
Nginx 설치
CentOS 6.5에 nginx 설치
Nginx 저장소 생성
vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 |
Nginx 설치
yum install nginx |
Nginx 설정 파일
- /etc/nginx/ : 설정 파일 폴더
- nginx.conf
- conf.d/
- /var/log/nginx/ : 로그 폴더
- access.log
- error.log
- /usr/share/nginx/html/ : Document Root 폴더
기본 설정
vi /etc/nginx/nginx.conf
worker_processes 1; #--- core 수만큼 지정 gzip on; |
vi /etc/nginx/conf.d/default.conf
server_name ossnode101.ossbiz.co.kr; |
방화벽 설정 및 서비스 기동
setup #--- 방화벽에서 80/tcp port를 오픈 합니다. service nginx restart |
브라우저에서 http://ossnode101.ossbiz.co.kr:80/ 으로 접속 합니다.
Windows에 nginx 설치
다운로드 사이트에서 nginx-1.7.10.zip 파일을 다운로드 합니다.
c:/appl/nginx/ 폴더에 압축을 해제 합니다.
nodepad /etc/nginx/nginx.conf
worker_processes 1; #--- core 수만큼 지정
gzip on;
# nginx -s [ stop | quit | reopen | reload ]
start nginx
http://localhost/ 로 접속하여 확인 합니다.
Nginx 환경 설정
Rewrite 사용법
rewrite 문법은 아래와 같이 단순 합니다.
문법 : rewrite 정규표현식 대체문자열 [flag]
flag
- last : Rewrite 실행을 종료하고 변경된 URI로 다시 처리를 시작 합니다.
- break : Rewrite 처리를 종료 합니다. rewrite가 무한 반복 실행되는 것을 방지 합니다.
- redirect : 302 temporary redirect 처리를 합니다.
- permanent : 301 permanent redirect 처리를 합니다.
요청된 parameter는 rewrite 처리후에 변경된 URI 뒤에 자동으로 붙습니다.
Mediawiki Rewrite Rule 적용
Mediawiki를 사용할 때 URL rewrite 기능을 사용하면 편리한 점이 많습니다. 우선 긴 URL을 의미 있는 간단한 URL로 변경할 수 있고 폴더의 위치와 URL을 동일하게 유지할 필요도 없습니다.
서버 환경과 요구 사항
서버 환경
- Nginx 사용 중
- DOCUMENT_ROOT : /cloudnas/www/jopenbusiness/public_html/
- Mediawiki가 설치된 폴더 : /cloudnas/www/jopenbusiness/public_html/mediawiki/
요구 사항
- URL Rewrite 전 : http://www.jopenbusiness.com/mediawiki/index.php?title=SuiteCRM
- URL Rewrite 후 : http://www.jopenbusiness.com/mediawiki/SuiteCRM
URL Rewrite 설정
vi /etc/nginx/sites-available/jopenbusiness.conf
location / { rewrite ^/mediawiki([^?]*)(?:\?(.*))? /mediawiki/index.php?title=$1&$2 last; index index.html index.htm index.php; } |
vi /cloudnas/www/jopenbusiness/public_html/mediawiki/LocalSettings.php
$wgScriptPath = "/mediawiki"; #--- Mediawiki가 설치된 폴더 $wgArticlePath = "/mediawiki/$1"; #--- URL 호출 방법 $wgUsePathInfo = true; |
참고 사이트
- https://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_nginx_rewrite--root_access
- https://www.mediawiki.org/wiki/Manual:Short_URL/Apache
PHP 사용 설정
PHP를 설치 합니다.
yum install php php-* mkdir /var/lib/php/upload |
vi /etc/php.ini
[PHP] |
PHP-FPM (FastCGI Process Manager) 서비스를 실행 합니다
service php-fpm restart |
Site를 설정 합니다.
mkdir -p /nas/www/ossnode101/public_html mkdir /etc/nginx/sites-available cp /usr/share/nginx/html/* /nas/www/ossnode101/public_html |
vi /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf; |
vi /etc/nginx/conf.d/default.conf
server_name nouse.ossbiz.co.kr; |
vi /etc/nginx/sites-available/ossnode101.conf
server { location / { location ~ \.php$ { |
sites-enabled에 ossnode101.conf를 추가 합니다.
ln -s /etc/nginx/sites-available/ossnode101.conf /etc/nginx/sites-enabled/ossnode101.conf |
vi /nas/www/ossnode101/public_html/phpinfo.php
<?php ?> |
nginx를 재기동 합니다.
service php-fpm restart service nginx restart |
브라우저에서 http://ossnode101.ossbiz.co.kr:80/phpinfo.php 으로 접속 합니다.
Tomcat 6 설정
yum install tomcat6 tomcat6-* cp /usr/share/tomcat6/webapps/ROOT/*.gif /nas/www/ossnode101/public_html |
vi /etc/nginx/sites-available/ossnode101.conf #--- 아래 항목을 추가 합니다.
location ~ \.do$ { |
방화벽 설정 및 서비스 기동
setup #--- 방화벽에서 8080/tcp port를 오픈 합니다. service tomcat6 restart |
http://ossnode101.ossbiz.co.kr/index.jsp 사이트로 접속하여 Tomcat 화면을 표시해 봅니다.
Nginx에 UTF-8 설정
관리자 가이드
업로드 파일 크기 변경
vi /etc/php.ini
post_max_size = 10M |
vi /etc/nginx/sites-available/jopenbusiness.conf
client_max_body_size 10M; #--- server, location, http 내에 설정할 수 있습니다. |
Server를 domain에 연결
server { listen 80; server_name docs.jopenbusiness.com docs.obcon.biz docs.obcon.co.kr; root /work/appl/obcon_scada/manual; charset UTF-8;
location / { proxy_no_cache 1; proxy_pass http://127.0.0.1:4000; }
error_page 404 /404.html; location = /40x.html { }
error_page 500 502 503 504 /50x.html; location = /50x.html { } }