Apache PHP Mysql OSX

Working in Web Development means you have to have a development environment installed on your local machine, in order to test and develop dynamic pages, using a web server (Apache,), a database (MySQL) and a scripting language (PHP). There are ways of getting those components installed in a bundle, like WAMPLAMP or MAMP. But as a developer, you are more the manual type, right? So as I had to go through that installation process recently, this article documents the steps I went through.

Apache

OSX already comes with Apache installed, it is just a matter of starting the server. You can do this if you go to System Preferences > Sharing and check “Web Sharing”. The Apache default page should now be displayed at

http://localhost

Later on, you can use the following commands to start, stop or restart Apache:

$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl restart

If you would like to change the DocumentRoot of the server, you need to edit the httpd.conf file:

$ sudo vi /etc/apache2/httpd.conf

In here, you need to change the DocumentRoot setting:

DocumentRoot "/Users/myUser/myNewWebroot/"
<Directory "/Users/myUser/myNewWebroot/">
...
</Directory>

PHP

PHP comes bundled up with Leopard as well. The important things to know here are where it got installed and where to find the configuration file.

Most likely, it got installed to:

/usr/local/php5

The configuration file should be located at:

/private/etc/php.ini

You only need to make sure that Apache knows that PHP is available, so edit httpd.conf:
$ sudo vi /etc/apache2/httpd.conf

And add the following lines (in the appropriate sections, to keep things tidy):

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

LoadModule php5_module libexec/apache2/libphp5.so

Finished with that, restart Apache, empty the browser cache and then load a php file for testing if it is correctly interpreted.

MySQL

Download the most recent dmg image from the MySQL site.

Before actually installing MySQL, I found it helps to restart the computer before proceeding with the installation. When running through the installation wizard, MySQL will get installed to:

/usr/local/mysql-VERSION

So, for example:

/usr/local/mysql-5.0.51b-osx10.5-x86/

Also, a symlink should have been created:

/usr/local/mysql -> mysql-5.0.51b-osx10.5-x86

You should also install the Preference Pane, which comes with the installation package asMySQL.prefPane

To start MySQL manually, run the following command:
$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

You should also add MySQL to $PATH:
$ vi ~/.profile
$ export PATH=$PATH:/usr/local/mysql/bin
$ source ~/.profile

To check whether that was successful, run:
$ echo $PATH

The default settings for the root user are:

  • Username: root
  • Password: [leave blank]

Add-on: PHPmyAdmin

To get PHPmyAdmin installed, which comes in handy for managing your database(s), download the latest package from their download page. Extract that package to a directory somewhere in your DocumentRoot.

Open config.sample.inc.php with an editor of your choice and add the following details for your MySQL installation:

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'whatever'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

$cfg['Servers'][$i]['user']          = 'root';
$cfg['Servers'][$i]['password']      = ''; // use here your password

After you made those changes, save the file as config.inc.php.

PEAR

PEAR should also already be available on your Mac. The location is probably:

/usr/local/php5/bin/pear

It is a good idea to add the path to PEAR to $PATH, similar to setting the path for MySQL (see above). In addition, upgrade PEAR to the latest version like so:

$ sudo pear channel-update pear.php.net
$ sudo pear upgrade PEAR

Advertisements

6 thoughts on “Apache PHP Mysql OSX

  1. Incredible story there. What occurred after? Take
    care!

  2. What’s up, I check your blogs like every week. Your humoristic style is witty, keep up the good work!

  3. Take along extra toys and fun activities to keep your child busy.
    Keep your hair down and avoid pins, bands, or other hair accessories
    that will make it difficult to comfortably
    rest your head. If you are perplexed about picking a vacation travel club.

  4. Gracie says:

    You need a big network who will pay attention to your campaign, fund you, and can help you get their own followers interested in helping you.
    You never know, it could lead to not wanting to leave. For the single machine, in Coating Machine Structure, the mechanical design, sizing roller
    speed slightly slower than the speed corrugating roll to ensure
    the right amount of adhesive glue transfer roll coating evenly on the peak on the
    flute.

  5. Dominick says:

    Most inflatable neck pillows come with a fabric cover that can be removed for cleaning.
    Now that I know how to ski I’d never dream of going straight downhill so fast and
    if I did I would probably break all my bones. If you have the knowledge and
    power, you can without leaving your seat, travel, traverse
    all the sub-planes, one after the other, witness
    the scenery, the inhabitants and their activities,
    and return to the material world, all in a moment of our time.

  6. Jasmin says:

    The Dan Bau may be played on a scale consisting of third-tones
    or even quarter-tones. With all of the laundry, ironing
    and everything else to do, this is an easy chore they
    can do from an early age until they leave for college.
    Get the “Visa approval letter” within 2 working days and
    pick up your visa at airports.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: