0 usar Notepad++
para modificar os arquivos de configuração
conexão bem-sucedida:
Você pode ser diretamente
Notepad++
modificado o arquivo de configuração, salvar sincronização vontade de Linux
1 Nginx
Virtual Host Configuração
基于域名的虚拟主机
Por nome de domínio para distinguir entre hosts virtuais - Aplicação: Website externo.基于端口的虚拟主机
Para distinguir entre hosts virtuais na porta - Aplicação: Web site interno da empresa, fundo de gestão website externo.Quase nenhum.基于 ip 的虚拟主机
Ou seja, um servidor iniciar vários sites.
Como distinguir entre diferentes locais:
域名不同
端口不同
Nginx
Perfil:
/usr/local/nginx/conf/nginx.conf
1.1 Ao 域名
hospedagem distintiva
Modificar arquivo janela anfitriões:
192.168.153.11 www.test.com
192.168.153.11 www.test1.com
192.168.153.11 www.test2.com
Nginx
configuração
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
#gzip on;
server {
listen 80; # server监听的端口号
server_name localhost; # 配置域名
location / {
root html; # 拦截后,跳转根路径
index index.html index.htm; # 默认页面
}
}
############ 添加配置一
server {
listen 80;
server_name www.test1.com; # 配置域名
location / {
root data/test1; # 拦截后,跳转根路径 data/test1
index index.html index.htm;
}
}
############ 添加配置二
server {
listen 80;
server_name www.test2.com; # 配置域名
location / {
root data/test2; # 拦截后,跳转根路径 data/test2
index index.html index.htm;
}
}
}
Nota: caminho da raiz salto após a intercepção deve ser configurado dimensão caminho relativo:
data/test2
Crie um diretório em Nginx:
Atualizar o arquivo de configuração
/usr/local/nginx/sbin/nginx -s reload
teste:
1,2 por 端口
diferentes hosts virtuais distintivas
Adicionar Host Virtual:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
#gzip on;
server {
listen 80; # server监听的端口号
server_name localhost; # 配置域名
location / {
root html; # 拦截后,跳转根路径
index index.html index.htm; # 默认页面
}
}
############ 添加配置一
server {
listen 8080; # 配置监听的端口号
server_name www.test.com;
location / {
root data/test1; # 拦截后,跳转根路径 data/test1
index index.html index.htm;
}
}
############ 添加配置二
server {
listen 8081; # 配置监听的端口号
server_name www.test.com;
location / {
root data/test2; # 拦截后,跳转根路径 data/test2
index index.html index.htm;
}
}
}
Atualizar o arquivo de configuração
/usr/local/nginx/sbin/nginx -s reload
teste: