So, to this point I have a xen master server with a xen slave instance. The slave instance is actually a virtual server with the purpose of hosting subversion and trac. The next component every network needs is a db server. This should be a painless process since I had documented the steps while creating the first instance. I will do the same for this instance just to see what steps overlap and what steps are independent to the build. This will also help me determine the common commands for creating/starting a new xen slave instance; which I will later document as well.
*The LAMP (Linux, Apache, MySQL, PHP) installation instructions were gathered from HowToForge
Create Xen Server
xen-create-image --hostname=mysql.scratchco.com --size=10Gb --swap=512Mb --ide \
--ip=10.0.0.2 --netmask=255.0.0.0 --gateway=10.0.0.254 --force \
--dir=/vserver --memory=512Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.18-xen \
--debootstrap --dist=etch --mirror=http://ftp.us.debian.org/debian/ --passwd
Start Server
xm create /etc/xen/mysql.scratchco.com.cfg
Configure to Start at Boot
ln -s /etc/xen/mysql.scratchco.com.cfg /etc/xen/auto
SSH into Server
ssh 10.0.0.2
Edits Hosts
vim /etc/hosts
and change
192.168.0.101 svn.scratchco.com
to
10.0.0.1 svn.scratchco.com
* I am not sure why this needs to be changed, I will research this issue and update the post when I have a better solution
Install Dependencies
apt-get update
apt-get upgrade
apt-get install vim-full
apt-get install build-essential
apt-get install locales
dpkg-reconfigure locales
select en_US.UTF-8
/usr/bin/tzconfig or /usr/sbin/tzconfig
Select time zone
Install MySQL
Install packages
apt-get install mysql-server mysql-client libmysqlclient15-dev
Edit Configuration File
vim /etc/mysql/my.cnf
comment out
...
#bind-address = 127.0.0.1
...
Setup User
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h mysql.scratchco.com -u root password yourrootsqlpassword
Give Permissions
GRANT ALL PRIVILEGES ON *.* TO root@'localhost' IDENTIFIED BY 'root-password'
Install Apache/PHP5
Install Apache
apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
Install PHP
apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-json php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl phpmyadmin
Install Apache Modules
a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include
Configure Master Server
Open iptables
vim /etc/network/if-up.d/iptables
and add this line to forward all requests on port 3306 to our new server
iptables -A PREROUTING -t nat -p tcp -i eth0 --dport 3306 -j DNAT --to 10.0.0.2:3306
Create VirtualHost
create new file
vim /etc/apache2/sites-enabled/mysql.scratchco.com
and add
<VirtualHost *>
# Basic setup
ServerAdmin jacob@scratchco.com
ServerAlias mysql.scratchco.dnsalias.com
Servername mysql.scratchco.dnsalias.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://10.0.0.2/
ProxyPassReverse / http://10.0.0.2/
</VirtualHost>
Configure DB Server
Now we have to configure the db server to default to phpmyadmin when accessed from the web. First we need to delete the web directory and create a symbolic link to the phpmyadmin directory which was installed with apt-get.
rm -rf /var/www/
ln -s /usr/share/phpmyadmin/ /var/www
Second, we must edit the default virtualhosts to make /var/www the root content for htttp://mysql.scratchco.(dnsalias).com/
vim /etc/apache2/sites-available
and comment out
...
# RedirectMatch ^/$ /apache2-default/
...