Restoring Web Applications for edrandall.co.uk
Section A - Install & Configure the WebServer with SSL Support
- Install the required ubuntu webserver packages
aptitude install apache2 php5 php5-mcrypt php5-curl
- Create the following webserver configuration files:
* /etc/apache2/conf.d/ejr-servers.conf
NameVirtualHost 192.168.2.2:443
* /etc/apache2/sites-available/restore.edrandall.co.uk
ServerName restore.edrandall.co.uk
<VirtualHost 192.168.2.2:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key
DocumentRoot /var/www/
<Directory "/var/www">
Order deny,allow
Deny from all
Authname "restore.edrandall.co.uk"
AuthUserFile /var/www/.htpasswd
AuthType Basic
Require valid-user
Allow from 192.168.2.
Satisfy Any
</Directory>
</VirtualHost>
* /etc/apache2/ports.conf
#We don't need to listen on port 80, only port 443 for https
<IfModule mod_ssl.c>
Listen 443
</IfModule>
- Setup the htpassd file for htaccess
htpasswd -c /var/www/.htpasswd q1w2e3r4
(Set a password for the q1w2e3r4 user when prompted)
- Setup the SSL certificates for the webserver
* Make the directory for the key, csr and certificate to go in
mkdir /etc/apache2/ssl
* Change to that directory
cd /etc/apache2/ssl
* Generate the private key
openssl genrsa -des3 -out server.key 1024
(Enter a passphrase when prompted, we’ll remove this later)
* Generate a CSR (Certificate Signing Request)
openssl req -new -key server.key -out server.csr
When prompted, enter “restore.edrandall.co.uk” for Common Name
* Remove Passphrase from Key
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
* Generate a Self-Signed Certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
* Edit the first line of /etc/hosts to look like this:
127.0.0.1 localhost restore.edrandall.co.uk
* Enable the SSL module in apache
a2enmod ssl
a2enmod default-ssl
* Enable the new site
a2ensite restore.edrandall.co.uk
* Restart apache, and test
/etc/init.d/apache2 restart
* Point firefox to
https://restore.edrandall.co.uk
* If the webserver is working OK, and you see the “it works” page, then copy the webapp directories to /var/www (you will have to install the self-signed certificate first)
- Copy all phpchain & sysadm content into /var/www from the backups
* Once the php content has been copied into /var/www, change the ownership of everything in there:
chown -R www-data:www-data /var/www/
Section B - Install Database Server
aptitude install php5-mysql mysql-server
(when prompted, set a password for the mysql root user)
-
Log onto mysql as the root user:
mysql -u root -p
-
Create the databases:
mysql> create database phpchain2;
- Create the users:
mysql> grant all on phpchain2.* to 'phpchain2'@'%' identified by 'PASSWORDGOESHERE';
mysql> grant all on sysadm2.* to 'edward'@'%' identified by 'PASSWORDGOESHERE';
(confirm with application config files in /var/www/APPNAME that mysql usernames and passwords match)
- Check the users can logon:
mysql -u phpchain2 phpchain2 -p
mysql -u edward sysadm2 -p
- Import the databases from the backups (unzip the sql files first if required):
mysql -u phpchain2 phpchain2 -p < /root/phpchain2.dump.070310.sql
mysql -u edward sysadm-p < /root/phpchain2.dump.070310.sql
- For wordpress the blog url will need to be changed in the database, otherwise the site won’t work properly:
mysql -u edward sysadm2 -p
mysql> update wp_options set option_value = 'https://restore.edrandall.co.uk/sysadm' where option_value='https://edrandall.co.uk/sysadm';
- Test the new sites: