setting up osx as web server

By default OSX comes with the industry standard apache web server , only OSX server comes with a mysql server however and none are configured my default for php.

Fortunately enabling both php and installing mysql is trivial on OSX compared even to linux
1 – enable php in apache (basically edit the config file uncommenting php module)
HOWTO :
type in terminal

sudo pico /etc/apache2/httpd.conf

press the down arrow untill you see this line

#LoadModule php5_module libexec/apache2/libphp5.so

delete the “#” at the start of the line by pressing right arrow and delete
press ctrl+x
press y
press enter
(you need to use console to edit this file because osx has no way to access that file in a open file window from any program)
2- install mysql
HOWTO:
go and download the package for your architecture and osx version , install it and the pref pane
open System Preferences and click MySQL > Start MySQL Server
open terminal and type :

/usr/local/mysql/bin/mysqladmin -u root password “MYPASS”

/usr/local/mysql/bin/mysqladmin -u root -h MYHOSTNAME password “MYPASS”

change MYPASS to what you want your mysql password to be and MYHOSTNAME to the machine’s hostname (it is shown in terminal along with your user name like this [myuser@myhostname:~])
3 – done , you are the owner of a AMP (apache/mysql/php) server , now you can harness the huge amount of free web software running on this ,
as a test that everything worked fine you can install phpMyAdmin as you will probably need it anyway , go to http://www.phpmyadmin.net and extract it to /Library/WebServer/Documents/phpmyadmin
open /Library/WebServer/Documents/phpmyadmin/config.default.inc.php in a text editor
find

$cfg[‘Servers’][$i][‘host’] = ‘localhost’;

and replace localhost with your hostname

save the file as /Library/WebServer/Documents/phpmyadmin/config.inc.php
done , open http://myhostname/phpmyadmin and login with user: root , password:what you set before