博客园 首页 私信博主 显示目录 隐藏目录 管理 动画

apache 虚拟主机脚本

#!/bin/sh
########################################
#this is created liang
#liang:QQ:1249648969            
#blog:http://www.o2oxy.cn
########################################
APACHE_CONFIG=/usr/local/apache/conf
DocumentRoot=/var/html

echo "------- step 1.make site dir "
for dir in www blog bbs wiki
do
mkdir -p $DocumentRoot/$dir
echo "$dir" >>$DocumentRoot/$dir/index.html
done 

echo "------- step 2 apache httpd.conf"
cp -p  $APACHE_CONFIG/httpd.conf $APACHE_CONFIG/httpd.conf.bak2
sed -i 's#\#Include conf/extra/httpd-vhosts.conf#Include conf/extra/httpd-vhosts.conf#g' $APACHE_CONFIG/httpd.conf

cat >>$APACHE_CONFIG/httpd.conf<<EOF
<Directory "$DocumentRoot">
      Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
EOF
cat >$APACHE_CONFIG/extra/httpd-vhosts.conf <<EOF
NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin 124964896@qq.com
    DocumentRoot "${DocumentRoot}/www"
    ServerName  www.lkq.com
    ErrorLog " /usr/local/apache/logs/lkq.com-error_log"
#    CustomLog "logs/lkq.com-access_log" common
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_www_%Y%m%d.log" combined  
ExpiresActive on
ExpiresDefault "access plus 12 mounth"
ExpiresByType text/html "access plus 12 months"
ExpiresByType text/css "access plus 12 months"
ExpiresByType image/gif "access plus 12 months"
ExpiresByType image/jpg "access plus 12 months"
ExpiresByType image/png "access plus 12 months"
ExpiresByType /usr/local/apache/x-shockwave-flash "access plus 12 months"
ExpiresByType /usr/local/apache/x-javascript "access plus 12 months"
ExpiresByType video/x-flv "access plus 12 months"
<ifmodule mod_deflate.c>
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE /usr/local/apache/javascript
AddOutputFilterByType DEFLATE text/css
</ifmodule>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin 124964896@qq.com
    DocumentRoot "${DocumentRoot}/bbs"
    ServerName  bbs.lkq.com
    ErrorLog " /usr/local/apache/logs/bbs.com-error_log"
#    CustomLog "logs/lkq.com-access_log" common
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_bbs_%Y%m%d.log" combined
ExpiresActive on
ExpiresDefault "access plus 12 mounth"
ExpiresByType text/html "access plus 12 months"
ExpiresByType text/css "access plus 12 months"
ExpiresByType image/gif "access plus 12 months"
ExpiresByType image/jpg "access plus 12 months"
ExpiresByType image/png "access plus 12 months"
ExpiresByType /usr/local/apache/x-shockwave-flash "access plus 12 months"
ExpiresByType /usr/local/apache/x-javascript "access plus 12 months"
ExpiresByType video/x-flv "access plus 12 months"
<ifmodule mod_deflate.c>
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE /usr/local/apache/javascript
AddOutputFilterByType DEFLATE text/css
</ifmodule>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin 124964896@qq.com
    DocumentRoot "${DocumentRoot}/blog"
    ServerName  blog.lkq.com
    ErrorLog " /usr/local/apache/logs/blog.com-error_log"
#    CustomLog "logs/lkq.com-access_log" common
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_blog_%Y%m%d.log" combined
ExpiresActive on
ExpiresDefault "access plus 12 mounth"
ExpiresByType text/html "access plus 12 months"
ExpiresByType text/css "access plus 12 months"
ExpiresByType image/gif "access plus 12 months"
ExpiresByType image/jpg "access plus 12 months"
ExpiresByType image/png "access plus 12 months"
ExpiresByType /usr/local/apache/x-shockwave-flash "access plus 12 months"
ExpiresByType /usr/local/apache/x-javascript "access plus 12 months"
ExpiresByType video/x-flv "access plus 12 months"
<ifmodule mod_deflate.c>
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE /usr/local/apache/javascript
AddOutputFilterByType DEFLATE text/css
</ifmodule>
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin 124964896@qq.com
    DocumentRoot "${DocumentRoot}/wiki"
    ServerName  wiki.lkq.com
    ErrorLog " /usr/local/apache/logs/wiki.com-error_log"
#    CustomLog "logs/lkq.com-access_log" common
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache/logs/access_wiki_%Y%m%d.log" combined
ExpiresActive on
ExpiresDefault "access plus 12 mounth"
ExpiresByType text/html "access plus 12 months"
ExpiresByType text/css "access plus 12 months"
ExpiresByType image/gif "access plus 12 months"
ExpiresByType image/jpg "access plus 12 months"
ExpiresByType image/png "access plus 12 months"
ExpiresByType /usr/local/apache/x-shockwave-flash "access plus 12 months"
ExpiresByType /usr/local/apache/x-javascript "access plus 12 months"
ExpiresByType video/x-flv "access plus 12 months"
<ifmodule mod_deflate.c>
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE /usr/local/apache/javascript
AddOutputFilterByType DEFLATE text/css
</ifmodule>
</VirtualHost>
EOF

 

posted @ 2017-11-05 22:33  crazy_py  阅读(162)  评论(0编辑  收藏  举报