How to use svn on real apache server?

I am new to SVN and something is stuck. For the longest time, Ive developed websites locally (setting up MAMP), and then ftp the whole site worked when it was ready. Any small additional changes that I make directly on the live site, and so often, I will reload all the files on the live server to my localhost (since I can never remember all the files that I changed). Obviously, this is not the best way to do something. I was curious how I can configure SVN on a real web server, so every change I make locally will be clicked on the website when I talk about it. Where can I create the svn repository? /Domain.com/www/svn? Can I create a www directory as an actual repo, and if so, is this a bad practice?

+8
svn apache
source share
2 answers

Do not create a repository in the web server directory! This is the first part of your problem.

Your repository can live anywhere, just do not put it in the web server directory.

When you configure Apache httpd (if that is what you are using), install it to ignore .svn folders as follows:

<DirectoryMatch \.svn> Order allow,deny Deny from all </DirectoryMatch> 

Now, somewhere else besides your web server, create a Subversion repository. Place an order from this repository in the working directory in a different place, and not in your web server directory. Now you can import all the files that will be in your repository and transfer them to the Subversion repository.

Once you do this, you can go to your web server directory where you want these files to be displayed, and do a check.

You should have three things:

  • Subversion repository that does not belong to your web server .
  • The working directory containing all of your files on your website is not on your web server .
  • The working directory located in your web server directory.

The plan is this: you make changes to the working directory, which is not in the directory of your web server. Here you can conduct testing and make your changes here. You also perform all your tests here.

Once you are satisfied with everything, you can do svn update in the Subversion working directory, which is located in your web server directory. This way you do your work outside of the web server, check, and then do svn update in the web server directory.

If you want to get really fantasy, you can create a web branch that will represent the code in your web server directory. Then you can check your code and whatever you want. When you are ready to implement it on your website, you can combine it with a web branch. When you update the working directory in your web server, it pulls the code only to the web branch.

In fact, you can automate this process with a kind of cronjob. You move your website down, update the subversion working directory in your web server directory, and reload your website. This ensures that the files that the web user is looking for are not modified from under them.

+7
source share

I would set the structure in your svn checkout (in your local field), which corresponds to the files that need to be stored (and does not necessarily correspond to the server structure), for example:

 my-project my-project/docs/README.txt (any documentation you want to write) my-project/www/index.html (etc) 

etc. Then

(1) If you have access to running commands on the server, I must log in and execute, for example:

 cd /domain.com rm -rf www svn co https://svn.myserver.com/my-project/www www 

(2) Otherwise, I checked the files on your local computer and transferred them ftp to the server.

Option (1) is better, but even with option (2) you have advantages over your current setup. If you change files on the server, you can return the entire directory back to the local field in a new directory, and then β€œcommit” the files to the subversion server. Subversion (with the .svn directories that you need to copy to / from the server) will know which files you changed.

+1
source share

Source: https://habr.com/ru/post/651035/


All Articles