fbpx

apache en os x leopard

February 27, 2008

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

  1. 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 TextMate
    mate /private/etc/apache2/httpd.conf
  2. Search for this line –
    #LoadModule php5_module libexec/apache2/libphp5.so
  3. Remove the hash and you will have php 5 available for use –
    LoadModule php5_module libexec/apache2/libphp5.so
  4. Save and authenticate

1b – Turn on web sharing in Leopard

  1. On OS X Go to system preferences > sharing
  2. 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 TextMate
mate /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.

avatar
Gonzalo Escribano

Ver entradas

Most Recent

June 9, 2022

¿Qué son las DAO y cuáles son sus beneficios?

Es común en la historia contemporánea que haya cambios a partir de los avances en el campo de la...

Read More

June 2, 2022

¿Qué son las DeFi y por qué son el futuro de las finanzas?

Es común en la historia contemporánea que haya cambios a partir de los avances en el campo de la...

Read More

May 27, 2022

How to start a successful product build from scratch?

Creating a product from scratch could be a huge challenge. To achieve your business goals it’s important to develop...

Read More