基于域名
cd /usr/local/nginx/html/
mkdir aaa
mkdir bbb
echo www.aaa.com > aaa/index.html
echo www.bbb.com > bbb/index.html
vim /usr/local/nginx/conf/nginx.conf
修改server中的配置
server {
listen 80;
server_name www.aaa.com;
charset utf-8;
access_log logs/benet.access.log;
location / {
root /usr/local/nginx/html/aaa;
index index.html index.php;
}
server {
listen 80;
server_name www.bbb.com;
charset utf-8;
access_log logs/bbb.access.log;
location / {
root /usr/local/nginx/html/bbb;
index index.html index.php;
}
}
第二个的网页的配置代码
/etc/init.d/nginx restart
echo "192.168.254.10 www.aaa.com" >> /etc/hosts
echo "192.168.254.10 www.bbb.com" >> /etc/hosts
你的ip 你的域名
# 由于没有做dns只能修改自身的hosts文件
基于端口
vim /usr/local/nginx/conf/nginx.conf
只需修改端口
基于ip
ifconfig ens33:0 192.168.254.12/24
配置一个子接口
文章来源:https://www.toymoban.com/news/detail-506809.html
文章来源地址https://www.toymoban.com/news/detail-506809.html
到了这里,关于Linux:nginx虚拟主机的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!