我刚刚使用一堆脚本创建了我的第一个Rightscale ServerTemplate和Deployment。我创建的脚本之一是将虚拟主机添加到apache。在不同输入的ServerTemplate上多次使用相同的脚本
#!/bin/bash -e
if [ $RS_DISTRO = ubuntu ]; then
export apache=apache2
export apache_extra_conf_dir=/etc/apache2/conf.d
elif [ $RS_DISTRO = centos ]; then
export apache=httpd
export apache_extra_conf_dir=/etc/httpd/conf.d
fi
server_name=$SERVER_NAME
echo "Adding virtual hosts to ${apache_extra_conf_dir}/vh-${server_name}.conf"
cat > $apache_extra_conf_dir/vh-${server_name}.conf <<EOF
NameVirtualHost $SITE_IP:$SITE_PORT
<VirtualHost $SITE_IP:$SITE_PORT>
ServerName $SERVER_NAME
ServerAlias $SITE_DOMAIN *.$SITE_DOMAIN
UseCanonicalName Off
ServerAdmin $ADMIN_EMAIL
DocumentRoot $APACHE_WWW_DIR
<Directory "$APACHE_WWW_DIR">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF
service $apache restart
exit 0
我的问题是,我可以使用相同的Rightscript两次在ServerTemplate但每个(IP,端口,WWW目录和服务器名)设置不同的投入?例如。
ServerTemplate:
Execute Rightscript vhost: *:80 /www-x/ x.com
Execute Rightscript vhost: *:80 /www-y/ y.com
或做我必须创建一个特殊的Rightscript只是有在同一个脚本定义这两个虚拟主机这个服务器部署?
Execute Rightscript vhost: *:80 /www-x/ x.com | *:80 /www-y/ y.com
太棒了,谢谢你的信息。 – 2012-03-31 23:10:29
很好的答案。谢谢! – slik 2012-06-11 14:33:02