lnmp 환경 구축 (nginx 부하 설정)

1781 단어
1. nginx 설치
yum install yum-priorities -y  
    wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm  
    rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm  
    yum install nginx  
  

    systemctl start nginx.service #  nginx  
    systemctl stop nginx.service #    
    systemctl restart nginx.service #    
    systemctl enable nginx.service #       

2. nginx 포트 번호 변경 (자신의 요구 에 따라)
    cd /etc/nginx/conf.d/  
    vim default.conf  
     listen 80  listen 81  

    systemctl restart nginx.service #  nginx 

3. 방문http://ip:81nginx 홈 페이지 를 볼 수 있 습 니 다.
4. 다음 설치 php - fpm
    yum install php-fpm  

    systemctl start php-fpm.service #  php-fpm  
    systemctl enable php-fpm.service #        

5. nginx 프로필 인식 php 변경
vi / etc / nginx / conf. d / default. conf, 이전 \ # 를 제거 하면 됩 니 다.param
    location ~ \.php$ {  
        root           html;  
        fastcgi_pass   127.0.0.1:9000;  
        fastcgi_index  index.php;  
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/$fastcgi_script_name;   //    
        include        fastcgi_params;  
    }  

6. / usr / share / nginx / html 에 test. php 를 새로 만 듭 니 다. 
방문 하 다.http://ip:81/test.phpnginx 의 phop 페이지 를 볼 수 있 습 니 다.
7. 부하 설정
upstream site{  
        server 172.16.170.138;  
        server 172.16.170.139;  
}  
server {  
    listen       80;  
    server_name  localhost;  
  
    #charset koi8-r;  
    #access_log  /var/log/nginx/log/host.access.log  main;  
  
    location / {  
        root   /usr/share/nginx/html;  
        index  index.html index.htm;  
        proxy_pass http://site;  
    } 

좋은 웹페이지 즐겨찾기