All Forces

Design, Music & Mac Geekery

WordPress on Mac Part 1: PHP & MySQL

18 Comments
by Melvin Rivera
Updated: Oct 17th, 2009

This guide will help you run WordPress (the blog application that runs this website) in your own personal Mac for testing purposes or for backing up your blog. This Tutorial will cover installing PHP and MySQL, setting up local sub-domains and installing WordPress. Why would you want to do this? Well, because you can. Mac OS X is built on Unix which gives us access some very cool things like the Apache server. Local development is great because you can develop even when you don’t have an internet connection like when traveling on a plane.

Wordpress on your Mac


What’s in a name?
If you are unfamiliar with these terms, here’s a quick guide:

PHP: The web programming language WordPress is written in.
Apache: The web server that comes with Mac OS X.
MySQL:
The web database system used by WordPress.

Step 1: Installing PHP

Mac OS X comes with PHP out of the box but we’re going replace it with the most recent version. This will also give us access to some other technologies not supported on the default installation.

Choose a version of PHP based on your operating system and Download it.

Choose a PHP version

Double click the Disk Image that was downloaded.

PHP Disk Image File

From the Mounted Disk, Double Click the Installer Package.

PHP Installer Package

Choose the drive you want to install PHP in and install it. You need Administrator’s rights to perform this action.

Installing PHP

Go to the Finder’s top menu and select Apple > System Preferences. Under Internet and Network, select Sharing. Under the Services Tab start Web Sharing by selecting Personal Web Sharing and clicking the Start button.

Web Sharing

That’s it, PHP is installed! You can unmount the Mounted Disc from the Finder’s Sidebar and delete the Disk Image File.

Step 2: Installing MySQL

Go to the MySQL website and choose the Standard installer package based on your operating system. Download the file. Once downloaded, double click the DIsk Image.

MySQL Disk Image

From the newly mounted disk, double click the Installer Package.

MySQL Disc Contents

Select a hard drive to install MySQL in and run the installer.

MySQL Installing

Once finished, go back to the content of the Mounted Disk and double click the MySQL to run the Installer.

MySQL Startup Item

Once finished, go back to the content of the Mounted Disk and double click the PrefPane to install the Preference Pane.

MySQL Pref Pane Installer

From the MySQL Preference Pane click on Start MySQL Server and select the Automatically Start MySQL Server on Startup option.

MySQL Preference Pane

That’s it, MySQL is installed! You can unmount the Mounted Disc from the Finder’s Sidebar and delete the Disk Image File.

I got PHP and MySQL running, now what?

Point your browser to “http://localhost” without quotation marks. This should point you to your computer’s server located in your computer at /Library/WebServer/Documents. You can also do “http://localhost/~yourshortusername” to view your personal web site located in the Sites folder of your Home Directory.

Security: If you are concerned about anyone in your local network having access to your MySQL Database, password protect the root(master) user of MySQL by entering this in the Terminal Application “/usr/local/mysql/bin/mysqladmin -u root password new_password_here”.

On my next post, I’ll cover how to do local sub-domains and how to run WordPress Locally. In the meantime, you can check out PHPMyAdmin, a php script to manage MySQL databases if you want to play with both PHP and MySQL together. Your server address is “localhost” and your username is “root”.


18 Comments

  • David Patty says:

    The tutorial is cool and useful for people needing to put all the pieces together but if you just want get to work or play and need mySQL and PHP and maybe Perl and phpMyAdmin and a whole bunch of other neat tools in one package then get xampp for Mac OS at http://www.apachefriends.org/en/xampp-macosx.html and skip most of the install stuff. Check it out if you haven’t, there are versions for Windoze, Linux and Mac. I’m running the Mac and Linux versions and would hate to go back to installing all these programs one at a time.

    HTH
    Dave

  • Peter Parkes says:

    Thanks for that — while I’d have had no problem setting it up myself, I’ve been waiting ages for a MySQL control panel, so the heads up was much appreciated; I just had one of those momentary-glance-at-the-screenshot ‘ooh!’ moments.

  • Katie says:

    It’s much easier to install MAMP – http://www.mamp.info/en/home/
    That’s what I use for all web testing and WordPress design projects.

    “The abbreviation MAMP stands for: Macintosh, Apache, Mysql and PHP.
    With just a few mouse-clicks, you can install Apache, PHP and MySQL for Mac OS X!”

  • nga says:

    @katie : next time i should read also read part 1 (or better: the comments )before i post a comment to part 2 :) — sorry, said the same: MAMP

  • shadeDream says:

    Justa note… if you guys dont need THE latest MySQL, ServerLogistics(.com) offers a nice package installer that includes a prefpane capable of starting/stopping like MySQL’s own, but also the ability to initialize the databases and to change the root password all in the pane. The rest of their software is nice too, but hasnt been updated in quite a while (and the Apache2 installation wont work on 10.4). Hoping they will update it soon.

  • Thank you, thank you, thank you! Just what I’ve been waiting for!

  • imran says:

    hello…..

    can anyone help me enter data into mysql database
    from a flash form using coldfusion components ?

    i’m using web services and simply want to pass data from my flash form to my cfc while staying in flash…

    any actionscript (or coldfusion code ‘cfc’) that anyone could provide or even links to other ressources on this specific topic would be awesome…

    if someone could help me with this process i would be greatful…..

    thank you in advance…

    Imran Hashmi
    http://www.visionstudio.co.uk

  • Ed Fladung says:

    hey mel, great tutorial. it’s about time i start tinkering around on my own test server rather than doing it live style. gracias. btw – my website is worth $14,000. I could panhandle and make more money in a year, then doing my website. go me.

  • shwetank says:

    Great walktthrough…

    I did a successful installation of wordpress on my g4 notebook running 10.4.7.

    Tried the same procedure on 10.4.7 server but the installer for php5 reports error in installation and I haven’t been able to start webserver since.

    Anyone else face this problem? Any suggestions / solutions?

    Thanks…

  • J. Alejandro says:

    Hi…. When I attempt to check my local host (the last step of this tutorial) it says a very big “FORBIDDEN you don’t have permission to access ~(myusername)/ on this server. Is this ok? can any one help me with this?

Leave a Reply


Contact Me