OSX ships with Apache and PHP but not MySQL, you can use HomeBrew to install the other parts of the AMP Stack quickly including MySQL, phpMyAdmin and mcrypt. What you need to get started as a base is Xcode and Command Line Tools.
This guide is intended for those with more experience with the command line and the AMP stack and want it done quickly – there is another guide here with more detailed instructions for a more traditional installation and an introduction here to HomeBrew and Xcode.
This guide works best on clean OSX images with no previous AMP installs, but it will still work on ones with installs, but there may be bumps on the way.
Lets get started…
Base Tools
Install Xcode
Install Command Line Tools
From the Terminal run…
xcode-select --install
Install HomeBrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
MySQL
Install MySQL
brew install mysql
Start mysql
mysql.server start
To login
mysql -u root
Set the MySQL root password – keep single quotes around password
/usr/local/mysql/bin/mysqladmin -u root password 'yourpasswordhere'
To make it launch on reboot
mkdir -p ~/Library/LaunchAgents ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Apache
To start it
sudo apachectl start
To stop it
sudo apachectl stop
To restart it
sudo apachectl restart
Document root is found at –
Document root filing system at –
/Library/WebServer/Documents/
To set up User webroot see here.
PHP
Turn on PHP
sudo nano /etc/apache2/httpd.conf
Use “control” + “w” to search within nano and search for ‘php’ this will land you on the right line then uncomment the line (remove the #):
LoadModule php5_module libexec/apache2/libphp5.so
Write out and Save using the nano short cut keys at the bottom ‘control o’ and ‘control x’
Reload Apache to kick in
sudo apachectl restart
phpMyAdmin
Create symbolic link for mysql.sock
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Install phpMyAdmin
brew install josegonzalez/php/phpmyadmin
Add to your your httpd.conf
sudo nano /etc/apache2/httpd.conf
Add at the end…
Alias /phpmyadmin /usr/local/share/phpmyadmin <Directory /usr/local/share/phpmyadmin/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory>
Set Up Configuration
mkdir/usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/config
chmod o+w /usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/config
Go to browser -> http://localhost/phpmyadmin/setup/
In the Authentication Tab set the password to the same one set as the MySQL root user from earlier
Login -> http://localhost/phpmyadmin/
mcrypt – optional
Make sure php.ini has its own config file
sudo cp /etc/php.ini.default /etc/php.ini
brew install php54-mcrypt
Edit php.ini to point to new extension directory and extension – if you already have set a extension directory then move mcrypt.so into it.
sudo nano /etc/php.ini
Add in and save
extension_dir="/usr/local/Cellar/php54-mcrypt/5.4.26/" extension=mcrypt.so
Restart Apache
sudo apachectl restart
wget – optional
brew install wget
Other Installs
There are many packages to install with HomeBrew – just do a search…
brew search