Apache and PHP5
The Apache server works out of the box and can be controlled with the following commands:
$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl restart
Once the server is running, you should be able to load the default page by going to http://localhost in a browser. You'll also need to set up the directory to host all your files, which requires a few steps:
- Create a 'Sites' folder in your root (home) directory:
- Create a 'username.conf' file (if your username is johndoe, then johndoe.conf) at
sudo touch /etc/apache2/users/username.conf
You then need to edit the config file you just created with your preferred editor to add the following (replace "username" in the first line with your own":
<Directory "/Users/username/Sites/"> AllowOverride All Options Indexes MultiViews FollowSymLinks Require all granted </Directory>
Then open up /etc/apache2/httpd.conf in an editor to uncomment the following lines (first two should already be uncommented, and the last one enables PHP5):
LoadModule authz_core_module libexec/apache2/mod_authz_core.so LoadModule authz_host_module libexec/apache2/mod_authz_host.so LoadModule userdir_module libexec/apache2/mod_userdir.so LoadModule include_module libexec/apache2/mod_include.so LoadModule rewrite_module libexec/apache2/mod_rewrite.so Include /private/etc/apache2/extra/httpd-userdir.conf LoadModule php5_module libexec/apache2/libphp5.so
We also need to open /etc/apache2/extra/httpd-userdir.conf and uncomment:
save all edited files, and run the restart command mentioned earlier:
sudo apachectl restart
You'll now be able to access your Sites folder by going to http://localhost/~username/
OSX does not come with MySQL so it needs to be downloaded: Mac OS X 10.10 (x86, 64-bit), DMG Archive (no need to sign up, just click the tiny "no thanks" link at the bottom). Once you run the DMG installer, it'll give you a temporary root user password upon completion, which you should write down somewhere until it's changed. Open up your System Preferences and go to the newly added MySQL section to start the server.
The temporary password can be overwritten by running the following:
/usr/local/mysql/bin/mysqladmin -u root -p 'temppassword' password 'newpassword'
where you can replace temppass with the one provided by the installer, and newpass with your desired password.
Typing out the full path to mysql can get annoying, so we can add the mysql directory to the shell path by adding the following into your .bash_profile:
There's also a known 2002 MySQL Socket error which can be fixed with the following:
sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
First download phpMyAdmin and unzip contents into a folder named 'phpmyadmin' inside the root of the Sites folder. Create a 'config' folder inside of phpmyadmin folder, and change the permissions:
chmod o+w ~/Sites/phpmyadmin/config and run the setup by going to http://localhost/~username/phpmyadmin/setup/
In the setup screen, click 'New Server' and select the 'Authentication' tab. User 'root' should be pre-filled, just type in the updated password we set previously and hit save.
Once returned to the previous screen, click the 'Save' button on the bottom, and a config.inc.php file will be saved into the 'config' folder we had created earlier. Move this file into the root of the phpmyadmin folder and delete the now empty 'config' directory.
You should now be able to interact with your databases by going to http://localhost/~username/phpmyadmin/