Hi, i am close to launching a site i have been working hard on for the past while. The site is developed in PHP.
I have been developing the site on a VPS with one hosting company (A) and now i have moved the live site to a new better hosting company (B) (i won’t go into why they are better)
Ok, so i was thinking of running with the following set up:
- development environment on VPS with hosting company A
- test environment with new hosting company B
- live site with new hosting company B
This means i have to pay 2 hosting companies quite a lot of money per month, which is not a huge problem if needed… but do you think i would be ok running with just hosting company B and running the live site beside one testing and development site…
Thanks in advance for any advice you can offer on this subject, it is much appreciated…
This really depends on a lot of factors - how many people working on the website and, of course, the nature of your website.
For a single-developer website, I would stick with having a development environment locally, with a manual SVN linked to a testing subdomain. Edit on your local PC, then if you’re happy that it doesn’t cause any errors, commit the changes. Then when you’re happy with it, copy over to the main domain.
I’d say the main domain and the test environment should be the same domain, but different subdomains - unless you utilise subdomains as part of your website’s functionality. I would also then recommend that the domain and test root directories should be on the same server (preferably siblings of a common parent directory), which would make the process of copying the files over from the testing website to the main website more convenient (and faster).
Ok cool, thanks i was also thinking that it would be a good idea to do as you mentioned above, thanks
I agree with @Jake_Arkinstall ; and I do a similar setup (using SVN, but I hear GIT is great for this too).
I develop and test locally, once I’m happy, I move it to a test subdomain (that is password protected and has bot crawling disabled), this is just to ensure that my changes run on the actual hosting server (in case they have PHP or Apache configured differently than my local machine). Once I’m happy with the test, I push it to the live site.
Things to keep in mind:
- Any files that need to change between the environments, such as configurations, keep out of SVN or write up a script that will update them to the correct values for each environment you deploy to.
- Make sure your repository is private as to not show any of your code to outsiders (especially if you have configuration settings in it!)
- Document any difference you find between your server and the test environment, then make those changes to your local environment so you are closer to running what is on the test and live environments (this will save you a lot of time later on)
Thanks guys, my only worry is that setting up SVN or GIT means i have to weaken the file permissions on the actual main server. If i want GIT to be able to write into the webfolder then the access rights must allow that.
Not necessarily. I actually have bash scripts I run for deployment. The one for the test environment, will export the latest from the SVN, and copy it to the test web directory.
Production’s simply copies the files from the test environment to the production folder. That way you can lock it down with different accounts, and give those accounts ownership of the scripts.
Ok cool, thanks i will have a look into this, cheers
The other way to do this securely is to use openvpn on port 443. Most hosts enable this port as it is for SSL. It is fairly easy to install and there are clients for your phone or whatever computer you have locally.
Once you get this setup you can enable password-less SSH access. You can easily upload a certificate public key to the server. Then with a simple bash script added to Git’s post-receive hook. It then allows you to use a one command push using ‘git push…’ to get your local Git repository synching up to your web-server repository.
In the next couple of weeks SitePoint is publishing a free Git tutorial. In the appendix we show how to do all of this with the exception of the VPN which this doc does not show.
It is nice to have a mirrored repository on you server as it allows you to roll back files or a complete version of your site.
This may sound hard, but going step by step it is not too bad.