Wednesday, January 31, 2007

Local CCC

Getting a local copy of our website on my Ubuntu box for development purposes:

Local files:

We use svn on our church website as a versioning system and I need a local version for testing and development. First thing is to get a local copy of the repro and then add non-repro files (images etc).
sudo apt-get install subversion subversion-tools
The problem I have is remembering the repro address. Make sure that you're in /home/ccc
svn checkout
svn checkout
The checkout happens and the path /home/ccc/htdocs/ should be correct. SVN doesn't cope with symbolic links at present - need to add them for pgadmin and lib/v1/

Get the postgres login details for the local filesystem.
Get a copy of the htpwd and htusergroup files.
Get a copy of the /image directory
Get a copy of all the xml and dbf files - they aren't in svn
~$ find -name *.xml | xargs tar rvf xml.tar
~$ find -name *.dbf | xargs tar rvf xml.tar
Then comes the setup of apache.
sudo apt-get install apache2
Move the previously saved apache config to /etc/apache2/sites-available/ and enable the setup.
sudo a2dissite 000-default
sudo a2ensite ccc
sudo /etc/init.d/apache2 restart
Then we need to install PHP with dbase.

Finally, comes the addition of postgres - make sure the correct version is installed!
sudo aptitude search postgres
sudo apt-get install postgresql-8.1
sudo apt-get install phppgadmin pgadmin3
The other option would be to get the latest version of phppgadmin and install it in /usr/share/phadmin with a symbolic link from /admin/pgadmin.

Connect to the CCC postgres db. Post 5432 is the standard port for postgres communication, but is closed on the CCC server. Set up a tunnel to it, but don't use port 5432 because we'll be running a local server on that port. SSH keys should be in place for passwordless login.
ssh -L5431:localhost:5432
Setup pgAdminIII to connect to the remote server using localhost:5431

Start to setup the local postgres server. First thing is to create a user.
~$ sudo su postgres -c createuser yourusername
~$ sudo su postgres -c psql yourusername
=# ALTER USER yourusername WITH PASSWORD 'yourpassword';
=# \q
Setup pgAdminIII to connect to the local server using localhost:5432

Get a local copy of the postgres database.
~$ pg_dump database_name > database
~$ tar -cf database.tar database
~$ scp database local_machine:

~$ createdb master
~$ tar -xf database.tar
~$ psql -d master
Or, if you need to get the data from the entire server, use:
~$ pg_dumpall -d > pg_server
~$ psql -f pg_server postgres
Irritatingly, it will ask for your password for every transaction. ie., for every database that is dumped!

That should be us done... have a quick test.

No comments: