zoukankan      html  css  js  c++  java
  • Ubuntu Apache多站点配置

    服务器环境:ubuntu_16, apache/2.4.18

    域名为 www.aaa.com 和 www.bbb.com 的两个站点都部署上去

    环境安装过程略

    修改两处配置

    1.apache配置文件位置  /etc/apache2/sites-available/000-default.conf(相当于本地wampinapacheapache2.4.18confextrahttpd-vhosts.conf)

    打开

    修改为

    <VirtualHost *:80>
    
      ServerAdmin xxx@xx.xxx  
      DocumentRoot 项目路径1
      ServerName www.aaa.com
    
      <Directory "项目路径1">
        Options FollowSymLinks
        AllowOverride All 
        Require all granted
      </Directory>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    
    <VirtualHost *:80>
    
      ServerAdmin xxx@xx.xxx  
      DocumentRoot 项目路径2
      ServerName www.bbb.com
    
      <Directory "项目路径2">
        Options FollowSymLinks
        AllowOverride All 
        Require all granted
      </Directory>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>

    设置不同的ServerName、DocumentRoot 和 Directory 

    2.打开查看 /etc/hosts 文件(相当于本地C:WindowsSystem32driversetchosts)

    默认

    127.0.0.1   localhost

    加上 

    127.0.0.1   www.aaa.com
    127.0.0.1   www.bbb.com

    将项目代码放入对应的 项目路径1 和 项目路径2

    重启apache

    sudo service apache2 restart

    完成,访问测试一下

  • 相关阅读:
    ArrayList 和 LinkList 的区别
    fork()相关的源码解析
    http协议状态码及其意义
    数据库的死锁相关知识
    JDBC事务的相关知识
    请求http页面的相关过程
    static 关键字的作用
    计算机网络网络层的IP地址划分及子码
    文件的相关操作.
    set集合和深浅拷贝
  • 原文地址:https://www.cnblogs.com/yangfei123/p/9803807.html
Copyright © 2011-2022 走看看