歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> Linux:一台apache服務器上部署多個項目的apache配置

Linux:一台apache服務器上部署多個項目的apache配置

日期:2017/3/1 12:23:42   编辑:關於Linux
第一步: 將代碼取到/var/www/html目錄下(此為默認目錄,具體看apache的設置);該目錄下可以放多個項目,如:
[root@www html]# pwd
/var/www/html
[root@www html]# ls
bossmail.cn  bossq.cn  oem  ydj.org  yzhantong  
第二步:
vim /usr/local/apache/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/var/www/html/bossq.cn"
    ServerName test.bossq.cn
    ServerAlias bqapi.bossq.cn
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/var/www/html/ydj.org"
   ServerName ydj.org
   ServerAlias www.ydj.org
   ErrorLog "logs/ydj.org-error_log"
  CustomLog "logs/ydj.org-access_log" common
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/var/www/html/oem"
   ServerName yzt241.com
   ServerAlias www.yzt241.com
   ErrorLog "logs/oem-error_log"
  CustomLog "logs/oem-access_log" common
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/var/www/html/yzhantong"
   ServerName cnh.cn
   ServerAlias www.cnh.cn
   ErrorLog "logs/cnh.cn-error_log"
  CustomLog "logs/cnh.cn-access_log" common
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/var/www/html/bossmail.cn"
   ServerName bossmail.cn
   ServerAlias test.bossmail.cn
   ErrorLog "logs/cnh.cn-error_log"
  CustomLog "logs/cnh.cn-access_log" common
</VirtualHost>

第三步: 本地電腦的hosts文件添加解析,如: 192.168.148.18 test.bossmail.cn 打開浏覽器輸入:test.bossmail.cn或者bossmail.cn即可訪問
Copyright © Linux教程網 All Rights Reserved