Auto-Update SVN on Media Temple (gs)
Tags: Media Temple, Linux | on 9/10/08

I wanted to update SVN every 5 minutes on my Media Temple grid service (gs) account. Here is the steps I took to make that happen.
First, I created a shell script with the SVN Update (I'll show how in a minute). I got this error:
Error validating server certificate
For some reason SVN wasn't reading my trusted server list, so I asked (mt) about it.

Josh Kline at Media Temple pointed out the issue. I'm not sure why this isn't documented somewhere, so I'm blogging it.
SVN looks for the config, including the trusted server list, in
$HOME/.subversion
Your cron jobs run withHOME=/home/#####, but when you ssh inHOME=/home/#####/users/.home
running svn with--config-dir /home/#####/users/.home/.subversionwill fix the problem.
That said, here are the steps to get SVN to auto update every 5 minutes. SSH in, you will have to go through the steps to enable SSH.
Bash:
cd data mkdir scripts vi cron.sh
In your cron.sh, use the config command that Josh suggested (replacing ##### with your id)
Bash:
svn update SVN_PATH --config-dir /home/#####/users/.home/.subversion
Go into the (mt) control panel under Cron Jobs and configure one to run your shell script.

There you have it, you now have svn auto updating on shared hosting.
CakePHP on Media Temple (dv) 3.5
Tags: CakePHP, PHP, Linux, Media Temple | on 18/6/08

A good thing to do when deploying CakePHP websites is to load one copy of the CakePHP core files onto your server, and point all of your domains to that core directory.
Media Temple's Plesk default configuration does not let PHP access files outside the website httpdocs. So we need to configure the domain's settings to have access to the root /cake folder, or wherever you happened to put the CakePHP root files.
First, let's make a new config file in our domain. Make sure you replace domain.com with your domain.
Bash:
cd /var/www/vhosts/domain.com/conf/ vi vhost.conf
Then basically we are over riding the default settings of Plesk with our own. Setting open_basedir to allow the /cake path.
Apache:
<Directory /var/www/vhosts/domain.com/subdomains/tools/httpdocs> <IfModule sapi_apache2.c> php_admin_flag engine on php_admin_flag safe_mode off php_admin_value open_basedir "/cake:/var/www/vhosts/domain.com/subdomains/tools/httpdocs:/tmp" </IfModule> <IfModule mod_php5.c> php_admin_flag engine on php_admin_flag safe_mode off php_admin_value open_basedir "/cake:/var/www/vhosts/domain.com/subdomains/tools/httpdocs:/tmp" </IfModule> </Directory>
Now we need to reload the vhost to include that loads our new config file.
Bash:
/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=domain.com service httpd graceful
Great! Now we can have a central set of cake files and use it for each domain.
SVN Authentication and Auto Update
Tags: Media Temple, Linux | on 24/11/07
- Part 1: Media Temple Dedicated Server Setup
- Part 2: Installing Subversion on Apache
- Part 3: Subversion (SVN) Authentication and Auto Update

During the first two parts of my series on setting up a Media Temple dedicated server, I setup subversion (SVN) on apache. Now I want to show you how I setup basic authentication and a SVN hook to automatically deploy files to the server (called continuous integration). This is great because you can check in your files to SVN and see them on the server immediately.
Adding Basic Apache Authentication to your Subversion (SVN) Repository
First lets give apache access to the SVN database (the $ symbol just means it is a shell command).
Bash:
chmod g+s /svnroot/db
Now create a password file with htpasswd, name the file whatever you would like. I chose to make my file hidden by adding the period before the name.
Bash:
htpasswd -cm /etc/.htaccess yourusername
It will prompt you for your password. Now go back to your httpd.conf and than add the last four lines below to your Location code block - we are adding to what we did in part 2 of the media temple setup series.
Apache:
<Location /svn> DAV svn SVNParentPath /usr/local/svn AuthType Basic AuthName "Subversion repository" AuthUserFile /etc/.htaccess require valid-user </Location>
For security reasons, we also need to make sure and hide the .svn folders from having apache publicly display them:
Apache:
# Disallow browsing of Subversion working copy administrative dirs. <DirectoryMatch "^/.*/\.svn/"> Order deny,allow Deny from all </DirectoryMatch>
Restart apache and when you try to access SVN you should be prompted for authentication. Great, SVN is now secure! You can also add more security by adding SSL to your dedicated server.
Creating a Subversion (SVN) Hook to Auto Update Your Server
I want to automatically deploy my files to my httpdocs without having to manually go in and update the files. So to accomplish this you need to create a SVN hook that runs after every commit.
First, copy the post-commit template from your svnroot/hooks folder. And lets also use chmod to give the file rights to execute.
Bash:
cd /svnroot/hooks/ cp post-commit.tmpl post-commit chmod +x post-commit
Now we need to create a little C program. You should have GCC installed. This will compile our little C program. Create a new svnupdate.c file and put this code in. Don't forget to change the directory path: "public_html_directory"
C:
#include <stddef.h> #include <stdlib.h> #include <unistd.h> int main(void) { execl("/usr/bin/svn", "svn", "update", "/public_html_direcotry/", (const char *) NULL); return(EXIT_FAILURE); }
Complile the file with this command. It will take the whatever.c and compile it into a binary file.
Bash:
gcc -o svnupdate svnupdate.c
Try executing the binary to see if it works with the env command.
Bash:
env - ./svnupdate
Alright now copy the whatever binary into your hooks folder. And we'll also run a couple commands to give it proper priveledges:
Bash:
cp whatever /svnroot/hooks cd /svnroot/hooks chown root:root svnupdate chmod +s svnupdate
Then lets tell the post commit hook to run our binary file name, "svnupdate".
Bash:
vi /svnroot/hooks/post-commit
Inside it the post-commit hook tell it to run the binary using the absolute path:
C:
/svnroot/hooks/svnupdate
Test it out by checking in a file to subversion. It should automatically update at the directory we set in the C program.
Installing Subversion on Apache
Tags: Media Temple, Linux | on 21/11/07
- Part 1: Media Temple Dedicated Server Setup
- Part 2: Installing Subversion on Apache
- Part 3: Subversion (SVN) Authentication and Auto Update

Note on June 24, 2008: Media Temple released their (dv) 3.5 which has a new set of developer tools, subversion and yum are installed - so you should be able to skip past the first few steps. You still may need to install mod_dav apache module with, "yum install mod_dav".
How to install subversion on a Media Temple dedicated virtual (dv) 3.0 linux server.
In the first part of setting up a dedicated server with Media Temple, I found out how to install PHP5 and learned some basic linux commands. I quickly realized how difficult linux can be if you don't know what you are doing. Luckily, YUM made my life a lot easier.
YUM is helps you easily install packages with simple commands on linux. First, lets install YUM and use it to install subversion. Run these commands one-by-one:
Bash:
rpm -ivh --nodeps http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/libxml2-python-2.6.16-10.i386.rpm rpm -ivh --nodeps http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm rpm -ivh --nodeps http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/rpm-python-4.3.3-22_nonptl.i386.rpm rpm -ivh --nodeps http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm wget http://centos.mirror.vpslink.com/centos-4/4.5/os/i386/CentOS/RPMS/yum-2.4.3-3.el4.centos.noarch.rpm rpm -Uvh yum-2.4.3-3.el4.centos.noarch.rpm
To check if it is installed run this command:
Bash:
rpm -q yum
Now we need to install subversion and to run it through apache we need mod_dav_svn (apache 2 modules).
Bash:
yum install subversion yum install mod_dav_svn
I found a few articles on setting up subversion, but I'll walk you through how I got it to work. First I needed a home location, I chose to call this "svnroot".
Bash:
svnadmin create /svnroot svn mkdir file:///svnroot
Now, I want to import the httpdocs of my subdomain into the <project>/trunk. You can name your project whatever you would like. Don't forget to replace the domain, subdomain and project name in this next command:
Bash:
svn import /var/www/vhosts/<domain>/subdomains/<subdomain>/httpdocs file:///svnroot/<project>/trunk/dev -m 'Initial import of dev httpdocs'
To test that my files were imported correctly and the svn repository was created successfully, I ran this command.
Bash:
svn checkout file:///svnroot/<project>/trunk/dev #/svnwork
Vuala! - it downloaded my httpdocs to the #/svnwork directory. Now lets setup our SVN through apache. First, lets give Apache access to the folder:
Bash:
chown -R apache.apache /svnroot
Next, lets jump in the apache config and load the proper modules and set the svn location.
Bash:
vi /etc/httpd/conf/httpd.conf
Press 'i' to insert into the document and in the LoadModule section add these two lines:
Bash:
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule dav_svn_module modules/mod_authz_svn.so
And lets add the SVN location for apache to access. Careful, this does not add any authentication so you are giving free reign to your SVN server until then. Add this to your apache config:
Bash:
<Location /repos> DAV svn SVNPath /svnroot </Location>
Hit esc and than :x to quit and save the file. Restart your apache server, you should get an ok message [ok].
Bash:
/etc/init.d/httpd restart
Now download the windows subversion client and install. Let's test to see if our Apache subversion module worked. Use 'http://<server ip address>/svn to see verify it worked.
Media Temple Dedicated Server Setup
Tags: Media Temple, Linux | on 5/5/07
- Part 1: Media Temple Dedicated Server Setup
- Part 2: Installing Subversion on Apache
- Part 3: Subversion (SVN) Authentication and Auto Update

I wanted a web hosting server that I can hyper-tweak to my needs. So I opted for a dedicated server with Media Temple. I have little knowledge in linux, but I am going to embark on this road to server greatness. I want to get these things on my server to start: subversion, PHP5 and MySQL5 (PHP5 comes pre-installed now). Here I'll walk through my experience setting up my dedicated virtual (dv) server.
You have to request admin access and dev tools to be installed. So I sent a support ticket and it took a day. Here is a list of the dev tools that are installed.
Opened VI (text editor) as part of the tutorial and couldn't figure out how to get out of it once you start editing a file. So I found this article which told me to exit by hitting ESC than typing :x http://www.cs.colostate.edu/helpdocs/vi.html
Than I had to learn Putty/Linux so I looked up my commands here: http://www.ss64.com/bash/
Some good, general commands...
Bash:
ls ...list directories mkdir <name> ...create a directory rm <filename> ...remove file wget <url> ...get a package cp <file> <directory> ...copy file to directoy
That's it for day one of my dedicated server setup.