你必須爲此創建一個conf文件。
它可以自動創建使用SH文件,如下
#!/bin/bash
if [ "x${1}" = "x" ]; then
echo "User is not specified"
exit 1
fi
if [ "x${2}" = "x" ]; then
echo "Domain is not specified"
exit 1
fi
if [ "x${3}" = "x" ]; then
echo "Domain is not specified"
exit 1
fi
/bin/echo ${1}${2} | /bin/egrep -q ';|`|\||>'
if [ $? -eq 0 ]; then
echo "Bad parameter"
exit 1
fi
/bin/cat > /etc/httpd/vhost.d/${1}.${2}.conf <<EOF
<VirtualHost *:80>
DocumentRoot /home/user/www.${2}/htdocs
ServerName ${1}.${2}
ServerAlias ${3}
ServerAdmin [email protected]
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /home/user/www.${2}/htdocs
ServerName ${1}.${2}
ServerAlias ${3}
ServerAdmin [email protected]
SSLEngine on
SSLCertificateFile /etc/httpd/conf/ssl.crt/example.com.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/example.key
SSLCACertificateFile /etc/httpd/conf/ssl.crt/example.crt
</VirtualHost>
EOF
service httpd restart
echo "Vhost has been added"
exit 0
路徑和指定的電子郵件可以根據自己的配置被修改,並與「一vhost_gen.sh將其保存在/ usr /本地/ bin /' 或任何你喜歡的地方。
,如果你想給任何真正的域別名到子域名稱CakePHP中該SH文件
$subdomain_name = 'xyz';
$domain_name = 'domain.com';
$real_domain_name = 'xyz.domain.com';
exec ("/usr/local/bin/vhost_gen.sh ".$subdomain_name." ".
$domain_name." ".$real_domain_name);
$ real_domain_name是ServerAlias。
本文可能會幫助你http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database –