What is the best and most efficient way to set up two versions of the same websi
ID: 651538 • Letter: W
Question
What is the best and most efficient way to set up two versions of the same website?
I want one version that is online and open for everyone to use but I also want a developer version where I can develop and test new things instead of doing that against the ftp.
Currently I have MAMP setup on my developing machine and I use Git for version control.
In MAMP/XAMPP the location for the files are localhost/example/ and on the ftp it is the host's (Dreamhost's in this case) file structure. Something like /home/username/example.com/. That results in having multiple versions of pretty much the same file. This isn't that efficient but I can't come up with a good solution for it. Are there any?
It would be perfect if I wanted to add a new feature to the website I could do that in MAMP and when i commit the changes with Git it uploads the changes to the ftp.
Explanation / Answer
what I do with XAMP is that I have on my local an entry called a.com that points to my 127.0.0.1
so i reference pages as a.com/....
Keep the same files in both the places. have some custom include that checks if the current page has a.com and makes root links differently. Something like :
if( $_SERVER['SERVER_NAME'] == 'a.com'){
$filePath = 'images/'
$url = "http://a.com";
$env = 'd';
}else{
$imgPath = '/home/sites/example/images/'
$path2 = "http://example.com";
$env = 'p';
}
//now this can be an include file in other files
//in the other files just use the previously initialized variables when making paths and URLs. This keeps the code in the main files simple and the details in one file