apache-虚拟主机配置

 

前言:以域名www.my.com举例

 

1、 host绑定(非必须)

   win: Windows\System32\drivers\etc

   类nuix: /etc/hosts

 添加记录 主机IP www.my.com

2. 修改apache的主配置文件

 一般默认安装:/usr/local/apache/etc/httpd.conf

 去掉前面的# 加载虚拟主机配置文件
 #Include etc//extra/httpd-vhosts.conf

3. 修改httpd-vhosts.conf文件

 vim /usr/local/apache/etc/extra/httpd-vhosts.conf

  <VirtualHost *:80>
    ServerAdmin XXX@163.com
    DocumentRoot "/usr/local/apache/htdocs"  # 项目路径 
    ServerName ip或者域名
    ErrorLog "logs/default.com-error_log"
    CustomLog "logs/default.com-access_log" common

  <Directory "/usr/local/apache//htdocs/my">

    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
  </Directory>

  </VirtualHost>

4. 重启apache

 apachectl restart

posted @ 2018-02-05 11:45  一七令  阅读(130)  评论(0编辑  收藏  举报