[D.I.Y.] ............ [.] [overview]
Want to host your own website? With Mac OS X 10.3 and just a little bit of creative and technical know-how, you can do just that. And to prove just how humbly true that statement is, Elsinor.com is itself hosted on a 333Mhz Strawberry iMac, sitting in our friend's closet up in Fremont, running Mac OS X. So there's really no magic (except maybe a little ImageMagick) involved in transforming your Mac into a powerful webserver, you just have to know which toy chest to root around in. The following article is a brief textual illustration on how to do such.
[.] [apache] Mac OS X 10.3 ships with Apache 1.3.29, which is the web server software that runs, like, almost all of the internet. The great thing about Apache is that everything is scalable, by which I mean that if you want something turned on (i.e. SSL), you simply tell it so. Since it ships with most everything you need turned on by default, making your Mac a world-accessible webserver is as easy as the click of a proverbial button: Just go to your Sharing System Preference Pane and click the "Personal Web Sharing" box. That's the easy part. The hard part is giving them something to look at.
Of course, the above only works if you have physical access to the machine running the GUI. If you're remote administering a Mac through ssh, then you can respectively start/stop/restart apache the old fashioned way:
[.] [php] PHP is a web scripting language that is very popular, modular, and plays well with others. In fact, the program I use for the forum, phorum, is a PHP program. What's beautiful about programs like this is that you don't need to learn any scripting or programming- you can just unpack the files and you're pretty much ready to go.
PHP is turned off by default in OS X 10.3. To enable it, uncomment (remove the # from the beginning of the line) the following two lines in /etc/httpd/httpd.conf (be sure to make a backup of your httpd.conf file first!):
[.] [mysql] MySQL is the standard bearer when it comes to open source database structures. While Mac OS X Server ships with MySQL pre-installed, we normal Mac users have to install it. Luckily, there are several ways to do so, each with its benefits.
1. Grab the installer straight from Apple, which includes a handy Preference Pane for turning MySQL on/off and setting the root password.
I recommend the fink method for two reasons: It will also install other packages you might not know you need, such as the
When you get mysql installed, be sure to heed the oft-remarked danger call and create the root password. Once that's done, you're ready to begin hosting databases. Now, if you're only going to be using mysql to run a bbs or some other pre-crafted website, you only need to know a few commands within mysql: creating a database; and creating a username while giving privileges on said database to said username. Given the database named foo and username bar, it would look like this:
[.] [ftp]
Mac OS X 10.3 ships with a built-in ftp server. Much like turning on Personal Web Serving, all you need to do to turn on the ftp server is to click the checkbox in the Sharing System Preference Pane. Along with the standard ftp server is a more secure sftp server. The process is the same- you just type [.] [virtual hosts]
You can serve as many different websites from your machine as you want, via name-based virtual hosts. While all the sites will resolve to the same IP address, to the client browsers they will seem independent of each other. You do this by adding the virtual host information to your /etc/httpd/httpd.conf file. For example, if you wanted to host both www.foo.com and www.bar.com from your Mac, you would edit the file thusly (scroll to the end of the file where the Virtual Host information is kept):
[.] [logs]
Logs can be extremely useful, providing you with the who/what/where information regarding incoming connections. Your system's apache web logs are located at /var/logs/httpd/access_log and /var/logs/httpd/error_log. The names pretty much speak for themselves. By default, they use the common format, which provides you with pretty much the date and time of request, and which page was requested:
[.] [conclusion] As you can see, it's very easy to turn your ittle-wittle iMac into a full featured web server. Be aware, however, that many of the technologies involved are not 100% secure, and you are potentially opening yourself up to crackers- particularly if you insist on turning on the built in mail server, postfix, which I won't cover for that very reason. Please be sure to read up on the services you are turning on, and use smart passwords! Good luck! [.] [relevant links]
Fink info page
|