I have just bought a new 256Gb SSD for my Mac Book Pro to upgrade my 128Gb SSD which I installed some months ago to have a test of SSD and performance (its awesome). I took this opportunity to perform a CLEAN install of OSx Lion 10.7 leaving my original SSD in a USB caddie with 10.6 (Snow Leopard).
On my old disk I ran several development sites using Apache / PHP / MySQL using a combination of the hosts file and virtual hosts in Apache.
This blog documents the process I went through in migrating my sites from a Snow Leopard (10.6) to a new clean installation of Lion (10.7).
Tasks on Lion 10.7 Installation
First I enabled ‘Web Sharing’ under system preferences, and tested I could access http://localhost from a browser.
Next I copied my original files under /volumes/ssd/users/rob/sites to the new disk at /volumes/ssd240/users/rob/sites where rob is my user folder.
Then I backed up the default host file located in /private/etc/ and added my own aliases such as those shown below.
127.0.0.1 bizziebee
127.0.0.1 intranet
Lion seems to have a higher level of file security on file system so I had to change this on a few of my files in order to be able to modify the key configuration files in apache. So using terminal I modified the following.
cd /private/etc/apache2
sudo chmod u+w httpd.conf
cd /private/etc/apache2/extra
chmod u+w httpd-vhosts.conf
Using textwrangler which allows you to view hidden files, I opened my original httpd-vhosts.conf file and merged it into the new version. Note as my new disk had a new Volume label I had to rename these from SSD to SSD240
<VirtualHost *:80>
ServerAdmin rob.langley@me.com
DocumentRoot "/Volumes/SSD240/Users/Rob/Sites/intranet"
ServerName localhost
ServerAlias intranet
ErrorLog "/Volumes/SSD240/Users/Rob/Sites/logs/intranet_error_log"
CustomLog "/Volumes/SSD240/Users/Rob/Sites/logs/intranet-access_log" common
</VirtualHost>
Next we need to modify the default httpd.conf file.
- Enable PHP support by deleting the leading # around line 111
- Enable Virtual hosts by deleting the leading # around line 626
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/extra/httpd-vhosts.conf
Now lets restart apache and test our settings so far. From terminal type.
sudo httpd -k restart
MySQL Migration
First I installed a new copy of MySQL Community followed by MySQL Workbench to administrate it. Both these installations were simple and straight forward but my machine did require a reboot in order to start mysql.
Copying Configuration from MySQL workbench
Obviously my new installation of MySQL workbench did not have any of the original connections or server instances. So rather than have to remember them all I copied two xml files from my orignal disk. The xml files were located as follows.
/Volumes/SSD/Users/Rob/Library/Application Support/MySQL/Workbench/connections.xml
/Volumes/SSD/Users/Rob/Library/Application Support/MySQL/Workbench/server_instances.xml
Now start MySQL workbench to find all your saved connections
Your local databases can now be exported from your original installation by booting into your original disk and creating and export (dump) and saving the file in a common location. I actually created one dump for all my schemas and this seemed to work. Then start you new OS (Lion) and import these files in to your new MySQL installation.
MySQL Sockets
It appears that the location of mysql.sock has moved in Lion from var/mysql/mysql.sock to tmp/mysql.sock This is defined in /private/etc/php.ini. Unfortunately this file also appear to have been renamed to php.ini.default. So….
- Stop the web server ‘sudo apachectl stop’
- copy php.ini.default to php.ini
- Edit php.ini and Search and Replace ‘var/mysql/mysql.sock’ to ‘tmp/mysql.sock’
- Restart the web server ’sudo apachectl start’
Thanks to Brian Chans blog for the info on mysql.sock
Thats it, I now have my sites running under Lion. I hope this may be of some help to some people.