"Nginx"의 두 판 사이의 차이

오픈소스 비즈니스 컨설팅
둘러보기로 가기 검색하러 가기
잔글
잔글
213번째 줄: 213번째 줄:
 
<span style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 19.0499992370605px;">브라우저에서&nbsp;</span>[http://ossnode101.ossbiz.co.kr:80/phpinfo.php http://ossnode101.ossbiz.co.kr:80/phpinfo.php]<span style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 19.0499992370605px;">&nbsp;으로 접속 합니다.</span>
 
<span style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 19.0499992370605px;">브라우저에서&nbsp;</span>[http://ossnode101.ossbiz.co.kr:80/phpinfo.php http://ossnode101.ossbiz.co.kr:80/phpinfo.php]<span style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 19.0499992370605px;">&nbsp;으로 접속 합니다.</span>
  
== Tomcat 6 설정 ==
+
Tomcat 6 설정 ==
  
 
[[Apache Tomcat|Apache Tomcat]] 설치
 
[[Apache Tomcat|Apache Tomcat]] 설치
220번째 줄: 220번째 줄:
 
|-
 
|-
 
| style="background-color: rgb(241, 241, 241);" |  
 
| style="background-color: rgb(241, 241, 241);" |  
&nbsp; &nbsp; yum install tomcat6 tomcat6-*
+
&nbsp;yum install tomcat6 tomcat6-*
 +
 
 +
cp /usr/share/tomcat6/webapps/ROOT/*.gif /nas/www/ossnode101/public_html<br/>cp /usr/share/tomcat6/webapps/ROOT/*.svg /nas/www/ossnode101/public_html<br/>cp /usr/share/tomcat6/webapps/ROOT/*.ico /nas/www/ossnode101/public_html
  
 
|}
 
|}
226번째 줄: 228번째 줄:
  
  
vi /etc/nginx/sites-available/ossnode101.conf
+
vi /etc/nginx/sites-available/ossnode101.conf &nbsp; #--- 아래 항목을 추가 합니다.
  
 
{| cellspacing="1" cellpadding="1" style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 20.7999992370605px; width: 771px;"
 
{| cellspacing="1" cellpadding="1" style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 20.7999992370605px; width: 771px;"
 
|-
 
|-
 
| style="background-color: rgb(241, 241, 241);" |  
 
| style="background-color: rgb(241, 241, 241);" |  
server {<br/>&nbsp; &nbsp; server_name ossnode101.ossbiz.co.kr;<br/>&nbsp; &nbsp; access_log /nas/www/ossnode101/logs/access.log;<br/>&nbsp; &nbsp; error_log /nas/www/ossnode101/logs/error.log;<br/>&nbsp; &nbsp; root /nas/www/ossnode101/public_html;
+
&nbsp; &nbsp; location ~ \.do$ {<br/>&nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://localhost:8080;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Real-IP $remote_addr;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;Host $http_host;<br/>&nbsp; &nbsp; }<br/>&nbsp; &nbsp; location ~ \.jsp$ {<br/>&nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://localhost:8080;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Real-IP $remote_addr;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;Host $http_host;<br/>&nbsp; &nbsp; }<br/>&nbsp; &nbsp; location ^~/servlets/* {<br/>&nbsp; &nbsp; &nbsp; proxy_pass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;http://localhost:8080;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Real-IP $remote_addr;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;X-Forwarded-For $proxy_add_x_forwarded_for;<br/>&nbsp; &nbsp; &nbsp; proxy_set_header &nbsp; &nbsp; &nbsp; &nbsp;Host $http_host;<br/>&nbsp; &nbsp; }
 +
 
 +
|}
 +
 
  
&nbsp; &nbsp; location / {<br/>&nbsp; &nbsp; &nbsp; &nbsp; index index.html index.htm index.php;<br/>&nbsp; &nbsp; }
 
  
&nbsp; &nbsp; location ~ \.php$ {<br/>&nbsp; &nbsp; &nbsp; &nbsp; try_files $uri =404;<br/>&nbsp; &nbsp; &nbsp; &nbsp; include /etc/nginx/fastcgi_params;<br/>&nbsp; &nbsp; &nbsp; &nbsp; fastcgi_pass &nbsp;127.0.0.1:9000;<br/>&nbsp; &nbsp; &nbsp; &nbsp; fastcgi_index index.php;<br/>&nbsp; &nbsp; &nbsp; &nbsp; fastcgi_param SCRIPT_FILENAME /nas/www/ossnode/public_html$fastcgi_script_name;<br/>&nbsp; &nbsp; }<br/>}
+
<span style="color: rgb(0, 0, 255);"><span style="font-size: larger;">'''방화벽 설정 및 서비스 기동'''</span></span>
 +
 
 +
{| cellspacing="1" cellpadding="1" style="color: rgb(0, 0, 0); font-family: sans-serif; line-height: 20.7999992370605px; width: 771px;"
 +
|-
 +
| style="background-color: rgb(241, 241, 241);" |
 +
setup &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #--- 방화벽에서 8080/tcp port를 오픈 합니다.
 +
 
 +
service tomcat6 restart
 
<div><br/></div>
 
<div><br/></div>
 
|}
 
|}
  
ppp
+
 
 +
 
 +
http://ossnode101.ossbiz.co.kr/index.jsp 사이트로 접속하여 Tomcat 화면을 표시해 봅니다.
  
 
== 참고 문헌 ==
 
== 참고 문헌 ==

2014년 9월 18일 (목) 16:33 판

비동기 이벤트 기반의 Web Server인 nginx를 정리 합니다.

nginx 개요

CentOS 6.5에서 설치

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/ 으로 접속 합니다.

File:Nginx init.png

PHP 사용 설정

PHP를 설치 합니다.

yum install php php-*

mkdir /var/lib/php/upload


vi /etc/php.ini

date.timezone = Asia/Seoul
upload_tmp_dir    = "/var/lib/php/upload"
session.save_path = "/var/lib/php/session"


PHP-FPM 서비스를 실행 합니다

service php-fpm restart


Site를 설정 합니다.

mkdir -p /nas/www/ossnode101/public_html
mkdir -p /nas/www/ossnode101/logs
chown -R apache:apache /srv/www/ossnode101

mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled


vi /etc/nginx/nginx.conf

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*.conf;               #--- 이 라인을 추가 합니다.


vi /etc/nginx/conf.d/default.conf

   server_name  nouse.ossbiz.co.kr;


vi /etc/nginx/sites-available/ossnode101.conf

server {
    server_name ossnode101.ossbiz.co.kr;
    access_log /nas/www/ossnode101/logs/access.log;
    error_log /nas/www/ossnode101/logs/error.log;
    root /nas/www/ossnode101/public_html;

    location / {
        index index.html index.htm index.php;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /nas/www/ossnode/public_html$fastcgi_script_name;
    }
}


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
  phpinfo

?>


nginx를 재기동 합니다.

service php-fpm restart

 service nginx restart

브라우저에서 http://ossnode101.ossbiz.co.kr:80/phpinfo.php 으로 접속 합니다.

Tomcat 6 설정 ==

Apache Tomcat 설치

 yum install tomcat6 tomcat6-*

cp /usr/share/tomcat6/webapps/ROOT/*.gif /nas/www/ossnode101/public_html
cp /usr/share/tomcat6/webapps/ROOT/*.svg /nas/www/ossnode101/public_html
cp /usr/share/tomcat6/webapps/ROOT/*.ico /nas/www/ossnode101/public_html


vi /etc/nginx/sites-available/ossnode101.conf   #--- 아래 항목을 추가 합니다.

    location ~ \.do$ {
      proxy_pass              http://localhost:8080;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        Host $http_host;
    }
    location ~ \.jsp$ {
      proxy_pass              http://localhost:8080;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        Host $http_host;
    }
    location ^~/servlets/* {
      proxy_pass              http://localhost:8080;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        Host $http_host;
    }


방화벽 설정 및 서비스 기동

setup                                 #--- 방화벽에서 8080/tcp port를 오픈 합니다.

service tomcat6 restart



http://ossnode101.ossbiz.co.kr/index.jsp 사이트로 접속하여 Tomcat 화면을 표시해 봅니다.

참고 문헌