简体   繁体   English

开发环境 - 从开发到登台服务器到生产的VCS

[英]Development environment - VCS from development to staging server to production

I've read a number of topics in the same sort of ballpark as this one, but in all honesty I'm still not exactly sure on the best approach (as a starting point). 我已经阅读了与此类相同类型的球场中的一些主题,但是说实话,我仍然不能确定最佳方法(作为起点)。 I am a solo developer in a small office and I have around 30 websites which are hosted on a linux VPS. 我是一个小型办公室的独立开发人员,我有大约30个网站,这些网站都是在Linux VPS上托管的。 I want to start using using version control (probably SVN) and also set up a staging server. 我想开始使用版本控制(可能是SVN)并设置登台服务器。 At the moment, I do development either locally on my machine before using FTP to upload to the live server, or ocassionally for small changes I edit the remote files directly, which is not an ideal approach. 目前,我在使用FTP上传到实时服务器之前在我的机器上本地进行开发,或者偶尔进行小的更改我直接编辑远程文件,这不是一种理想的方法。

I'm looking for some guidance on how to improve my development environment. 我正在寻找有关如何改善我的开发环境的一些指导。 I imagine I should be installing SVN on the web server, which would then allow me to check out versions to my local machine (which would also require SVN i think). 我想我应该在Web服务器上安装SVN,这样我就可以查看本地机器的版本(我认为这也需要SVN)。 Also, if I want to set up a staging server, should I just set up subdomains for each of the live websites, then use these subdomains for showing clients changes to the site before making them live? 另外,如果我想设置一个临时服务器,我应该只为每个实时网站设置子域名,然后使用这些子域名来显示客户端对网站的更改,然后再将它们生效吗?

Hope this makes sense! 希望这是有道理的!

This is what we do at work: 这就是我们在工作中所做的事情:

We have a staging server running Apache and a Subversion server. 我们有一个运行Apache的登台服务器和一个Subversion服务器。 We have a post commit hook that updates a working copy in the htdocs directory, that way, when a developer commits something it automatically gets updated on the staging server, so everyone can see the latest code. 我们有一个post commit钩子来更新htdocs目录中的工作副本,这样,当开发人员提交一些它会在登台服务器上自动更新时,所以每个人都可以看到最新的代码。

On the client's production servers (the ones we can control) we have the Subversion client installed and the website is a working copy. 在客户端的生产服务器(我们可以控制的服务器)上,我们安装了Subversion客户端,并且网站是一个工作副本。 When we need to update the live site we login to a shell and run svn up . 当我们需要更新实时站点时,我们登录到shell并运行svn up If you do something like this, make sure to limit access to the .svn directories, either with .htaccess files or from the main Apache config. 如果您执行此类操作,请确保使用.htaccess文件或主Apache配置限制对.svn目录的访问。

We have a custom app that manages the projects, but that is only because we're lazy and don't want to setup each project by hand, the app creates the necessary directories and working copies. 我们有一个管理项目的自定义应用程序,但这只是因为我们懒惰而且不想手动设置每个项目,应用程序创建必要的目录和工作副本。 You could write a quick script to do this. 您可以编写一个快速脚本来执行此操作。

We never, ever , edit files via FTP on the live site. 我们永远, 永远 ,通过FTP直播网站上编辑文件。 All in all we have been using this setup for almost 2 years and aside from the occasional conflict on the staging server, we never have had any problems. 总而言之,我们已经使用这个设置将近2年,除了临时服务器上偶尔的冲突,我们从来没有遇到任何问题。

You can actually install the SVN server on your local machine, which I would recommend in lieu of installing it on the web server (assuming you make backups). 您实际上可以在本地计算机上安装SVN服务器,我建议将其安装在Web服务器上(假设您进行备份)。 The easiest thing to do, since it's only you using it, would be to use the file:// protocol, but using svnserve is a little more robust, and the preferred method if you want to take the time to do it. 最容易做的事情,因为只有你使用它,才会使用file://协议,但是使用svnserve会更加健壮,如果你想花时间去做,那就是首选的方法。

@Michael, I disagree - I would say it's better to install on the linux vps, especially if you are already paying for the hosting service. @Michael,我不同意 - 我会说最好安装在linux vps上,特别是如果你已经为托管服务付费了。 I find it very helpful to be able to browse and download stuff from my svn repo wherever I am, from whatever computer I'm on. 无论我在哪里,无论我在哪台计算机上,我都能从我的svn repo中浏览和下载内容。

@nicky, I started with svn (and version control) several years ago and I took baby steps which made it easier to tackle. @nicky,几年前我开始使用svn(和版本控制),我采取了婴儿步骤,这使得它更容易解决。

If I had to do it over again, I'd read the svn book to start with. 如果我不得不再做一次,我会先阅读svn书 The book is very well laid out and didn't take more than 1-2 days to plow thru. 这本书布置得非常好,并且通过犁过的时间不超过1-2天。

While you're reading, install svn on your linux vps with an apache front end . 在您阅读时,请使用apache前端在Linux vps上安装svn。

Once you have that up, pick one of your websites and import it into svn. 完成后,选择一个网站并将其导入svn。 This is how I structure my svn repo. 这就是我构建svn repo的方式。 For example, say my repo is hosted at http://mysvn.mydomain.com/svn/ : 例如,假设我的仓库托管在http://mysvn.mydomain.com/svn/

  mywebsite1
     - trunk
     - tags
     - branches 
  mywebsite2
     - trunk
     - tags
     - branches 

Don't worry about creating the perfect structure. 不要担心创造完美的结构。 It's pretty easy to re-organize especially when you're starting out. 重新组织起来很容易,特别是在你刚开始的时候。 After you import a few projects into svn, you'll start to get a feel for which projects should have their own "trunk/tags/branches" dir structure and which can be combined. 在将几个项目导入svn之后,您将开始了解哪些项目应具有自己的“主干/标记/分支”目录结构,哪些项目可以组合。

For creating test environments, I do exactly what you describe. 为了创建测试环境,我完全按照您的描述进行操作。 I use build scripts to checkout from svn and download files into dirs that are mapped to subdomains like "test.clientsite.com" (I work primarily in java and use ant and maven, but I think you can use whatever scripting language you're familiar with). 我使用构建脚本从svn签出并将文件下载到映射到子域的dirs,如“test.clientsite.com”(我主要在java中工作并使用ant和maven,但我认为你可以使用任何脚本语言你是熟悉)。

Once you get used to version control, you'll never go back, good luck! 一旦你习惯了版本控制,你永远不会回去,祝你好运!

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

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