如何通过apache2配置多站点

来源:互联网 发布:mac管理安卓手机助手 编辑:程序博客网 时间:2024/06/09 08:46

设置多站点

详细的步骤和设置可以参考官方文档。

假设主站的域名为:www.bitrix.zjf(原生bitrix代码),第二个站点域名取为:site2.bitrix.zjf(定制后的bitrix代码)

准备

  1. 首先需要把需要共享的核心放到共享目录(mv),比如:/var/www/shared/,包括bitrix, upload文件夹

    mv /var/www/html/bitrix /var/www/shared/bitrixmv /var/www/html/upload /var/www/shared/upload
  2. 创建新的站点文件夹(/var/www/html2/),主站目录为:/var/www/html/
  3. 映射共享文件到站点文件夹

    ln -s /var/www/shared/bitrix /var/www/html/ln -s /var/www/shared/upload /var/www/html/ln -s /var/www/shared/bitrix /var/www/html2/ln -s /var/www/shared/upload /var/www/html2/
  4. 把定制后的代码拷贝到site2(/var/www/html2/)中,注意要将.htaccess.php.access.php文件也拷贝到site2中
    • .htacess.php 文件是php 用来设置404页面路径。更多功能,点这里
    • .access.php是bitrix配置用户权限的文件,点这里
  5. 设置Apache2的VirtualHost,指定ServerName分别为两个站点的域名

    <VirtualHost *:80>    ServerAdmin admin@site1.com    DocumentRoot "/var/www/html/"    ServerName site1.com    ServerAlias *.site1.com    <Directory "/var/www/html">    Require all granted    </Directory>    ErrorLog logs/site1.log    CustomLog logs/site1.log  common</VirtualHost><VirtualHost *:80>    ServerAdmin admin@site2.com    DocumentRoot "/var/www/html2/"    ServerName site2.com    ServerAlias *.site2.com    <Directory "/var/www/html2">    Require all granted    </Directory>    ErrorLog logs/site2.log    CustomLog logs/site2.log  common</VirtualHost>
  6. /etc/apache2/sites-available/ 新建的*.conf文件 软连接到 /etc/apache2/sites-enabled 中,重启Apache2服务;

    sudo ln -s /etc/apache2/sites-available/*.conf /etc/apache2/sites-enabled/sudo service apache2 restart
原创粉丝点击