mardi 10 novembre 2009

Enable Apache installed in Mac OS X

If you’re running Mac OS X it has some surprises for you. Seems, PHP and the Apache Web Server have been installed on your machine without your knowledge. Well, its no secret but running them both is somewhat of a mystery and the trick is to flush them out of their hiding spots.

Generally on a Mac there are Icons that represent programs and documents that you double-click to execute their existence. With PHP and Apache, they run in the background with no sign of an Icon in sight.

To start Apache Web Server, you must go into the “System Preferences Control panel located on the “Apple Menu”.

Click on the Icon labeled "Sharing". Then locate the tab labeled "File & Web". You will want to click the button labeled “Start” in the "Web Sharing " section. This starts up Web sharing which starts the Apache Web Server.

Apache Web Server is now running. Easy, huh? "How can I tell?” you ask. Simple. Start up your web browser of choice. In the web address or URL part of your browser, type: "localhost" (without the double-quotes)

Ex.
http://localhost

If everything is Okay, your browser will display the following:

"If you can see this, it means that the installation of the Apache Web server software on this system was successful. You may now add content to this directory and replace this page."

It worked! Hooray.

To access the pages of this directory, double-click on your hard drive and locate the "Library" directory. From there locate the "WebServer" directory and then the "Documents" directory where these web pages reside.

Note: If its not running, you either do not have web sharing enabled or something is wrong with Apache's files. It should work right out of the box.

Since Mac OS X is a multi-user system, every person has their own account and with that brings it’s own set of web pages. To access your personal web pages you must type the following in the browser address:

Ex.
http://localhost/~yourname/

To access your personal web pages, locate your account name directory under "Users" And locate the directory labeled "Sites".

/Users/yourname/Sites/your web pages are here <---

Now that you have Apache running, it would be great to write your own PHP scripts and run them locally on your Mac. This is the most difficult part and if you get past this, everything is downhill with ease.

Aucun commentaire:

Enregistrer un commentaire