Fastest Way to install WordPress on OSX 10.8, 10.7 and 10.6
This tutorial assumes a certain degree of comfort in the command line Terminal for installing WordPress on Mac OS X Lion or Snow Leopard, but the commands below are not overly complex and following the tutorial will get the job done. If you have no experience with the Terminal and want the easiest way to install on your local Mac then follow this guide here which installs everything with a point and click in the Finder.
Before proceeding WordPress needs a couple of things to get going and those things are an AMP stack - Apache, MySQL and PHP, Apache and PHP come bundled in OS X but MySQL needs to be downloaded and configured. Optionally install phpmyadmin to manage the database.
To get the AMP stack working correctly on OS X follow this guide (10.7 & 10.6) on Apache/MySQL/php and for phpMyAdmin if required, or Mountain Lion OSX 10.8.
Once these components are in place you are OK to proceed.
OS X has 2 web document roots ‘/Library/WebServer/Documents’ and ‘/Users/username/Sites/’ also known as ‘~/Sites’ this guide uses ’~/Sites’.
The shared WordPress directory will be called “wordpress“.
WordPress File Set Up
make a sharing directory and move into it
mkdir ~/Sites/wordpress ; cd ~/Sites/wordpress
get the latest WordPress
curl -O http://wordpress.org/latest.tar.gz
expand it
tar -xvzf latest.tar.gz
move all files into shared directory one level up
mv wordpress/* .
remove empty directory and compressed archive
rmdir wordpress/ ; rm latest.tar.gz
create a settings file
cp wp-config-sample.php wp-config.php
Database Setup
create it a new database (no space between -p and password – as an alternative this can be done in phpmyadmin
mysql -u [username] -p[password] -e "create database [databasename];"
or in phpmyadmin
You can do all of the above in one hit at the command line just separate the commands with “;”. This would be handy with multiple installs and can be scripted – not necessary for this guide – but I thought I’d throw it in.
mkdir ~/Sites/wordpress ; cd ~/Sites/wordpress ; curl -O http://wordpress.org/latest.tar.gz ; tar -xvzf latest.tar.gz ; mv wordpress/* . ; rmdir wordpress/ ; rm latest.tar.gz ; rmdir wordpress/ ; rm latest.tar.gz ; cp wp-config-sample.php wp-config.php ; mysql -u [username] -p[password] -e "create database [databasename];" ; nano wp-config.php
WordPress Database Config
Then proceed with the editing of the wp-config file which needs to have the database details added as below:
nano wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress‘);
/** MySQL database username */
define(‘DB_USER’, ‘root‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘yourpassword‘);
/** MySQL hostname */
define(‘DB_HOST’, ‘localhost‘);
If you are not comfortable with editing this file in nano in the Terminal you can use Text Edit in Applications.
Famous 5 Minute Install
open it up in your default browser
open http://localhost/~username/wordpress/wp-admin/install.php
fill in your credentials:
voila
Post Mortem
but wait there’s more, you need to fix up those ownership and permissions
sudo chown -R _www ~/Sites/wordpress ; sudo chmod -R g+w ~/Sites/wordpress
and finally if you do enable clean URLs via the permalink options in WordPress dashboard you will lock out your site with 403 Forbidden errors, what you need to do is tweak the .htaccess by adding in a line of code at the very top. The .htaccess file is generated when the Permalink settings are saved from within the WordPress dashboard.
Since we have now changed ownership of the site .htaccess needs to be opened with sudo
sudo nano ~/Sites/wordpress/.htaccess
and add in at the top:
Options +FollowSymLinks
Thats it you should have a fully functioning local WordPress install built on a native AMP stack.


July 21, 2011 

















Pingback: MacMini server deel 14: Wordpress « AJvK.nl
Pingback: taplinlaw.biz » Blog Archive » Adding WordPress to OS X 10.7
Pingback: Installera wordpress på Mac OsX Server
Pingback: Installazione e configurazione di Apache, MySQL, PHP, phpMyAdmin e WordPress in OSX 10.8 Mountain Lion « Mad Mat