Install WordPress on Mac OS X Without installing MAMP or AMPPS from Command Line just like we do for Ubuntu or any kind of Linux. Mac OS X Lion has Apache, PHP and virtual hosts. Mac OS X looks funky in front but it is actually UNIX, so it is quite obvious that it will take almost all commands like Linux. There is no need to install any third party software like MAMP, AMPSS etc. Extra software means extra load and when we can actually configure Mac OS X like a server to run WordPress as on localhost, why we will use those junks. You can actually run any PHP MySQL based softwares, this guide to Install WordPress on Mac OS X With Command Line is a prototype example.
Install WordPress on Mac OS X With Command Line : The Basics
Basically labeling it as LAMP will be wrong, the right will be UAMP – Unix Apache MySQL and PHP. We will use iTerm2 for this guide to Install WordPress on Mac OS X With Command Line. Apache, PHP is already installed on Mac, we just need to configure to Install WordPress on Mac OS X. There is vim, nano etc.text editors preinstalled as well. Basically the only needed software is MySQL. Basically its the Windows that is abnormal. UNIX, Linux and BSD basically takes almost same commands. There is minor variation from distro to distro, like yast for SUSE/openSUSE, yum for CentOS / REHL and so on.
Install WordPress on Mac OS X With Command Line : The Commands
Just like we said before in the linked article, First open Terminal (iTerm with Homebrew will not allow sudo in all commands), type :
---
1 | sudo su |
It will ask for password, type it and hit Return key. You will be root user now.
1 | sudo nano /etc/apache2/httpd.conf |
In the above screenshot, you can see, I have used nano text editor to configure the httpd.conf file. You can open with vi (vim) command too. You need to change permission (chmod) it to edit in vim :
1 | sudo chmod u+w /etc/apache2/httpd.conf |
Otherwise you will get a read only file in vi. But in that case you have to revert back again by using :
1 | sudo chmod u-w /etc/apache2/httpd.conf |
…after editing. That is why using nano is better option.
Uncomment these lines :
1 2 3 | LoadModule php5_module libexec/apache2/libphp5.so Include /private/etc/apache2/extra/httpd-vhosts.conf Include /private/etc/apache2/extra/httpd-ssl.conf |
Uncomment means making the directives active by removing the hash (#) and a space before them. Save it. The Include lines are for enabling virtual host and httpd-ssl. If you do not want these extra advanced setup, you only can uncomment the LoadModule (for enabling PHP) thing.

Run the four commands like above like a blind :
1 | sudo mkdir /usr/local/include |
1 | sudo mkdir /usr/local/bin |
1 | sudo mkdir /usr/local/lib |
1 | sudo mkdir -p /usr/local/man/man1 |
I basically checked by going to the folder and listing (ls) them. As I do not have those folders. You will not have too, create them as I did above. Now restart Apache :
1 | sudo apachectl restart |
This is how to setup the php :
1 | cd /etc |
1 | sudo cp php.ini.default php.ini |
1 | sudo chmod ug+w php.ini |
1 | sudo chgrp admin php.ini |
Open php.ini file by using :
1 | sudo nano /etc/php.ini |
Edit these lines and save it :
1 | error_reporting = E_ALL | E_STRICT |
1 | display_errors = On |
1 | html_errors = On |
1 | extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626" |
These are only PHP and Apache native part. If you put a simple php file in /Library/WebServer/Documents ; it will load fine if you point your browser to http://localhost/ or the localhost’s IP (127.0.0.1).
Now the remaining points are MySQL and some other PHP components. MySQL can be directly installed or you can use Homebrew to get MySQL running :
1 | brew install mysql |
1 | unset TMPDIR |
1 | mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp |
You can start MySQL server in either ways :
1 | mysql.server start |
1 | /usr/local/Cellar/mysql/write-version-here/bin/mysql_secure_installation |
Change write-version-here to full version number. You can install PHPMyAdmin if you want, but probably there is no need.
Now installing the dependencies (you’ll need Homebrew package manager to be installed) :
1 | brew install mcrypt mcrypt-php |
Please enable mycript from /etc/php.ini (in the way we enabled PHP). It will be looking like “extension=/usr/local/Cellar/mcrypt-php/…”
Setting up Pear is important.
1 | cd /usr/lib/php |
1 | sudo php install-pear-nozlib.phar |
Open /etc/php.ini and change that include_path = to pointing towards /usr/lib/php/pear.
1 | sudo pear channel-update pear.php.net |
1 | sudo pecl channel-update pecl.php.net |
1 | sudo pear upgrade-all |
1 | pear install MDB2-2.5.0b3 |
(check the version when you will install)
1 | pear install MDB2_Driver_mysqli-1.5.0b3 |
Now your work toinstall WordPress on Mac OS X is almost done. It is like a LAMP server. Download WordPress and put it in /Library/WebServer/Documents. You need to create a MySQL database, the commands will be like in normal server installation like we described here in the last steps.