Apache添加多端口及实现单ip多端口映射的方法

先给大家说下apache添加多端口的方法,具体步骤如下所示:

Apacheconf 目录下

 Apache添加多端口及实现单ip多端口映射的方法 Linux 第1张

添加端口监听

 Apache添加多端口及实现单ip多端口映射的方法 Linux 第2张

Vhost.conf简单写写

 Apache添加多端口及实现单ip多端口映射的方法 Linux 第3张

下面是有关apache实现单ip多端口映射的内容

我使用一个apache服务器。在我的apache根目录下有这么几个网站,如Test、Child这两个文件夹,也就是两个网站。我想这样,当我访问的时候就访问Test,当我访问http://localhost:8080的时候就访问Child。

我们需要配置apache。讲apache文件夹下的conf中的httpd.conf打开,搜索Include conf/extra/httpd-vhosts.conf,将前面的注释去掉。再打开conf/extra/httpd-vhosts.conf文件,清除里面的内容,这样写道:

  NameVirtualHost *:8080  <VirtualHost *:8080>  ServerName localhost  ServerAlias localhosts  DocumentRoot D:/development/www/Child  </VirtualHost>  NameVirtualHost *:80  <VirtualHost *:80>  ServerName localhost  ServerAlias localhost  DocumentRoot D:/development/www/Test  </VirtualHost>

重启apache服务器就ok了。

参与评论