This article is part of Django Installation on Mac OS X Lion
Mac OS X by default ships with Apache web server which we will use to install (configure) phpMyAdmin to manage MySQL server installed previously on Mac OS X 10.7 (aka Lion). At the end of this step-by-step tutorial, you should be able to access phpMyAdmin by opening http://localhost/phpMyAdmin in your preferred browser.
In this tutorial we will be using Terminal to move files around and edit/create files using command line.
- Start Apache if it’s not already running (You can check by running command “ps -ef | grep httpd” in terminal)
- Open System Preferences and Click Sharing
- Check Web Sharing Checkbox which should start web server (Apache) on your Mac
- Open http://localhost in browser and you should see default page (on mine it just says “It Works” in H1 Tag)
- By default, PHP module is not activated. Uncomment the line ”LoadModule php5_module libexec/apache2/libphp5.so” in file “/private/etc/apache2/httpd.conf” to enable PHP on Mac OS X Apache web server. Default PHP version is PHP 5.3 (PHP 5.3.6 to be precise)
- Download phpMyAdmin (Latest version at the time of writing this is 18.104.22.168) from phpMyAdmin Site. Download page has quite a few options in terms of language and compresssion formats, so download the most relevant language pack and compression format you are comfortable with. (I downloaded phpMyAdmin-22.214.171.124-english.zip, please note your version may be different )
- Open Terminal and Extract downloaded package to /usr/local/ by running command “sudo unzip phpMyAdmin-126.96.36.199-english.zip -d /usr/local/“
- Rename phpMyAdmin-188.8.131.52-english to phpMyAdmin by using command “sudo mv /usr/local/phpMyAdmin-184.108.40.206-english /usr/local/phpMyAdmin” in Terminal
- Switch to phpMyAdmin directory using “cd /usr/local/phpMyAdmin” to create phpMyAdmin config file
- By default config.inc.php file does not exist but phpMyAdmin ships with sample config which we can use. Copy config.sample.inc.php to config.inc.php using “sudo cp config.sample.inc.php config.inc.php“
- Edit config.inc.php using your favorite editor (I prefer vi) and change $cfg['Servers'][$i]['host'] = ‘localhost’; to $cfg['Servers'][$i]['host'] = ’127.0.0.1′;
*Well it sounds stupid because localhost and 127.0.0.1 are same in networking world but phpMyAdmin won’t let you (At least me) log in without this change and keeps throwing error “#2002 Cannot log in to the MySQL server”
**If your MySQL is running on a different host/port, you can change them in this file
***You can also use setup wizard offered by phpMyAdmin to configure phpMyAdmin further
****You can also add random blowfish secret to config.inc.php to encrypt your session cookies.
- Configure Apache to enable /phpMyAdmin
- Create phpMyAdmin apache config file with below text in bold in /etc/apach2/other/ directory using your favorite editor “sudo vi /etc/apache2/other/phpMyAdmin.conf“Alias /phpMyAdmin /usr/local/phpMyAdmin
Allow from all
- Restart Apache by typing command sudo apachectl restart in terminal
- Open http://localhost/phpMyAdmin in your browser and you should see phpMyAdmin Login Page
*Note Default phpMyAdmin does not allow you to login with empty passwords, you can change this behaviour but it is highly recommended to have password for mysql server accounts.