Use Mac as a Web Server (1/5)

This article serves two purposes: to show what steps are needed to have a functioning website running on a Macintosh computer, and to remind myself not to forget how to do this later. Yes, I must be dumb. :-P

Okay, you need:

- A Macintosh computer (mine is a Mac mini)
- Mac OS X 'Panther' 10.3.9 or higher (mine is running 'Tiger' 10.4.1)
- Internet connection (direct, or through a router that you can configure)

I'm assuming the OS X installation is of a normal edition, not Server edition. OS X Server already integrates much of the tools needed and configured, so you can skip a large portion of this guide already.

1. Apache

OS X already has Apache web server software integrated (1.3 for normal, 2.0 for Server), so we're off to a good start. To enable this, open System Preferences, and locate 'Sharing' under 'Internet & Network'.

You will notice 'Personal Web Sharing' checkbox under 'Services' tab. Click the checkbox and you'll have the server running instantly. The address to access your instant website is shown at the bottom. Go there and make sure the default pages load. Where are the files, though?

http://address/ --> /Library/WebServer/Documents/
http://address/~username/ --> /username/Sites/

A couple of things to note: 'Library' goes to the root of the Macintosh HDD, not under the username folder, and the ~(username) address looks uncool. Unless the Mac is being used by several people I think we can just go for the first address. The original 'Documents' folder contains default Apache server docs and stuff, so I moved it out elsewhere and have an empty Documents folder for a clean start. From now on I'll refer to this folder as the 'root' since it is the root folder of the website.

Make a simple index.html file on the root to check that you can load the page. That's cool and all, and if static HTML pages are your thing (as I was until this year) then you can skip bunch of stuff and go right into getting a working URL. But as I found out, man, static pages are boring.

2. PHP

The first step to a not-so-boring website is putting PHP: Hypertext Preprocessor, or PHP for short, running on this setup. It's a versatile scripting language that can create dynamic web pages. In other words, it saves you a lot of pain from actual work once you have it do your bidding.

You can read about the PHP by going to the official website I linked above. What we need is an actual installation package. This is where Marc Liyange's PHP module created to work with Apache in OS X comes in handy. I scrolled down to 'Installation Instructions' and got the "PHP 5.0.4 for Apache 1.3" package (version number may change).

Once the .dmg file is downloaded, open it and run the 'php-5.0.4.pkg' package installer. Follow the instructions to finish installing, then make the test page as mentioned in Marc Liyange's site to check that it's working.

With the installation this easy, there's almost no reason for putting off installation. A lot of stuff out there uses it to function and you don't even have to know how to program in PHP to use them, so you miss out a lot if you don't install PHP.

Next up is MySQL. This could be slightly tricky.

Trackbacks

Trackback specific URI for this entry

This link is not meant to be clicked. It contains the trackback URI for this entry. You can use this URI to send ping- & trackbacks from your own blog to this entry. To copy the link, right click and select "Copy Shortcut" in Internet Explorer or "Copy Link Location" in Mozilla.

Wesley's Tool-Box on : Use Mac as a Web Server (Appendix)

Continue reading "Use Mac as a Web Server (Appendix)"
[Related to: Use Mac as a Web Server] After setting up a domain name for your website, you might want to change the domain name setting for phpBB and s9y so you can administer them from anywhere. phpBB Login to phpBB and click Go to Administratio

Wesley's Tool-Box on : Fixing quirks with s9y on the Mac

Continue reading "Fixing quirks with s9y on the Mac"
[Related to: Use Mac as a Web Server] Two issues may come up after installing s9y on the Mac. .terminal{font-family: Times New Roman, Times, Georgia, serif;} 1. Quicksearch Error Attempt a search on the Quicksearch box and you may get this: The s

Wesley's Tool-Box on : Solving IP loopback problem

Continue reading "Solving IP loopback problem"
[Related to: Use Mac as a Web Server] Your Mac, which is also the webserver, is behind a router. You enter your website's domain name on your web browser. You cannot connect. You can still connect via your internal IP address, so the webserver is not d

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

Copyright (C) 1996-2024 Woo-Duk Chung (Wesley Woo-Duk Hwang-Chung). All rights reserved.