# Displays all files in Finder. Optional: personal preference.
$ defaults write com.apple.Finder AppleShowAllFiles YES
# Relaunch Finder
# Update MacPorts
$ sudo port selfupdate
$ sudo port -u upgrade outdated
# Install MySQL
$ sudo port install mysql5-server
$ sudo port load mysql5-server
$ sudo -u _mysql mysql_install_db5
$ sudo mysqld_safe5 &
$ sudo /opt/local/lib/mysql5/bin/mysql_secure_installation
# Install Apache, PHP (with PEAR), PHP MySQL bindings
$ sudo port install apache2
$ sudo port install php5 +apache2 +pear
$ sudo port install php5-mysql
# Configure Apache
# The following line may not be necessary
? sudo cp /opt/local/apache2/conf/httpd.conf.sample /opt/local/apache2/conf/httpd.conf
$ cd /opt/local/apache2/modules
$ sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
$ sudo nano /opt/local/apache2/conf/httpd.conf
# Set DirectoryIndex to:
# DirectoryIndex index.html index.php
#
# Change DocumentRoot to whatever (e.g. /Users/michael/Sites
#
# Change <directory "{old DocumentRoot}"> to <directory "{new DocumentRoot}">
#
# In that <directory "{new DocumentRoot}"> section change to the following.
# Options Indexes FollowSymLinks MultiViews
# AllowOverride All
#
# In <ifmodule mime_module> section, add the following two lines
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
#
$ sudo port load apache2
# Configure PHP
$ sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini
$ sudo nano /opt/local/etc/php5/php.ini
# set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to
# /opt/local/var/run/mysql5/mysqld.sock
# Start Apache
# Make sure System Preferences → Sharing → Web Sharing is turned off.
$ sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start
# You may get a window asking if httpd can accept incoming requests. Approve it.
# Add DB and tables to MySQL for easy WordPress install
$ mysql5 -u root -p
> CREATE DATABASE database_name_here;
> GRANT ALL PRIVILEGES ON database_name_here.* TO "username_here"@"localhost" IDENTIFIED BY "password_here";
> FLUSH PRIVILEGES;
> EXIT
# Install and Configure phpMyAdmin (will need to restart Apache when done)
$ sudo port install phpmyadmin
$ sudo nano /opt/local/apache2/conf/httpd.conf
# Add section
# <Directory "/opt/local/www/phpmyadmin/">
# Options Indexes MultiViews
# AllowOverride None
# Order allow,deny
# Allow from all
# </Directory>
#
# In <IfModule alias_module> section add the following
# Alias /phpMyAdmin "/opt/local/www/phpmyadmin"
$ sudo nano /opt/local/www/phpmyadmin/config.inc.php
# See http://www.phpmyadmin.net/documentation/Documentation.html#config
# Fill in $cfg['blowfish_secret']
# Set $cfg['Servers'][$i]['auth_type'] = 'config';
# Add $cfg['Servers'][$i]['user'] = 'root';
# Add $cfg['Servers'][$i]['password'] = '{root password}';
$ sudo /opt/local/apache2/bin/apachectl {start|restart|graceful|graceful-stop|stop}
$ sudo /opt/local/share/mysql5/mysql/mysql.server {start|stop|restart|reload|force-reload|status}