一、Apache
成都创新互联是一家专业从事成都网站设计、成都网站建设的网络公司。作为专业的建站公司,成都创新互联依托的技术实力、以及多年的网站运营经验,为您提供专业的成都网站建设、成都全网营销推广及网站设计开发服务!
(1)基于访问主机头(FQDN)
cat /etc/httpd/conf.d/vhostfqdn.conf <virtualhost *:80> documentroot /data/web01 servername www.web01.com <directory /data/web01> require all granted </directory> CustomLog "logs/a_access_log" combined </virtualhost> <virtualhost *:80> documentroot /data/web02 servername www.web02.com <directory /data/web02> require all granted </directory> CustomLog "logs/a_access_log" combined </virtualhost> <virtualhost *:80> documentroot /data/web03 servername www.web03.com <directory /data/web03> require all granted </directory> CustomLog "logs/a_access_log" combined </virtualhost>
(2)基于ip地址
cat /etc/httpd/conf.d/vhostip.conf <virtualhost 192.168.130.11:80> documentroot /data/web01 <directory /data/web01> require all granted </directory> </virtualhost> <virtualhost 192.168.130.22:80> documentroot /data/web02 <directory /data/web02> require all granted </directory> </virtualhost> <virtualhost 192.168.130.33:80> documentroot /data/web03 <directory /data/web03> require all granted </directory> </virtualhost>
(3)基于端口号
cat /etc/httpd/conf.d/vhostport.conf listen 8001 listen 8002 listen 8003 <virtualhost *:8001> documentroot /data/web01 <directory /data/web01> require all granted </directory> </virtualhost> <virtualhost *:8002> documentroot /data/web02 <directory /data/web02> require all granted </directory> </virtualhost> <virtualhost *:8003> documentroot /data/web03 <directory /data/web03> require all granted </directory> </virtualhost>
二、Nginx
(1)基于域名且不同站点
server { listen 80; server_name mobile.magedu.com; location / { root html; index index.html index.htm; } location /python { root /mobile; !!!必须在/mobile目录下创建/python目录,且把文件写入python目录中,否则会报错!!! index index.html index.htm; } location /java { root /mobile; index index.html index.htm; } } server { listen 80; server_name www.magedu.com; location / { root html; index index.html index.htm; } location /python { root /www; index index.html index.htm; } location /java { root /www; index index.html index.htm; } }
文章标题:Apache和Nginx虚拟主机的创建
分享地址:https://www.cdcxhl.com/article20/joccco.html
成都网站建设公司_创新互联,为您提供静态网站、网站设计、、标签优化、云服务器、网站改版
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联