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
- System Preferences->Sharing and turn on Web Sharing.
- Sites folder had been there already.
- IP for web server:
- URL for my Sites folder:
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/libphp5.so
To be able to use
.htaccess files set
AllowOverride to “
<Directory /> Options FollowSymLinks AllowOverride All Order deny,allow Deny from all </Directory>
Here are some more settings:
DocumentRoot "/Users/samehlabib/Sites" ServerAdmin email@example.com <IfModule dir_module> DirectoryIndex default.htm index.html index.php </IfModule> # # 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 </Directory>
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
for making a lot of the same configurations you would do in
httpd.confexcept this time affecting
samehlabibonly. Here I’ve added
AllowOverride All. I added
FollowSymLinksto make my pages load faster. See code all the way at the bottom of this list item.
httpd.confmatters. 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
httpd.conf. Again, let me emphasize
DocumentRootof the web server. It is a design decision that this directory will always be the
DocumentRootfor 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
~samehlabibsandwiched 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.htmlpage in the
DocumentRootfolder. Here is what it looks like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>index.html</title> </head> <body> <h1 align="center">index.html</h1> <hr> <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—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> <hr> </body> </html>
<Directory "/Users/samehlabib/Sites/"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
In order for there to be a
php.inifile which I can edit I must create it using
php.ini.defaultas a template (
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.
I installed the 64-bit version
To start/stop MySQL go to System Preferences->MySQL.
I registered an account with http://www.mysql.com.
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
rw and wheel has
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
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
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
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
I created a user called
samehrlabib. His password is
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'] = '127.0.0.1';
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 </Directory>
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.
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.
su command opens up a shell for me as root.
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.