Skip to content

Instantly share code, notes, and snippets.

@kaplan
Last active December 15, 2015 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaplan/5327539 to your computer and use it in GitHub Desktop.
Save kaplan/5327539 to your computer and use it in GitHub Desktop.
PHP/MySQL, Virtual Hosts Mountain Lion Setup from a user migration. Clean install on a new hard drive using a Mountain Lion bootable drive for MacOS install and a Time Machine ext. hd for the User Migration

###Basic setup outline (This may be wrong but it roughly contains everything you've been doing. Check the references for more info.)

  • Enable PHP and vhosts in the httpd.conf file
  • Set the permissions on the default /Library/WebServer/Documents
  • Start Apache
  • Test with the localhost in the browser
  • Make the username.conf file and set the default directory to the /Users/username/Sites/
  • Restart Apache
  • Edit PHP config to work with MySQL
  • Fix the permissions on the existing user MySQL
  • Add the vhosts and hosts setting back

####Enable PHP and VHOSTS in httpd.conf

~ > sudo subl /etc/apache2/httpd.conf

In Sublime make these changes

# uncomment the following lin:
LoadModule php5_module libexec/apache2/libphp5.so

# in <Directory "/Library/WebServer/Documents"> change AllowOverride None to All
AllowOverride All

# Add .php to DirectoryIndex
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

# Uncomment virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

####Default WebServer Settings

~ > sudo chmod -R o+w /Library/WebServer/Documents
~ > open /Library/WebServer/Documents
# trash the files in here and add a phpinfo() in a index.php or info.php

####Start or restart Apache

~ > sudo apachectl restart

Add a php info index.php file and test in the browser. http://localhost/

####Make the user Sites folder the default WebServer Now add a username.conf (username is your account username) file and make that the default WebServer within Sites

<Directory "/Users/username/Sites/">
  DirectoryIndex index.php index.html
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

####Edit php.ini config

~ > cd /etc
~ > sudo cp php.ini.default php.ini
~ > sudo subl php.ini

In the php.ini change the following to match

display_errors On
html_errors = On
mysqli.default_socket = /tmp/mysql.sock

####Fix the permissions on the user mysql
(you might be doing a fresh install of MySQL if this isn't a user migration)

~ > sudo chown -RL root:mysql /usr/local/mysql
~ > sudo chown -RL mysql:mysql /usr/local/mysql/data
~ > sudo /usr/local/mysql/support-files/mysql.server start
Starting MySQL
  SUCCESS! 

####Setup the hosts and vhosts then you won't have to use localhost or 127.0.0.1

~ > sudo subl /etc/apache2/extra/httpd-vhosts.conf
~ > sudo subl /etc/hosts
~ > sudo apachectl restart

###Other things you'll probably need to fix and document here.

  • homebrew settings, doctor brew error after a new drive is setup with a migration
  • if you have pow installed, you'll see pow messages in the browser if the Apache/PHP isn't right
  • need new users for any local databases, using SequelPro to set those up, wp site configs for usr/pwd

Homebrew/legacy-homebrew#19006 https://github.com/37signals/pow/wiki/Running-Pow-with-Apache

References:
https://gist.github.com/jessedc/3488335
http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion
http://akrabat.com/computing/setting-up-php-mysql-on-os-x-10-8-mountain-lion/
http://bensch.be/mysql-php-apache-and-mountain-lion
http://stackoverflow.com/questions/5527676/warning-the-user-local-mysql-data-directory-is-not-owned-by-the-mysql-user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment