>  기사  >  백엔드 개발  >  리눅스 nginx 설치

리눅스 nginx 설치

WBOY
WBOY원래의
2016-08-08 09:23:10992검색

gcc 설치

yum install gcc gcc-c++

첫 번째 다운로드

pcre -8.12.tar.gz

http://download.csdn.net/detail/qq_22929803/8771933

tar -zxvf pcre-8.21.tar.gz

cd pcre-8.21

./configure

make

make install

./configure에서 권한이 부족하다는 메시지가 표시되면 chmod 777 ./configure이면 충분합니다

./configure

구성: 오류: `/usr/local/src/pcre-8.12'에서:구성: 오류: $PATH

그럼 gcc가 부족하네요

yum install gcc 다운로드 gcc

zlib 라이브러리 설치

cd /usr/local/

wget

http://zlib.net/zlib -1.2.8.tar.gz

tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8

./configure

make

make install

ssl 설치

cd /usr/local/

wget

http://www.openssl .org/source/openssl-1.0.1c.tar.gz

tar -zxvf openssl-1.0.1c.tar.gz

./config

make

make install

nginx 설치

Nginx에는 일반적으로 안정 버전과 개발 버전 두 가지 버전이 있는데, 목적에 따라 둘 중 하나를 선택하면 됩니다. , 다음은 Nginx를 /usr/local/nginx 디렉토리에 설치하는 자세한 단계입니다:

cd /usr/local/

wget

http://nginx.org/download/nginx-1.2.8.tar.gz

tar -zxvf nginx-1.2.8.tar.gz

cd nginx-1.2.8

./configure --prefix=/ usr/local/nginx --with-pcre=/usr/local/src/pcre-8.12 --with-http_ssl_module --with-openssl=/usr/local/src/openssl-1.0.1c

make

make install

--with-pcre =/usr/src/pcre-8.21은 pcre-8.21의 소스 코드 경로를 나타냅니다.

--with-zlib=/usr/src/zlib-1.2.7은 zlib-1.2.7의 소스 코드 경로를 나타냅니다.

6.

을 시작하여 시스템의 포트 80이 비어 있는지 확인합니다.

/usr/local/nginx/sbin/nginx

시작 성공 여부 확인 :

netstat -ano|grep 80 결과가 입력되면 시작 성공

브라우저를 엽니다. 이 컴퓨터의 IP에 액세스하려면 브라우저에 Welcome to nginx!가 나타나면 Nginx가 성공적으로 설치되고 실행되었음을 의미합니다.

7. 다시 시작

/usr/local/nginx/sbin/nginx –s reload

8. 구성 파일 수정

cd /usr/local/nginx/conf

vi nginx.conf

9. 일반 구성

#nginx 실행 사용자 및 그룹

user www www; 

#프로세스 시작, 일반적으로 CPU 수와 동일하게 설정

worker_processes 4;

#전역 오류 로그 및 PID 파일

pid /var/run/nginx.pid;

error_log / var/log/nginx/error.log;

events {

                              #epoll은 다중화 IO입니다(I/O 다중화 ) 방법 중 하나(linux2.6 이상 커널에만 해당)는 nginx의 성능을 크게 향상시킬 수 있습니다

epoll을 사용하세요. 단일 백그라운드 작업자 프로세스에 대한 최대 동시 연결 수입니다.

Worker_connections 10240; # http 서버를 설정하고 역방향 프록시 기능을 사용하여 로드 밸런싱 지원 제공

http {

                                                                                                                >

default_type 애플리케이션/옥텟-스트림;

error_page 400 403 500 502 503 504 /50x.html;

인덱스 index.html index.shtml

autoindex off;

fastcgi_intercept_errors on;

        sendfile        on;

 

        # 이는 좋은 기본값입니다.

        tcp_nopush      on;

        tcp_nodelay     off;

 

        # 출력 압축하면 대역폭이 절약됩니다

        gzip  off;

        #gzip_static on;

        #gzip_min_length  1천;

        gzip_http_version 1.0;

        gzip_comp_level 2;

        gzip_buffers  4 16k;

        gzip_proxied any;

        gzip_disable "MSIE [1-6].";

        gzip_types  text/ 평원 text/html text/css 애플리케이션/x-javascript 애플리케이션/xml 애플리케이션/xml+rss text/javascript;

        #gzip_vary on;

 

        server_name_in_redirect off;

 

#设定负载均衡的服务器列表

        업스트림 포털 {

                서버 172.16.68.134:8082 max_fails=2 failure_timeout=30s;

서버 172.16.68.135:8082 max_fails=2 failure_timeout=30s;

                       서버 172.16.68.136:8082 max_fails=2 failure_timeout=30s ;

서버 172.16.68.137:8082 max_fails=2 failure_timeout=30s;

        }

 

#업스트림 오버플로 {

         #       서버 10.248.6.34:8090 max_fails=2 failure_timeout=30s;       

         #       서버 10.248.6.45:8080 max_fails=2 failure_timeout=30s;       

        #}

 

        서버 {

                                  #侦听8080端口

               듣기       8080;

                서버_이름  127.0.0.1;

 

                 #403、404页면중정向地址

                  error_page  403 = http://www.e 100.cn/ebiz/기타/ 217/403.html;

                 error_page  404 = http://www.e100.cn/ebiz/other/218/404.html;

                  proxy_connect_timeout      90;

                  proxy_send_timeout         180;

                  proxy_read_timeout         180;

 

                  proxy_buffer_size 64k;

                  proxy_buffers 4 128k;

                   proxy_busy_buffers_size 128k;

 

 

                 client_header_buffer_size 16k;

                  large_client_header_buffers 4 64k;

 

               #proxy_send_timeout         3분;

                #proxy_read_timeout         3분;

               #proxy_buffer_size          4k;

              #proxy_buffers              4 32k; 🎜>

 

               proxy_set_header 호스트 $http_host;

              proxy_max_temp_file_size 0;

                #proxy_hide_header 세트-쿠키;

                

         #      if ($host != 'www.e100.cn' ) {

         #                다시 작성 ^/(.* )$ http://www.e100.cn/$1 영구;

         #       }

 

 

               위치 / {

                  모두 거부;

               }

 

                 위치 ~ ^/resource/res/img/blue/space.gif {

                  proxy_pass http ://tecopera;

               }

 

              위치 = / {

                  ^(.*)$  /ebiz/event/517.html 마지막으로 다시 작성;

              }

 

 

                  위치 = /ebiz/event/517.html {

                  add_header Vary Accept-Encoding;

                    루트 /data /web/html;

                   10분 후 만료;

             }

 

 

 

 

              위치 = /check.html {

                   root /usr/local/nginx/html/;

                  access_log off;

}

 

             위치 = /50x.html {

                  root /usr /로컬/ nginx/html/;

                   1분 후 만료;

                  access_log off;

               }

 

 

             위치 = /index.html {

                     add_header Vary Accept-Encoding;

#determin义服务器的默认网站根目录位置

                    루트 /data/web/html/ ebiz;

                    10분 만료;

              }

#정义反向代理访问명称

                  위치 ~ ^/ecps-portal/* {

                 # 만료 10분;

# 정중向集群명

                  proxy_pass http://portals;

                  #proxy_pass http://172 .16.68.134:8082;

               }

 

                 위치 ~ ^/fetionLogin/* {

>        #proxy_pass http://172.16.68.134:8082 ;

               }

 

                 #위치  ~ ^/business/* {                                                 

                #   #은 10분 후에 만료됩니다.                                                                                

                #    proxy_pass http://172.16.68.132:8088;                                                                   

                #    #proxy_pass http://172.16.68.134:8082;                                                       

               #}

 

                  위치 ~ ^/rsmanager/* {

                  10분 만료;

                 root /data/web/;

                    #proxy_pass http://rsm;

                       위치 ~* (.* ).(jpg|gif|htm|html|png|js|css)$  {

                        root /data/web/html/;

#页면缓存时间为10分钟

                      10분 만료;

                   }

 

#设定查看Nginx状态的地址     

              위치 ~* ^/NginxStatus/ {

> 10.1.252.126;

                   10.248 허용 .6.49;

                  127.0.0.1 허용;

                 모두 거부;

               }

        #       error_page   405 =200 @405;

        #      위치 @405

        #      {

> 🎜>

> }

         서버 {

              듣기       8082;

 

               server_name  _;

              위치 = /check.html {

                  root /us r/local/nginx/html/;

                  접속_로그오프;

             }

                  

        }

         서버 {

                 듣기       8088;

                  서버_이름  _;

                 위치 ~ ^/* {

           /data/web/b2bhtml/;

                   access_log off;

         }               

         }

        서버 {

               들어봐       9082;

              서버_이름  _;

🎜>

        #        위치 ~ ^/resource /* {

        #            10분 후에 만료;

        #         root /data/web/html/;

         #       }

 

위치 / {

루트 /data/web/html/sysMaintain/;

                  if (!-f $ request_filename) {

                                                             }

}

이상은 관련 내용을 포함하여 리눅스 nginx 설치에 대해 소개하고 있는데, PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되었으면 좋겠습니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.