Notes about Setting up my Mac LAMP

Some assertions here are no longer valid—since I’ve reconfigured my web server to utilize virtual hosts.


Computer: Mac OS X Version 10.7.3 Lion.

Instructions: VerySimple Custom Software web site

Run Apache

http://sameh-labibs-imac.local/ is the only URL which should be used when trying to access the development web site on this computer. Don’t try to use something like http://sameh-labibs-imac.local/~samehlabib/. Much more on that to follow…

To refresh server disable/re-enable Web Sharing.

To see the IP information and the status of the web server go to System Preferences->Sharing.

the Apache error_log file

Its filesystem location:


Edit httpd.conf and Others


To enable PHP uncomment the following like this:

LoadModule php5_module libexec/apache2/

To be able to use .htaccess files set AllowOverride to “All.”

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all

Here are some more settings:

DocumentRoot "/Users/samehlabib/Sites"
<IfModule dir_module>
    DirectoryIndex default.htm index.html index.php

# This should be changed to whatever you set DocumentRoot to.
<Directory "/Users/samehlabib/Sites">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all

Refresh the server per instructions above. I won’t keep saying this over and over. Remember to do it whenever you make changes to configuration files for any daemon.

Other Configuration Files

  • /private/etc/apache2/users/samehlabib.conf
    for making a lot of the same configurations you would do in httpd.conf except this time affecting samehlabib only. Here I’ve added FollowSymLinks and made AllowOverride All. I added FollowSymLinks to make my pages load faster. See code all the way at the bottom of this list item.

    However, only httpd.conf matters. Why? … For two reasons. One, because I want browsers to always access my development site by using http://sameh-labibs-imac.local/ (even though the directory they will be accessing is the Sites folder for samehlabib.) Two, http://sameh-labibs-imac.local/ uses httpd.conf. Again, let me emphasize /Users/samehlabib/Sites is the DocumentRoot of the web server. It is a design decision that this directory will always be the DocumentRoot for the web server on my Mac. The fundamental reason I chose this design is that many of my scripts assemble URLs to other files on my site; and, the manner in which my scripts assemble these URLs is by pre-appending the domain name to the location of the script. That is incompatible with having a ~samehlabib sandwiched in between the domain name and the file path.

    I want to mention the following because it relates to the design decision mentioned in the previous paragraph. I placed an informational index.html page in the DocumentRoot folder. Here is what it looks like:

  • <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html lang="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <h1 align="center">index.html</h1>
    <p>This page is a place holder.</p>
    <p>Its intended location is the Sites folder of my Mac. So, (if you
    see this page on my live site,) ignore it&mdash;it's here as a back-up.</p>
    <p>The <strong>Sites</strong> folder is<strong><code> DocumentRoot
    </code></strong>of my development web server.</p>
    <p>Projects can be found in sub-folders of Sites folder.</p>
    <Directory "/Users/samehlabib/Sites/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
  • /private/etc/php.ini
    In order for there to be a php.ini file which I can edit I must create it using php.ini.default as a template (/private/etc/php.ini.default.)

    Most of the changes I’ve made to php.ini relate to how the development environment differs from a production environment. I won’t list those changes here because the php.ini file does a good job of documenting how to choose those values.

    You have to (at least) make the following changes:

  • display_errors = On
    mysql.default_socket = /tmp/mysql.sock
    pdo_mysql.default_socket = /tmp/mysql.sock
    date.timezone = "America/New_York"
    include_path = ".:/usr/lib/php/pear"

Refresh the web server after making these changes.

Install MySQL


I installed the 64-bit version mysql-5.5.23-osx10.6-x86_64.dmg.

To start/stop MySQL go to System Preferences->MySQL.

I registered an account with

Where is the mysql directory?

The directory called mysql is actually an alias to the version specific MySQL directory.


Who owns the actual MySQL directory?

Notice I said “actual.” That is because I am referring to the version specific MySQL directory.

An account called system and a group called wheel.

Account system has rw and wheel has r.

Commonly used CL programs


It is suggested that I alias them in my bash shell. Even better, add /usr/local/mysql/bin to my PATH environment variable.

alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

The directory which contains data


Command to shut down the MySQL server

mysqladmin shutdown

The name of MySQL server binary


CL start/stop the MySQL server using Startup Item

The Startup Item for MySQL is installed into /Library/StartupItems/MySQLCOM. The Startup Item installation adds a variable MYSQLCOM=-YES- to the system configuration file /etc/hostconfig. If you want to disable the automatic startup of MySQL, change this variable to MYSQLCOM=-NO-.

To start/stop MySQL go to System Preferences->MySQL.

You can start and stop MySQL by running the following commands in a terminal window.

shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop

MySQL users

The user named root initially did not have a password. All you had to do was hit the enter key. Now it has a password. That password is the same as the one for samehrlabib.

I created a user called samehrlabib. His password is etnashar(nemra)_girls(3araby)_esm-kalby-el-tany.

Install phpMyAdmin (PMA)

I was able to successful install phpMyAdmin (PMA) using the instructions on the A Non-Programmer Approach to Django blog.

PMA runs in the browser. Here is the URL:


directory location for PMA files


config file for PMA


I had to edit this file to avoid a glitch:

$cfg['Servers'][$i]['host'] = '';

I can also use the PMA setup wizard to configure phpMyAdmin further.

To configure httpd to resolve /phpMyAdmin

I created the file



Alias /phpMyAdmin /usr/local/phpMyAdmin

<Directory /usr/local/phpMyAdmin>
    Options Indexes
    Order allow,deny
    Allow from all

Configurations I made to MySQL Server (using PMA)

I changed some of the default character sets and database engines to match what my web-host Netfronts uses.

Furthermore, I created a new database (samehrlabib_aTestMyLAMP) for testing my LAMP setup. Also, I gave samehrlabib privileges over this database.

SysAdmin Stuff

Good News! I can use GUI text editors (i.e., TextWrangler) to edit system configuration files if I do “Switch User” of my Mac GUI to root user.

More Good News! To navigate the file system on a Mac I can do Finder->Go->Go to the folder.

I ran into some problems which required me to do some command line system administrator type stuff. I had to wing it with the help of Mary Ann and Google. So, I’ll document what I learned right here so I don’t have to re-learn this stuff later.


sudo cp /private/etc/php.ini.default /private/etc/php.ini

sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.


sudo vi /private/etc/apache2/httpd.conf

Vi is an editor which can work at the command line. Vi, being a sysadmin thing allowed me to edit and save files I otherwise could not save from a GUI test editor.


The su command opens up a shell for me as root.

The root user account is disabled on Mac computers by default. So, I had to reconfigure my Mac to have a root user. And, I had to pick a P/W. So, I chose the same one as my regular user account.


About samehramzylabib

See About on
This entry was posted in Configure My Systems, Version 2.0 Site Design. Bookmark the permalink.

3 Responses to Notes about Setting up my Mac LAMP

  1. Pingback: Lubuntu cont’d – add MySQL & phpMyAdmin | Sam's PHP How-To

  2. Pingback: Lubuntu cont’d — add PHP | Sam's PHP How-To

  3. Pingback: Testing the LAMP I have on My Mac | Sam's PHP How-To


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

You are commenting using your 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