打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
apache配置多域名多端口 | 五点的博客

1、单域名单端口设置

如:www.abc.com 默认用80访问

特别说明,apache的配置默认都在安装目录下的conf目录里面

或者是/etc/apache2

不过一定要注意,listen.conf文件中端口监听是否开启

如下图,表示已经开启80端口监听

直接默认修改default-server.conf

这个配置最好简单

安装好了,之后,默认已经能够使用了,只是要把它修改成你需要的域名及访问路径罢了。

给一个标准配置吧

DocumentRoot “/srv/www/htdocs”

#
# Configure the DocumentRoot
#
<Directory “/srv/www/htdocs”>
        # Possible values for the Options directive are “None”, “All”,
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that “MultiViews” must be named *explicitly* — “Options All”
        # doesn’t give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs-2.2/mod/core.html#options
        # for more information.
        Options None
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be “All”, “None”, or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        AllowOverride None
        # Controls who can get stuff from this server.
        Order allow,deny
        Allow from all
</Directory>

2、单域名多端口设置

<Directory “/srv/www/htdocs/bbs”>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory “/srv/www/htdocs/”>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost   *:80
NameVirtualHost   *:81
<VirtualHost *:80>
          DirectoryIndex  index.html index.php
          ServerName   “www.abc.com”
          DocumentRoot   “/srv/www/htdocs/”  
  </VirtualHost>

<VirtualHost *:81>
          DirectoryIndex   index.php
    ServerName   “www.abc.com:81″
          DocumentRoot   “/srv/www/htdocs/bbs/”  
  </VirtualHost>

3、多域名多端口设置

<Directory “/srv/www/htdocs/btc”>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory “/srv/www/htdocs/bbs”>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory “/srv/www/htdocs/”>
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost   *:80
NameVirtualHost   *:81
<VirtualHost *:80>
          DirectoryIndex  index.html index.php
          ServerName   “www.abc.com”
          DocumentRoot   “/srv/www/htdocs/”  
  </VirtualHost>

<VirtualHost *:80>
          DirectoryIndex  index.html index.php
          ServerName   “www.btc.com”
          DocumentRoot   “/srv/www/htdocs/btc”  
  </VirtualHost>

<VirtualHost *:81>
          DirectoryIndex   index.php
    ServerName   “www.abc.com:81″
          DocumentRoot   “/srv/www/htdocs/bbs/”  
  </VirtualHost>

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
在Apache中配置基于主机名的虚拟主机
Apache2.2多域名虚拟主机配置
配置apache2运行多个网站/虚拟主机+多个访问端口
Apache绑定多IP多域名
xampp配置多个监听端口和不同的网站目录
使用APMServ本地搭建多个网站的两种方法(图)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服