echo "192.168.2.66 www.xkq.com www.wy.com" >> /etc/hosts
mkdir -p /var/www/html/ly/ mkdir -p /var/www/html/weq/ echo "<h1>www.xkq.com</h1>" > /var/www/html/ly/index.html echo "<h1>www.wwy.com</h1>" > /var/www/html/weq/index.html
vim /usr/local/nginx/conf/nginx.conf server { listen 80; server_name www.xkq.com; #设置域名 charset utf-8; #设置网页字符集 access_log logs/xkq.com.access.log; #设置日志名 location / { root /var/www/html/xkq; #设置www.xkq.com的工作目录 index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 80; server_name www.wy.com; #设置域名 charset utf-8; #设置网页字符集 access_log logs/wy.com.access.log; #设置日志名 location / { root /var/www/html/wy; #设置www.weq.com的工作目录 index index.html index.htm; }
systemctl restart nginx
浏览器访问http://www.xkq.com
浏览器访问http://www.wy.com
ifconfig ens33:1 192.168.2.67/24 vim /usr/local/nginx/conf/nginx.conf
server { listen 192.168.2.66:80; #修改监听的为ip server_name www.ly.com; charset utf-8; access_log logs/ly.com.access.log; location / { root /var/www/html/ly; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 192.168.2.67:80; #修改监听的为ip server_name www.weq.com; charset utf-8; access_log logs/weq.com.access.log; location / { root /var/www/html/weq; index index.html index.htm; }
nginx -t systemctl restart nginx
浏览器访问http://192.168.229.66:80
浏览器访问http://192.168.229.67:80
vim /usr.local/nginx/conf/nginx.conf server { listen 192.168.2.66:8080; #修改监听的为ip server_name www.ly.com; charset utf-8; access_log logs/ly.com.access.log; location / { root /var/www/html/ly; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 192.168.2.67:456; #修改监听的为ip server_name www.weq.com; charset utf-8; access_log logs/weq.com.access.log; location / { root /var/www/html/weq; index index.html index.htm; }
nginx -t systemctl restart nginx.service
浏览器访问http://192.168.2.66:8080
浏览器访问http://192.168.2.67:456