# first method
# go to nginx
configuration folder
cd /usr/local/nginx/conf
# edit configuration file
vim nginx.conf
# is modified as follows
......
http {
......
server {
listen 80;
server_name location;
#charset koi8-r;
#access_log logs/host.access.log main;
location/{
root html/index/;
index index.html index.htm;
}
......
}
# 访问 www.test1.com 网站,默认解析到 http://ip/test1 项目
server {
listen 80;
server_name www.test1.com;
location/{
root html/test1/;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# 访问 www.test2.com 网站,默认解析到 http://ip/test2 项目
server {
listen 80;
server_name www.test2.com;
location/{
alias html/test2/;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
......
}
domain name resolution address is the server’s IP, access to nginx will determine which site to request, and then match to the corresponding project
# the second method
# go to nginx
configuration folder
cd /usr/local/nginx/conf
# new folder vhost
Create www.test.com.conf
under the folder vhost
server {
listen 80;
server_name www.test.com;
location/{
root html/www.test.com;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
pay attention to change
root
path (www.test.com
come in to visit the project path)
here newwww.test.com
can be named according to your domain name, according to the above template, Changeserver_name and root
.
. Create a newproject name for each project
# go to nginx
configuration folder
cd /usr/local/nginx/conf
# edit configuration file
vim nginx.conf
# is modified as follows
......
http {
......
#引入其它配置
include vhost/*.conf;
......
}
domain name resolution address is the server's IP, access to nginx will determine which site to request, and then match to the corresponding project
reference blog:
- configure different Nginx domain names to access different projects
Read More:
- JS error: permission denied to access property ‘document’— document.domain -The same source strategy of JavaScript
- Solved: No’Access-Control-Allow-Origin’ cross-domain issue
- Nginx startup error: nginx: [error] open() “/ var / run / nginx/ nginx.pid The solution of “failed (2: no such file or directory)”
- Ajax error reporting cross domain, AJAX cross domain access error 501 solution
- nginx: [error] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)
- 13. R language: Error in match.names(clabs, names(xi)): The name is not relative to the original name
- nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
- R language error in match.names (clabs, names(xi)) :
- The solution of centos7 in VMware virtual machine unable to access after installing nginx
- /var/run/nginx/nginx.pid” failed (2: No such file or directory)
- Nginx error: nginx: [error] invalid PID number “” in “/run/nginx.pid”
- nginx: [error] open() “/usr/local/var/run/nginx.pid” failed (2: No such file or directory)
- Domain error in object XXX “other” domain “other” rejected values and atm913
- nginx: [error] invalid PID number ““ in “/data/nginx/logs/nginx.pid“
- Solve the problem of starting nginx nginx.pid error
- CentOS7 nginx Failed to read PID from file /run/nginx.pid: Invalid argument?
- nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)
- nginx: [error] invalid PID number in /var/run/nginx.pid
- Nginx start error: job for nginx.service failed because the control process exited with error code
- nginx: open() “/var/run/nginx.pid“ failed (2: No such file or directory)