How to start and stop the Apache HTTP Server

  1. Go to: System Preferences -> Sharing
  2. To start the server, select Web Sharing. To stop the server, unselect it.

Install MySQL

  1. Download MySQL for Mac OS X. For my computer, I used the package format for Mac OS X 10.5 (x86).
  2. Verify package integrity using MD5 checksums or GnuPG.
  3. Follow the instructions for installing MySQL on Mac OS X. I recommend installing both the MySQL Startup Item and preference pane as well. These will make it possible to have MySQL start automatically during system startup and enable you to start and stop the MySQL server with a click of a button.
  4. Post-installation setup and testing.

Enable PHP

Mac OS X comes with the Apache HTTP Server and PHP installed. The PHP module needs to be enabled.

Find the location of httpd.conf, the main configuration file for the Apache HTTP Server, using the command, httpd -V.

Note: The $ at the beginning of the lines in the following examples is the command prompt.

$ httpd -V | grep SERVER_CONFIG_FILE
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"

Beware. Proceed only if you know what you are doing. I expect that you have the technical ability of a software developer familiar with Unix.

Edit the httpd.conf file using root access with the sudo command and your favorite text editor. I use vi.

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

Uncomment the line:

# LoadModule php5_module

Save the file and exit.

Start the HTTP server and test that PHP is running by creating a file in your Web directory containing a call to the function phpinfo().

File: /Users/<username>/Sites/test.php

<?php phpinfo(); ?>

Navigate to the URL, http://localhost/~username/test.php .

Change MySQL socket

If you were to try to install WordPress now, you would probably run into this error:

Error establishing database connection

This error occurs because the PHP build that comes installed on Mac OS X (Leopard) is configured to look for the MySQL socket at /var/mysql/mysql.sock. In the current release of MySQL, the default socket is at /tmp/mysql.sock. Here is how to fix this.

Find the PHP configuration file path from the call to phpinfo() from earlier. It is probably /etc and this location is probably a symbolic link to /private/etc.

Create a php.ini file if it doesn’t already exist by copying the default configuration file, php.ini.default, using root access with the sudo command. Give the root user write permission on the file.

$ cd /private/etc
$ sudo cp php.ini.default php.ini
$ sudo chmod +w php.ini

In php.ini, edit the two lines for the parameters mysql.default_socket and mysqli.default_socket to be:

mysql.default_socket = /tmp/mysql.sock

mysqli.default_socket = /tmp/mysql.sock

Save the file and exit.

Enable .htaccess

If you want to use pretty permalinks in WordPress, you need to enable .htaccess. Otherwise you will see this error:

404 Not Found: The requested URL <URL> was not found on this server.

Edit the Apache configuration file to allow override. If you are using your Sites Web directory:

$ sudo vi /private/etc/apache2/users/<username>.conf

Find AllowOverride and change its value from None to All.

AllowOverride All

Save the file and exit.

Start Apache HTTP Server

Now that you have enabled PHP and .htaccess, restart the HTTP server.

Download and extract WordPress

Download and extract WordPress. To have WordPress automatically configure wp-config.php, before you proceed with Step #3 of the WordPress installation instructions, set the file permissions as follows.

Set file permissions

On Mac OS X (Leopard), the Apache HTTP Server runs under the user account, _www which belongs to the group _www. To allow WordPress to configure wp-config.php during installation, update files during upgrades, and update the .htaccess file for pretty permalinks, give the server write permission on the files.  I do not know if there are any security issues with this.  If you are more knowledgeable than I am on this matter, please chime in!

Updated February 17, 2010. My preferred way to do this is to change the group of the wordpress directory and its contents to _www and give write permissions to the group. Keep the owner as your <username>.

$ cd /Users/<username>/Sites
$ sudo chown -R <username>:_www wordpress
$ sudo chmod -R g+w wordpress

However, when I tried this, it did not work for automatic upgrades to newer versions of WordPress although it worked for automatically updating the .htaccess file for pretty permalinks.  End of update.

Another way to do this is to change the user of the wordpress directory and its contents to _www.  Keep the group as staff, a group to which your user account belongs and give write permissions to the group.

$ cd /Users/<username>/Sites
$ sudo chown -R _www wordpress
$ sudo chmod -R g+w wordpress

With both of these methods, the WordPress directories have a permission level of 775 and files have a permission level of 664. No file nor directory is world-writeable.

For reference, the Apache configuration file, httpd.conf, contains entries for the User and Group which the server will run as. The default setting is www for both.

For reference, on Mac OS X (Leopard), the user account information is located in the file:


This file shows that the _www and www name map to the same user account.

Install WordPress

Now resume the steps for installing WordPress. If you did not change the file permissions, you will need to edit the wp-config.php file yourself instead of having WordPress create it automatically.

Follow Symbolic Links

In some Apache server configurations, mod_rewrite requires FollowSymLinks to be enabled. Otherwise you might see this error:

403 Forbidden: You don’t have permission to access <URL> on this server.

Add this line to the top of your .htaccess file:

Options +FollowSymlinks

All done!



Please let me know if you find any errors or have anything to add.


  • Do not unzip the file if it gets downloaded as a file (unless it is supposed to be a .zip file).
  • Rename the file to remove the .zip extension and keep the .pptx extension.

.pptx files are viewable with:


How to Automate FTP with a Shell Script

July 4, 2009

Here is an example shell script: ftp -in <ftp-server> << EOF > ~/log.txt 2>&1 user <username> <password> cd <directory> get <file> bye Another way to send the username and password is: ftp -in <ftp-server> << EOF > ~/log.txt 2>&1 quote USER <username> quote PASS <password> cd <directory> get <file> bye The ftp -i option turns […]

Read the full article →