洛阳兼职网站网站与网站链接怎么做
2026/1/17 8:04:18 网站建设 项目流程
洛阳兼职网站,网站与网站链接怎么做,网络营销论文题目精选,如何做网站推广赚钱文章目录实验环境一、基于域名虚拟主机配置二、基于端口虚拟主机配置三、基于主机别名配置实验环境 安装好Nginx [rootweb01 ~]# yum -y install nginx [rootweb01 nginx]# systemctl start nginx [rootweb01 nginx]# systemctl enable nginx Created symlink from /etc/syst…文章目录实验环境一、基于域名虚拟主机配置二、基于端口虚拟主机配置三、基于主机别名配置实验环境安装好Nginx[rootweb01 ~]# yum -y install nginx[rootweb01 nginx]# systemctl start nginx[rootweb01 nginx]# systemctl enable nginxCreated symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.一、基于域名虚拟主机配置1创建web站点目录[rootweb01 ~]# mkdir -p /soft/code/{www,bbs}[rootweb01 ~]# echo www /soft/code/www/index.html[rootweb01 ~]# echo bbs /soft/code/bbs/index.html2配置不同域名的虚拟主机[rootweb01 conf.d]# cat bbs.confserver{listen80;server_name bbs.server.com;root /soft/code/bbs;index index.html;}[rootweb01 conf.d]# cat www.confserver{listen80;server_name www.server.com;root /soft/code/www;index index.html;}3主机映射[rootweb01 conf.d]# cat /etc/hosts10.0.0.7 web01 www.server.com bbs.server.com4访问域名[rootweb01 bbs]# curl www.server.comwww[rootweb01 bbs]# curl bbs.server.combbs 如果不管怎么访问都是默认的网页可以检查一下主配置文件/etc/nginx/nginx.conf中 必须包含include /etc/nginx/conf.d/*.conf;加载conf.d目录下的所有.conf文件否则你的虚拟主机文件不会被加载二、基于端口虚拟主机配置让同一台 Nginx 服务器通过不同端口如font stylecolor:rgba(0, 0, 0, 0.85);8080/font、font stylecolor:rgba(0, 0, 0, 0.85);8081/font返回不同页面1创建站点目录[rootweb01 bbs]# mkdir -p /usr/share/nginx/test8080[rootweb01 bbs]# mkdir -p /usr/share/nginx/test8081[rootweb01 bbs]# echo h1Welcome to Port 8080!/h1 /usr/share/nginx/test8080/index.html[rootweb01 bbs]# echo h1Welcome to Port 8081!/h1 /usr/share/nginx/test8081/index.html2修改配置文件[rootweb01 bbs]# cat /etc/nginx/conf.d/8080.confserver{listen8080;# 核心监听8080端口非默认80端口server_name _;# 无需域名用_匹配所有域名/IP# 8080端口对应的站点根目录root /usr/share/nginx/test8080;# 索引页默认访问index.htmlindex index.html index.htm;}[rootweb01 bbs]# cat /etc/nginx/conf.d/8081.confserver{listen8081;# 核心监听8081端口server_name _;# 8081端口对应的站点根目录root /usr/share/nginx/test8081;index index.html index.htm;}[rootweb01 bbs]# nginx -tnginx: the configurationfile/etc/nginx/nginx.conf syntax is ok nginx: configurationfile/etc/nginx/nginx.conftestis successful[rootweb01 bbs]# systemctl restart nginx3访问不同端口[rootweb01 bbs]# curl 127.0.0.1:8080h1Welcome to Port8080!/h1[rootweb01 bbs]# curl 127.0.0.1:8081h1Welcome to Port8081!/h1三、基于主机别名配置实现用户访问多个域名对应同一个网站, 比如用户访问 www.server.com 和访问 server.com 内容一致1创建别名对应的站点目录和测试页面[rootweb01 bbs]# mkdir -p /usr/share/nginx/test_main[rootweb01 bbs]# echo h1Welcome to Main Site! (www.test.com / test.com / abc.test.com)/h1 /usr/share/nginx/test_main/index.html2配置 Nginx 虚拟主机别名[rootweb01 bbs]# cat /etc/nginx/conf.d/vhosts_alias.confserver{listen80;# 核心配置主域名多个别名空格分隔server_name www.test.com test.com abc.test.com;# 指向主站点目录root /usr/share/nginx/test_main;index index.html index.htm;}[rootweb01 bbs]# nginx -tnginx: the configurationfile/etc/nginx/nginx.conf syntax is ok nginx: configurationfile/etc/nginx/nginx.conftestis successful[rootweb01 bbs]# systemctl restart nginx3配置hosts文件[rootweb01 bbs]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain610.0.0.5 lb0110.0.0.6 lb0210.0.0.7 web01 www.server.com bbs.server.com www.test.com test.com abc.test.com3访问不同域名看看内容是否一致[rootweb01 ~]# curl www.test.comh1Welcome to Main Site!(www.test.com / test.com / abc.test.com)/h1[rootweb01 ~]# curl test.comh1Welcome to Main Site!(www.test.com / test.com / abc.test.com)/h1[rootweb01 ~]# curl abc.test.comh1Welcome to Main Site!(www.test.com / test.com / abc.test.com)/h1

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询