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.
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.
sudo chmod u+w httpd.conf
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
CustomLog "/Volumes/SSD240/Users/Rob/Sites/logs/intranet-access_log" common
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
Now lets restart apache and test our settings so far. From terminal type.
sudo httpd -k restart
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.
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.
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.