0 use Notepad++
to modify configuration files
connection succeeded:
You can be directly
Notepad++
modified the configuration file, save will sync to Linux
1 Nginx
Virtual Host Configuration
基于域名的虚拟主机
By domain name to distinguish between virtual hosts - Application: External website.基于端口的虚拟主机
To distinguish between virtual hosts on port - Application: the company's internal Web site, external website management background.Almost no.基于 ip 的虚拟主机
That is, a server start multiple sites.
How to distinguish between different sites:
域名不同
端口不同
Nginx
Profile:
/usr/local/nginx/conf/nginx.conf
1.1 By 域名
distinguishing Hosting
Modify window hosts file:
192.168.153.11 www.test.com
192.168.153.11 www.test1.com
192.168.153.11 www.test2.com
Nginx
Configuration
#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;
}
}
}
Note: Jump root path after the interception should be configured dimension relative path:
data/test2
Create a directory under Nginx:
Reload the configuration file
/usr/local/nginx/sbin/nginx -s reload
test:
1.2 By 端口
distinguishing different virtual hosts
Add Virtual Host:
#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;
}
}
}
Reload the configuration file
/usr/local/nginx/sbin/nginx -s reload
test: