PHP Apache MySQL Set-up Note
- Apache is pre-installed in Mac OS X, and it can be started by running
sudo apachectl start
in terminal. After this, It works! is shown when visitinglocalhost
in browser. Create aSites
folder in your home folder, then this folder is accessible throughlocalhost/~yourusername
. - Enable PHP by uncommenting
LoadModule php5_module libexec/apache2/libphp5.so
in/etc/apache2/httpd.conf
. Then restart Apache viasudo apachectl restart
. To verify if php works, creating aphpinfo.php
in theSites
folder:
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 server
when logging in to phpmyadmin, try editingphpmyadmin/config.inc.php
and 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
- Edit
/etc/hosts
to append127.0.0.1 SERVER.local