apache配置多域名

环境:mac,其他环境也可做参考

  • hosts配置

eg:sudo vim /etc/hosts

127.0.0.1       www.testphalcon.com
  • apache配置

找到apache对应安装目录,打开httpd.conf

eg:sudo vim /private/etc/apache2/httpd.conf

开放扩展(去除前#注释即可)

启用apache的虚拟主机功能:

LoadModule vhost_alias_module modules/mod_vhost_alias.so

从httpd-vhosts.conf导入虚拟主机配置:

Include conf/extra/httpd-vhosts.conf

配置httpd-vhosts.conf

eg:sudo vim /private/etc/apache2/extra/httpd-vhosts.conf

增加虚拟主机配置

<VirtualHost *:80>
    DocumentRoot "/Users/wanghaokun/dev/code/phalcon54/"
    ServerName www.testphalcon.com
    ErrorLog "/private/var/log/apache2/testphalcon-error_log"
    CustomLog "/private/var/log/apache2/testphalcon-access_log" common
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order deny,allow
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

  • 重启apache服务

sudo apachectl restart

 

注:

  • apache日志生成机制

在启动apahce服务时,会自动根据配置的ErrorLog 和 CustomLog 生成对应的日志记录文件

 

 

相关文档:apache下设置域名多站点访问及禁止apache访问80端口

 

posted on 2019-01-17 19:10  爱吃柠檬不加糖  阅读(274)  评论(0编辑  收藏  举报

导航