다섯 번 째 모듈 Ubunt 14.04 LANMP 환경, Nginx 가상 호스트 설정 - (첫 번 째 부분)
첫 번 째 부분 에 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
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;
}
}
;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 는 이미 사용 한 사이트 입 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.