In my situation my SVN server and web server are running on the same machine. Assume you want your document root to be located at /home/ubuntu/repository201207/ and the user that runs the web server is called www-data. Follow the following steps.
Make sure you don't have any directory in the SVN project that the web server needs to write to. Let's say your SVN project contains a folder called log and the web server is programmed to write to log/. Since you check out the SVN project as ubuntu log/ will be owned by ubuntu and www-data may not be able to write to it. One way to solve this conflict is remove log/ from source control.
Step 1: Checkout Files
If you are checking out the SVN project locally then here's the command:
% svn co file:///svnrepos/repository /home/ubuntu/repository201207
If you are checking out the SVN project remotely then here's the command:
% svn co svn+ssh://ubuntu@23.2.1.2/svnrepos/repository /home/ubuntu/repository201207
SVN does NOT store files in a form readable to your apache. Project files will be stored in a database managed by the SVN program.
Step 2: Adjust Owner and Group of Your Files
When you check out the repository you are getting the same set of permissions as the original, existing directory, but the owner and group of every file becomes ubuntu. You need to adjust owner and group of some of the files as appropriate. For example if your web server's user is www-data and it writes to some log directory or cache directory you need to use 'chown' command to set owner and group of these directories properly! The completion of this step is web server specific. Here's the Unix command to change owner and group of log folder to www-data recursively:
sudo chown -R www-data:www-data log
NOTE: You MUST keep the owner of .svn/ and every file in .svn/ ubuntu to avoid permission related issues when you run 'svn update' as ubuntu! A great Unix command to perform this task recursively is:
find . -type d -name .svn -exec sudo chown -R ubuntu:ubuntu {} \;
Step 3: Change Your Web Server's Document Root
Make your web server point to /home/ubuntu/repository201207 directory and restart your web server. The way this is set depends on what web server you have. I am using Nginx and here's what my /etc/nginx/sites-available/mffl has:
server { listen 80; server_name photo.mensfashionforless.com; rewrite_log on; access_log /home/ubuntu/webserver-log/mffl/access.log; error_log /home/ubuntu/webserver-log/mffl/error.log error; location / { root /home/ubuntu/image/mffl/; } }From now on you can make changes remotely and commit your changes via SVN, and log into your web server and run 'svn update' in /home/ubuntu/repository201207/ to get latest changes, and they should be reflected on your website right away!
If you run into any 'Permission Denied' issue while running some SVN command it's probably because some .svn directory or some file in that directory has www-data or someone other than ubuntu as the owner. You should adjust the ownership of the folders/files in question. If your web server does not need to write anything in the working copy, then simply go to the root of the working copy and run this command to make everything owned by ubuntu:
find . -type d -name .svn -exec sudo chown -R ubuntu:ubuntu {} \;
If you have any questions let me know and I will do my best to help you!
◀ Import a Directory into SVNCheckout an SVN Project In Eclipse ▶