您的位置:首页 > 运维架构 > Linux

Linux(contos)虚拟域名配置(通过IP地址和不同端口号访问不同项目)

2019-01-29 14:38 288 查看
  1. 配置监听
    /etc/httpd/conf/httpd.conf 中:Listen 80 处添加Listen 8088(端口号)
  2. 配置虚拟域名(apache)
    创建/etc/httpd/conf.d/httpd-vhost.conf文件
<VirtualHost *:8088>
#虚拟域名
ServerName a.com
#入口文件位置
DocumentRoot /var/www/html/XXX/public
#根目录访问权限配置
<Directory  "/var/www/html/XXX/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
  1. 注册虚拟域名访问地址
    编辑/etc/hosts文件
    添加127.0.0.1 a.com (a.com为虚拟域名,与上述ServerName保持一致)后保存文件,
  2. 重启apache服务器
    Systemctl restart httpd
  3. 浏览器访问
    服务器IP地址: http://IP:8088/index.php

注意:需要开启服务器安全组配置中的端口号

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐