Update my website on the server
I basicly went scp with my terminal to get the website folder upto the linode server with all the files. Server and website work fine. What is the simplest way to make changes to my site? Once i edit some changes locally can i somehow again within twrminal push the same but updated folder up and it overwrites the older version leaving the new one? Or is there a way where can i get a git repo with my webfiles and do it through there? And please the simplest answers, thank you
3 Replies
You can do this with git(1) quite easily. See:
https://www.toolsqa.com/git/clone-repository-using-ssh/
You need to add configuration so that your web server does not serve the git(1) control files/directories (any file matching the regex \.git*).
You can set up apache2(8) on your laptop for testing. Set up the domain name in /etc/hosts on your laptop by adding the following entry:
127.0.0.1 yourdomain.com.local
and pointing your laptop browser to http://yourdomain.com.local . Since both the server and browser are running on your laptop, I'd eschew SSL…unless you have something in your site that requires it (in which case, you can use a self-signed certificate).
-- sw
Once i clone the repo into my virtual server on linode, wouldnt that conflict with the same name folder thats already there? Or would that overwrite it somehow?
Arrrrgghhh! "folders"… They're directories!!!!!
0. Shut down your web server.
1. Build the repository in the place you want to keep it.
git init /some/path/to/foo.git --bare
2. Go to the parent of the directory holding your website; i.e., if your website is at /another/path/to/foo, go to /another/path/to. Then
mv foo foo.orig
git clone <ssh path to foo.git> ./foo
<warning about cloning an empty repository>
cp -Rp foo.orig/* foo
cd foo
<inspect foo to make sure everything is there>
git add -A
git commit -a
<answer the commit message>
git push origin master
3. Start your web server.
4. Test your site. (your original site is in foo.orig in case it doesn't work).
On the remote (testing) machine, you can git clone your site wherever you like. You can make additions/changes/deletions as your heart desires. When you're done,
git add -A
git commit -a
<answer the commit message>
git push origin master
After this, on the webserver system,
cd /another/path/to/foo
git pull origin master
Your changes will be applied.
YMMV. I'm not responsible for any mishaps or screw-ups. You do this at your own risk.
-- sw