PHP Apache MySQL Set-up Note
- Apache is pre-installed in Mac OS X, and it can be started by running
sudo apachectl startin terminal. After this, It works! is shown when visitinglocalhostin browser. Create aSitesfolder in your home folder, then this folder is accessible throughlocalhost/~yourusername. - Enable PHP by uncommenting
LoadModule php5_module libexec/apache2/libphp5.soin/etc/apache2/httpd.conf. Then restart Apache viasudo apachectl restart. To verify if php works, creating aphpinfo.phpin theSitesfolder:
<?php
phpinfo();
?> When visiting localhost/~yourusername/phpinfo.php you should see php mata information instead of plain text of the code.
- Install MySQL and phpMyAdmin
- Set MySQL root password
mysqladmin -u root password PASSWORD
If you’re getting#2002 Cannot log in to the MySQL serverwhen logging in to phpmyadmin, try editingphpmyadmin/config.inc.phpand change:
$cfg['Servers'][$i]['host'] = 'localhost';
to:$cfg['Servers'][$i]['host'] = '127.0.0.1'; - Create VirtualHost by adding to the end of
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "PATH TO SITE ROOT"
ServerName "SERVER.local"
ErrorLog "/private/var/log/apache2/jason.local-error_log"
CustomLog "/private/var/log/apache2/jason.local-access_log" common
<Directory "PATH TO SITE ROOT">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "PATH TO SITE ROOT"
ServerName "SERVER.local"
ErrorLog "/private/var/log/apache2/"SERVER.local"-error_log"
CustomLog "/private/var/log/apache2/"SERVER.local"-access_log" common
<Directory "PATH TO SITE ROOT">
Options +Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>- Edit
/etc/hoststo append127.0.0.1 SERVER.local