How to install apache + mysql + php on MacOSX

Apache2 and PHP are already installed on system.

Apache2 config is located here

/etc/apache2/httpd.conf

To load php module uncomment line

LoadModule php5_module libexec/apache2/libphp5.so


At line 249 change next 4 lines to following

Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

If you want to use virtual hosts uncomment line

Include /private/etc/apache2/extra/httpd-vhosts.conf

Configure virtual hosts at /private/etc/apache2/extra/httpd-vhosts.conf and don’t forget to modify /etc/hosts.

You don’t need to configure PHP settings at all so just copy the default file
cp php.ini.default php.ini

Restart apache

apachectl restart

Enable Web sharing at Settings > Sharing

To install MySQL first download it from mysql.com. Install it and don’t forget to install Setting Pane if you want to use GUI to (un)load MySQL.
Put next lines to ~/.bashrc

alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin

In /etc/php.ini, replace the three occurences of /var/mysql/mysql.sock by /tmp/mysql.sock

pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

At the don’t forget to start MySQL and restart Apache.

Share
Posted By admin

Leave a Reply

You must be logged in to post a comment.