다섯 번 째 모듈 Ubunt 14.04 LANMP 환경, Nginx 가상 호스트 설정 - (첫 번 째 부분)

4960 단어
Ubuntu 에서 php 7 mysql 5.7 LNMP 환경 구축 다섯 번 째 모듈 참고 Ubunt 14.04 LANMP 환경, Nginx 가상 호스트 설정 - (첫 번 째 부분) 다섯 번 째 모듈 Nginx 부하 균형, 동정 분리 - (세 번 째 부분) 306 - Ubuntu 16.04 LNMP 설치
첫 번 째 부분 에 LANMP 환경 설치 (apache2 | php 5.6 | mysql 5.6)
1. apt 원본 수정 (Ubuntu 14.04) AliYun 원본 추가
vim /etc/apt/sources.list

알 리 윤 원
# AliYun
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

업데이트
sudo apt update
sudo apt upgrade

2. 아파 치 2 설치
sudo apt-get install apache2
//  rewrite
sudo a2enmod rewrite

설정 파일 에서. htaccess 를 지원 하고 apache2. conf 를 수정 합 니 다.

        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted


3. Nginx 설치
sudo apt-get install nginx

4. mysql 5.6 설치
sudo apt-get install mysql-server
sudo service mysql start

5. php 5.6 설치
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade
sudo apt-get install php5.6 php5.6-mysql php-gettext php5.6-mbstring libapache2-mod-php5.6 php5.6-fpm
// 5.6     7.0     php7.0
sudo service php5.6-fpm restart
sudo service apache2 restart

두 번 째 부분 Nginx 가상 호스트 설정
필드: 가상 호스트 두 대 설정:
IP
도 메 인 이름
루트 디 렉 터 리172.16.0.51 a.com /home/ /a 172.16.0.51 b.com /home/ /b
  • 사용자 집 디 렉 터 리 에 디 렉 터 리 만 들 기
  • cd ~
    mkdir a b
    //   a、b     index.php       
    
  • Nginx 설정 디 렉 터 리 에 두 개의 프로필 추가
  • sudo vim /etc/nginx/sites-available/a.com //      
    

    내용 은 다음 과 같다.
    server {
            listen 80;
            root /home/scort/a; #    b.com        `/home/scort/b`,   `scort`         ,        
            index index.php index.html index.htm;
    
            # Make site accessible from http://localhost/
            server_name a.com; #      b.com
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            # PHP  
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    
            #   # `/etc/php/5.6/fpm/php-fpm.conf`  php5.6-fpm.sock     ,      pid       
            #   # With php5-fpm:
                    fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; # php5.6-fpm.sock     
                    fastcgi_index index.php;
                    include fastcgi_params;
            }
    }
    
  • php. ini 의 ;cgi.fix_pathinfo = 1; 수정 cgi.fix_pathinfo = 0;
  • 복사 a.com 는 설정 에서 수정 할 부분 을 따로 저장 합 니 다!

  • 다음은 Nginx 의 사이트 설정 디 렉 터 리 b.com 에서 소프트 체인 설정 파일
    cd /etc/nginx/sites-enable/
    sudo ln -s /etc/nginx/sites-available/a.com
    sudo ln -s /etc/nginx/sites-available/b.com
    
  • 서비스 재 개
  • sudo service php5.6-fpm restart
    sudo service nginx restart
    
  • 클 라 이언 트 방문
  • sudo vim /etc/hosts
          
    172.16.0.51 a.com
    172.16.0.51 b.com
    

    브 라 우 저 접근
    http://a.com
    http://b.com
    

    Nginx 프로필 메 인 프로필 /etc/nginx/sites-enable/, Ubuntu 시스템 은 자동 으로 Nginx 프로필 을 나 누 어 줍 니 다. 이렇게 하면 메 인 프로필 을 읽 고 편집 할 수 있 습 니 다.
    주 설정 은 일부 설정 정 보 를 배치 합 니 다. 초보 자 는 잠시 신경 쓰 지 않 고 설정 파일 70 줄 에 다음 과 같은 설정 이 있 습 니 다.
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*; 
    
    /etc/nginx/nginx.conf 여기 서 주의해 야 할 것 은 conf. d 디 렉 터 리 아래 에 놓 인 것 도 Nginx 의 설정 입 니 다. 불 러 오 는 순서 에서 conf. d 에 있 는 설정 은 맨 아래 에 있 습 니 다. 기 존 프로필 에 있 는 설정 을 덮어 씁 니 다. 설정 을 수정 해 야 한다 면 conf. d 에서 수정 해 야 합 니 다. 홈 프로필 을 직접 수정 하 는 것 이 아니 라 잘못 고 쳐 도 복구 할 수 있 습 니 다./etc/nginx/conf.d/*.conf sites - enabled 는 가상 컴퓨터 호스트 설정 파일 입 니 다. 한 사이트 의 ngix. conf 에서 수정 하지 않 습 니 다. 물론 sites - enabled 에 있 지 않 고 sites - available 폴 더 에 있 습 니 다. 두 폴 더 의 글자 그대로 sites - available 는 사용 가능 한 사이트 이 고 sites - enabled 는 이미 사용 한 사이트 입 니 다.

    좋은 웹페이지 즐겨찾기