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

  1. 配置监听
    /etc/httpd/conf/httpd.conf 中:Listen 80 处添加Listen 8088(端口号)
  2. 配置虚拟域名(apache)
    创建/etc/httpd/conf.d/httpd-vhost.conf文件

		#虚拟域名
        ServerName a.com
		#入口文件位置
        DocumentRoot /var/www/html/XXX/public
		#根目录访问权限配置
        
                Options +Indexes +Includes +FollowSymLinks +MultiViews
                DirectoryIndex index.php
                AllowOverride All
                Allow from all
        

  1. 注册虚拟域名访问地址
    编辑/etc/hosts文件
    添加127.0.0.1 a.com (a.com为虚拟域名,与上述ServerName保持一致)后保存文件,
  2. 重启apache服务器
    Systemctl restart httpd
  3. 浏览器访问
    服务器IP地址: http://IP:8088/index.php

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

你可能感兴趣的:(学习总结,服务器相关内容)