Installing apache 2.4, mysql and php5.6 on Mac

Before install your own apache server, make sure the apache server that came with Mac OS is shut down by issuing this command in the Termainal window

sudo apachectl stop

1. If you don’t have Xcode installed yet on your Mac, download and install it from the Apple App Store.

2. If you don’t have the home brew package manager installed yet, open up the terminal and type this command to get brew.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3. Install pcre, libtool, mysql, php56 and appache2.4 through brew package manager.

brew tap homebrew/apache
brew install pcre libtool mysql php56 httpd24

4. Open the apache 2.4 config file, and proceed to the following steps.

vim /usr/local/etc/apache2/2.4/httpd.conf

5. By default, Apache 2.4 listens to port 8080 instead of 80, find the line with Listen 8080 and change it to the following.

Listen 80

6. Load php56 module in the config file, add this line next to the last LoadModule in the config file. The path for libphp5.so might be different depending on the php version.

LoadModule php5_module /usr/local/Cellar/php56/5.6.12/libexec/apache2/libphp5.so

7. Find the line that has AddType and add the following line.

AddType application/x-httpd-php .php

8. Find the line with DirectoryIndex and change it to the following

DirectoryIndex index.html index.php

9. Find the following lines in the config file and uncomment them by removing the #

LoadModule rewrite_module libexec/mod_rewrite.so
LoadModule expires_module libexec/mod_expires.so
LoadModule deflate_module libexec/mod_deflate.so

10. Find the lines with DocumentRoot and Directory, and change them to these. yourname is your user name that shows on the Terminal window.

DocumentRoot "/Users/yourname/sites"
<Directory "/Users/yourname/sites">

11. Create an index.php file in /Users/yourname/sites with the code below that prints the phpinfo.

<?php
echo phpinfo();

12. Start Apache server from the Terminal window.

sudo apachectl start

13. Visit localhost in your browser and you should see a php info page.

To have launchd start homebrew/apache/httpd24 at login:

ln -sfv /usr/local/opt/httpd24/*.plist ~/Library/LaunchAgents

To have launchd start homebrew/php/php56 at login:

ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents

To have launchd start mysql at login:

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

To start, stop and restart apache server.

apachectl start
apachectl stop
apachectl restart

Search within Codexpedia

Custom Search

Search the entire web

Custom Search