简体   繁体   English

PHP部署到windows / unix服务器

[英]PHP Deployment to windows/unix servers

We have various php projects developed on windows (xampp) that need to be deployed to a mix of linux/windows servers. 我们在windows(xampp)上开发了各种需要部署到linux / windows服务器混合的php项目。

We've used capistrano in the past to deploy from windows to the linux servers, but recent changes in architecture and windows servers left the old config not working. 我们过去曾使用过capistrano从windows部署到linux服务器,但最近架构和Windows服务器的变化使旧的配置无效。 The recipe works fine for the linux deployment, but setting up the windows servers has required more time than we have right now. 该配方适用于Linux部署,但设置Windows服务器需要比现在更多的时间。 Ideas for the Capistrano recipe are valid answers. Capistrano食谱的想法是有效的答案。 obviously the windows/linux servers don't share users, so this complicates it a tad (for the capistrano assumption of same username/password everywhere). 显然,Windows / Linux服务器不共享用户,因此这有点复杂(对于capistrano假设相同的用户名/密码到处)。

Currently we're using svn-update for the windows servers, which i dislike, since it leaves all the svn files hanging on the production servers. 目前我们正在为Windows服务器使用svn-update,这是我不喜欢的,因为它使所有svn文件都挂在生产服务器上。 (and we still have to manually svn-update them on windows) And manual updating of files using winscp and syncing the directories with their linux counterparts. (我们仍然需要在Windows上手动svn更新它们)并使用winscp手动更新文件并将目录与linux对应程序同步。

My question is, what tools/setup do you suggest to automatize this deployment scenario: "Various php windows/linux developers deploying to 2+ mixed windows/linux machines" 我的问题是,你建议哪些工具/设置自动化这个部署方案: “各种php windows / linux开发人员部署到2 +混合windows / linux机器”

(ps: we have no problems using linux tools or anything working through cygwin, we simply need to make deployment a simple one-step operation) (ps:我们使用linux工具或通过cygwin工作的任何东西都没有问题,我们只需要进行简单的一步操作)

edit: Currently we can't work on a all-linux enviroment, we have to deploy to both linux and windows server. 编辑:目前我们不能在全Linux环境下工作,我们必须部署到linux和windows服务器。 We can start the deploy from anywhere, but we'd prefer to be able to do it from either enviroment. 我们可以从任何地方开始部署,但我们希望能够从任何环境中进行部署。

I use 4 different approaches depending on the client environment: 我根据客户端环境使用4种不同的方法:

  1. Capistrano and similar tools (effective, but complex) Capistrano和类似工具(有效,但复杂)
  2. rsync from + to Windows, Linux, Mac (simple, doesn't enforce discipline) 从+到Windows,Linux,Mac的rsync (简单,不强制执行纪律)
  3. svn from + to Windows, Linux, Mac (simple, doesn't enforce discipline) svn从+到Windows,Linux,Mac(简单,不执行纪律)
  4. On-server scripts (run through the browser, complex) 服务器上脚本(通过浏览器运行,复杂)

There are some requirements that drive what you need: 有一些要求可以满足您的需求:

  • How much discipline you want to enforce 你想要执行多少纪律
  • If you need database (or configuration) migrations (up and/or down) 如果需要数据库(或配置)迁移(向上和/或向下)
  • If you want a static "we're down" page 如果你想要一个静态的“我们关闭”页面
  • Who can do the update 谁可以进行更新
  • Configuration differences between servers 服务器之间的配置差异

I strongly suggest enforcing enough discipline to save you from yourself: deploy to a development server, allow for upward migrations and simple database restore, and limit who can update the live server to a small number of responsible admins (where the dev server is open to more developers). 我强烈建议强制执行足够的规则来拯救自己:部署到开发服务器,允许向上迁移和简单的数据库恢复,并限制谁可以将实时服务器更新为少量负责的管理员(dev服务器开放的地方)更多开发人员)。 Also consider pushing via a cron job (to the development server), so there's a daily snapshot of your incremental changes. 还可以考虑通过cron作业(到开发服务器)进行推送,因此每天都有一个增量更改快照。

Most of the time, I find that either svn or rsync setups are enough, with a few server-side scripts, especially when the admin set is limited to a few developers. 大多数时候,我发现svnrsync设置都足够了,有一些服务器端脚本,特别是当管理员设置仅限于少数开发人员时。

This will probably sound silly but... I used to have this kind of problem all the time until I decided in the end that if I'm always deploying on Linux, I ought really to at least try developing on Linux also. 这可能会听起来很愚蠢,但...我曾经有过这样的问题,所有的时间,直到我最终决定,如果我总是在Linux上部署 ,我真的应该至少尝试也可以在Linux 开发 I did. 我做到了。 It was pain free. 它没有疼痛。 I never went back. 我再也没有回去过。

Now. 现在。 I am not suggesting this is for everyone. 我并不是说这适合每个人。 But, if you install VirtualBox you could run a Linux install as a local server on your windows box. 但是,如果您安装VirtualBox ,则可以在Windows机器上将Linux安装作为本地服务器运行。 Share a folder in the virtual machine and you can use all your known and trusted Windows software and techniques and have the piece of mind of knowing that everything is working well on its target platform. 在虚拟机中共享一个文件夹,您可以使用所有已知和可信赖的Windows软件和技术, 并且知道一切都在其目标平台上运行良好。

Plus you'll be able to go back to Capistrano (a fine choice) for deployment. 此外,您还可以回到Capistrano(一个很好的选择)进行部署。

Best of all, if you thought you knew Linux / Unix wait until you use it everyday on your desktop! 最重要的是,如果你认为你知道Linux / Unix等到你每天在桌面上使用它! Who knows you may even like it :) 谁知道你甚至可能喜欢它:)

Capistrano is the nicest deployment tool I've seen. Capistrano是我见过的最好的部署工具。 Do the architecture changes make it impossible to fix the configs so it works again? 架构更改是否无法修复配置,以便再次运行?

Why you can't use capistrano anymore? 为什么你不能再使用capistrano了?

Why you dislike svn-update? 为什么你不喜欢svn-update?

What things in your app requires an special deployment ? 您的应用中的哪些内容需要特殊部署?

您可以在配置文件上设置svn:ignore属性,以便svn update不会删除它们,然后使用svn export /target/path/来删除Subversion存储库中的.svn文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM