post original con php y mysql en os x
Leopard comes with Apache 2 and PHP 5 preinstalled. All we need to do is activate it.
1a – Change the apache conf file to activate PHP
- Using a text editor such as smultron, TextMate or command line tool Pico, which lets you open hidden files. Open Apache’s conf file on your system at /private/etc/apache2/httpd.conf
On Pico open terminal and typesudo pico /private/etc/apache2/httpd.conf
For TextMatemate /private/etc/apache2/httpd.conf
- Search for this line –
#LoadModule php5_module libexec/apache2/libphp5.so
- Remove the hash and you will have php 5 available for use –
LoadModule php5_module libexec/apache2/libphp5.so
- Save and authenticate
1b – Turn on web sharing in Leopard
- On OS X Go to system preferences > sharing
- Tick the web sharing box
You should now be online!
Enter localhost in your browser, you should see the apache webpage.
You then put your files in /Library/WebServer/Documents
e.g. i put a folder called website inside the Documents folder. I can access this by typing localhost/website in my browser.
Easy!
1c – Optional – changing the location of your websites to the Sites folder in your home directory
Some people prefer not to keep their development files in /Library/WebServer/Documents. Fortunately its very easy to set up Apache so that it gets the files from your Sites folder.
Using a text editor such as smultron, TextMate or command line tool Pico, which lets you open hidden files, open Apache’s conf file on your system at /private/etc/apache2/httpd.conf
On Pico open terminal and type sudo pico /private/etc/apache2/httpd.conf
For TextMatemate /private/etc/apache2/httpd.conf
Find this:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Library/WebServer/Documents"
and replace with the path to your sites folder, mine is “/Users/myname/Sites”, myname is the name of my home directory.
e.g.
DocumentRoot "/Users/myname/Sites"
Then find the code:
#
# This should be changed to whatever you set DocumentRoot to.
#
And change there as well, e.g.
myname
/Sites">
Now when you type localhost into your browser, it will give you the contents of your Sites folder.