apache配置不同端口管理不同项目

端口无法连接,记得查看是否开启了防火墙或者查看云服务器入端口是否开启!!!!

window下 安装了wampmanager的找到如下目录
方法一
F:\wamp\bin\apache\apache2.4.37\conf\extra
打开 httpd-vhosts.conf 文件

# Virtual Hosts
#
<VirtualHost *:80>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

添加如下:

# Virtual Hosts
#
<VirtualHost *:80>  
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>
<VirtualHost *:81>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www2"
  <Directory "${INSTALL_DIR}/www2/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

方法二
打开F:\wamp\bin\apache\apache2.4.37\conf目录先的 httpd.conf
Listen 80 后面添加 Listen 81


Listen 80
Listen 81

然后在httpd.conf末尾添加

<VirtualHost *:81>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "${INSTALL_DIR}/www2"
  <Directory "${INSTALL_DIR}/www2/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

重启apache 即可实现不同端口管理不同项目(
端口无法连接,记得查看是否开启了防火墙或者查看云服务器入端口是否开启!!!!

centos系统同理由

端口无法连接,记得查看是否开启了防火墙或者查看云服务器入端口是否开启!!!!

方法一:在目录/etc/httpd/conf.d目录下新建 VirtualHost.conf文件(名字随便取,但后缀一定要是.conf)

# Virtual Hosts
#
<VirtualHost *:81>
  ServerName localhost
  ServerAlias localhost
  DocumentRoot "/var/www2/html"
  <Directory "/var/www2/html">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>
~                

保存,重启apache服务器

方法二:修改 /etc/httpd/conf/httpd.conf,步骤和内容如上windows方法二
需要注意的是:
DocumentRoot “${INSTALL_DIR}/www2” 改为 DocumentRoot “/var/www2/html” 或者你的文件目录

<Directory “${INSTALL_DIR}/www2/”> 改为<Directory “/var/www2/html”> 或者你的文件目录

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值