我正在一个托管服务器上开发我的web应用程序。我使用IDE自动下载/上传我正在编辑的文件。我想设置另一台服务器(即development.domain.com),我将使用它来处理更新。完成并测试更新后,如何将所有更改(数据库方案更改、文件更改/添加/删除、系统更改到cron等)推送到发布服务器?有没有软件可以一键完成这项工作,或者我必须跟踪我所做的所有更改,然后复制文件并在生产服务器上逐个进行方案更改?谢谢
发布于 2016-03-30 13:57:05
这是一个很好的问题,许多早期开发人员都面临着这个问题。我们在StrollUp使用tomcat和Elastic beanstalk,并负责在生产机器上的部署。因此,我们可以很容易地将war文件从开发环境上传到prod。您也可以尝试一下Elastic beanstalk。一些像Laravel这样的php框架提供了像RoR这样的功能。但是,使用您自己的php代码和单实例prod服务器,您可以遵循以下指导原则:
用于生产server的
1. Once you have tested your dev code, upload the whole directory of /var/www/html/YOUR\_PROJECT (compressed ie. YOUR\_PROJECT.gz or YOUR\_PROJECT.phar) to your prod server (don't upload one by one, there are chances that some file uploads successfully, some fails)
2. Unzip the compressed uploaded file on prod server
1. Db changes might contain DDL and DML both. Best way to transfer them on prod (according to me) is to save the sqls **in sequence** that you ran on your dev environment and run them just before unzipping your compressed project on prod server.
2. Another way (not suggested, but it works for me) is to dump the whole dev database (obviously not the user or log tables) to your prod database.
1. I just copy all the cron from dev to prod. You can do it in a bash script.crontab -r #删除所有当前的cron作业
crontab cron.txt # cron.txt中列出的所有cronjob
关于上述步骤的最好部分:您可以将上述所有步骤放入一个bash脚本中并在一行中执行它。这就像你自己的软件一样,只需点击一下按钮;)我已经为自己制作了“一次点击”脚本,但它们特定于tomcat和Elastic Beanstalk。你可以看一看,它可能会给你一些如何继续的想法:AWS Deploy
最重要的:在prod server上运行sql query之前,首先对两个数据库进行db备份。一定要使用VCS (git,bitbucket是一个很好的选择)来保证所有更改的安全。
发布于 2016-03-29 06:55:31
我会考虑使用源代码控制的持续集成或持续部署解决方案。
https://stackoverflow.com/questions/36270435
复制相似问题