Skip to content

Instantly share code, notes, and snippets.

@ebetancourt
Created July 31, 2012 20:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ebetancourt/3220396 to your computer and use it in GitHub Desktop.
Save ebetancourt/3220396 to your computer and use it in GitHub Desktop.
Set up apache on Mountain Lion
mkdir -p ~/Sites
mkdir -p ~/Sites/logs
mkdir -p ~/Sites/conf
mkdir -p ~/Sites/conf/vhosts
touch ~/Sites/conf/httpd-vhosts.conf
export USERDIR=`whoami`
cat >> ~/Sites/conf/httpd-vhosts.conf <<EOF
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# Set up permissions for VirtualHosts in ~/Sites
#
<Directory "/Users/$USERDIR/Sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# For http://localhost in the OS X default location
<VirtualHost _default_:80>
ServerName localhost
DocumentRoot "/Users/$USERDIR/Sites"
</VirtualHost>
#
# VirtualHosts below
#
## Template
#<VirtualHost *:80>
#    ServerName domain.local
#    CustomLog "/Users/$USERDIR/Sites/logs/domain.local-access_log" combined
#    ErrorLog "/Users/$USERDIR/Sites/logs/domain.local-error_log"
#    DocumentRoot "/Users/$USERDIR/Sites/domain.local"
#</VirtualHost>
EOF
sudo ln -s ~/Sites/conf/httpd-vhosts.conf /etc/apache2/other
chmod 0777 ~/Sites/logs
echo "<html><body><h1>My site works</h1></body></html>" > ~/Sites/index.html.en
sudo sed -i '' 's/AllowOverride None/AllowOverride All/' /private/etc/apache2/httpd.conf
# sudo sed -i '' 's/^#Include\(.*\)vhosts\.conf/Include\1vhost.conf/g' /private/etc/apache2/httpd.conf
sudo sed -i '' 's/^#LoadModule\(.*\)php\(.*\)/LoadModule\1php\2/' /private/etc/apache2/httpd.conf
echo "<?php echo phpinfo(); ?>" > ~/Sites/info.php
sudo cp -a /etc/php.ini.default /etc/php.ini
sudo sh -c "cat >> /etc/php.ini <<'EOF'
;;
;; User customizations below
;;
; Original - memory_limit = 128M
memory_limit = 196M
; Original - post_max_size = 8M
post_max_size = 200M
; Original - upload_max_filesize = 2M
upload_max_filesize = 100M
; Original - default_socket_timeout = 60
default_socket_timeout = 600
; Original - max_execution_time = 30
max_execution_time = 300
; Original - max_input_time = 60
max_input_time = 600
; Original - display_errors = Off
display_errors = On
; Original - display_startup_errors = Off
display_startup_errors = On
; Original - ;date.timezone =
date.timezone = 'America/New_York'
EOF"
sudo /usr/bin/php /usr/lib/php/install-pear-nozlib.phar
sudo php /usr/lib/php/install-pear-nozlib.phar
sudo `echo 'include_path = ".:/usr/lib/php/pear"' >> /etc/php.ini`
sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade-all
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo apachectl restart
open http://localhost/info.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment