如何使用Rex管理你的服务器?(1)(5)
首先,更换到website项目目录。
wks01 database# cd ../website
wks01 website# touch Rexfile
首先,我们同样需要在此定义外部版本库。
wks01 website# svn propedit svn:externals .
把下列几行添加到编辑器中,保存并关闭。
lib/Common http://svn01/svn/common
lib/Service http://svn01/svn/service
在建好外部版本库之后,运行更新,提交新的设置。
wks01 database# svn up
wks01 database# svn ci -m "added external repositories"
svn up命令现在检查两个外部版本库,检查有无更新。所以,如果有人往这其中一个版本库添加了新服务,你在执行svn up命令后获得新服务。现在,你可以开始创建Rexfile,建立web服务器。
# Rexfile
set user => "root";
set password => "test";
include qw/
Common::NTP
Service::Apache
/;
set group => srvweb => "web01";
task "prepare", group => "srvweb", sub {
# 运行常见ntp任务“prepare”
Common::NTP::prepare();
# 安装apache
Service::Apache::prepare();
# 配置apache
Service::Apache::configure({
timeout => 60,
});
#重新启动apache
service apache2 => "restart";
};
保存文件,并保存到版本库。
wks01 website# svn add Rexfile
wks01 website# svn ci -m "initial Rexfile"
现在,你可以准备用下列命令来创建web服务器了。
wks01 website# rex prepare
你创建好了数据库和web服务器后,就可以准备部署应用程序了。比如说,如果你从开发团队获得了一个ZIP或TAR压缩文档,可以往Rexfile添加第二个任务,以此部署应用程序。
task "deploy", group => "srvweb", sub {
upload "your-web-application.tar.gz", "/tmp";
extract "/tmp/your-web-application.tar.gz",
owner => "www-data",
group => "www-data",
to => "/var/www";
rm "/tmp/your-web-application.tar.gz";
};
评论暂时关闭