Skip to content

Instantly share code, notes, and snippets.

@jjulian
Created February 11, 2013 15:09
Show Gist options
  • Save jjulian/4754983 to your computer and use it in GitHub Desktop.
Save jjulian/4754983 to your computer and use it in GitHub Desktop.
Run PHP on a Mac using Apache
$ edit httpd.conf to match your local filesystem
$ mkdir tmp logs public php
$ mv public.php public/
$ cp <your php.ini> to php/php.ini
$ apachectl -f /Users/jjulian/runphp/httpd.conf -t
$ apachectl -f /Users/jjulian/runphp/httpd.conf -k start
$ curl -D - http://localhost:8888
ServerRoot /Users/jjulian/runphp
PidFile tmp/httpd.pid
LockFile tmp/accept.lock
User jjulian
ServerName localhost
Listen 8888
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 5
MaxClients 10
MaxRequestsPerChild 0
</IfModule>
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule log_config_module /usr/libexec/apache2/mod_log_config.so
LoadModule mime_module /usr/libexec/apache2/mod_mime.so
LoadModule autoindex_module /usr/libexec/apache2/mod_autoindex.so
LoadModule negotiation_module /usr/libexec/apache2/mod_negotiation.so
LoadModule dir_module /usr/libexec/apache2/mod_dir.so
LoadModule rewrite_module /usr/libexec/apache2/mod_rewrite.so
LoadModule php5_module /usr/libexec/apache2/libphp5.so
<IfModule mod_php5.c>
PHPIniDir /Users/jjulian/runphp/php
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
DocumentRoot "/Users/jjulian/runphp/public"
<Directory /Users/jjulian/runphp/public>
AllowOverride None
Order allow,deny
Allow from 127.0.0.1, localhost
</Directory>
<?php echo 1 + 2 ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment