ibookserver Setup

my How-to quest to set up a rural dialup server on an ibook g3.

My Photo
Location: Trinity County, East Texas, United States

I'm a lawyer who likes to surf the net, play music and bitch about things I can't change.

Friday, July 01, 2005

More on Getting PHP Up and Running on the way to Hosting your own Forum Server

Her's where we left off... Enabling PHP on your mac running Panther or Jaguar. So you need to get it running? It comes already installed, so all you need to do is follow a few simple steps in Terminal. You already know that when you open up a new window in terminal, the prompt tells you where you are – the “~maybeso” means you are in the home directory because that is how you logged in on your mac in the first place. You need to get to your root directory – All the other web sites that try to help you forget that most folks delving into unix are not geeks – they just want to do something that requires a little knowledge – they forget that you don’t know the basics of the command line interface – (CLI) that is all Terminal is. To get to the “root” directory from your prompt just type in “cd /” without the quotes. You will see something like this :

Garbo:~ maybeso$ cd /

Garbo:/ maybeso$

That “slash” or forward slash means you are in the root directory. Now type in “ls” that is an Ls but lower case. You should see a list of folders and files. Find one named “etc” and then at the prompt type in cd etc

this takes you to that folder or directory. Type “ls” again and you will see another list of files and folders. If you have a folder called “httpd” you are getting closer to your goal. Type cd httpd or cd /httpd to change directories to that one. Type “ls” and you will find a file called httpd.conf. That is the one you want. You are going to change this file, and it is an important file so you NEED to BACKUP this file before proceeding. This file is the configuration file for most of the system-wide settings in Unix. How to back up the file? While you are in the same directory you likely saw a file called httpd.conf.applesaved. That is your backup file for this file. You need to make a backup that you know is pre php changes so we will call the new backup file “httpd.conf.phpsaved. To do this you can do it this way:

Garbo:/etc/httpd maybeso$ sudo cp httpd.conf httpd.conf.phpsaved

it will ask you for your root password.


Garbo:/etc/httpd maybeso$

Now type “ls” to see if the new file is in that directory. If it is go to the next step. You will want to open up the httpd.conf file in a text editor. I use the included unix editor called pico. To open up the file in pico, stay in the same directory you were in. type sudo pico httpd.conf. What this does is tell unix to give you permission (sudo) to edit the file in Pico. Got it open? You should see the following :

## httpd.conf -- Apache HTTP server configuration file

Hehe – fooled you! You didn’t know about the apache server. That is what this file configures and you need this up and running properly to do most things with any server. The highlighted black squares are the commands to do things in the pico editor. To move around you use the Arrow keys. It moves the grey prompt which is the only place you can start typing. The other key commands are basically self-explaining – but for one thing – the Caret thingy in front of the commands such as ^V means to hold the control key while pressing the v key to page down. Got it? To find out more use the help command in pico.

The next thing you need to learn is what the heck the Number sign (#) means. Whenever you see the sign at the beginning of a line that means unix will not read and implement that line of code. It is called commenting the line out. To make a line work, you must uncomment it by removing the number sign at the beginning of the line and all other lines of that piece of code.

Keep in mind that what you are doing is making apache load, run and use PHP whenever it starts up. Next step: you need to find the

“LoadModule php4_module libexec/httpd/libphp4.so

AddModule mod_php4.c”

To find this line in the 1102 lines of the file use the Control W keys to find it and then type the first portion of the line you want to find in the black line and hit return. It will take you there. Delete the # sign by placing the grey cursor to the right of the # and delete it. Then scroll down to the addmodule area – just a few lines down and find the AddModule mod_php4.c and uncomment that line. For Mac os x 10.1 users you may need to add the following line :

addType application/x-httpd-php .php. Do a search using control W and search for addtype. Then cursor down to just below the other addtype uncommented line and add your line.

Back to the rest of the users – panther and jaguar – next find the

DirectoryIndex index.html index.htm index.php

to find it just search for directoryindex index.html. This set is likely to uncommented already – if so, leave it alone – unless you want to add the index.htm type like I did. The important thing here to make sure the index.php is in the directoryIndex line. Got it? Good! Now save that file by using control “O’ that is zero, and save to the httpd.conf file. To exit the pico editor – Control X and you are out!

Now, the easy way to restart apache is to go to your sharing panel in your systems preferences on your regular mac os system It is in your Dock or under the apple – Go to the sharing panel and start the personal web sharing. If it is running – turn it off then back on – that is the easy way to do it. The better, unix way to do it is to do this in Terminal: sudo apachectl restart

Terminal should then tell you apache is restarting.

Now you have to test it out – Remember where you turned on the personal web sharing? Just under the checkmarked box the computer will give you a line that will tell you where your web server is on your computer – in my case it was - your mileage may vary.

Now, to test this php/apache stuff out you need to make a document called info.php and place it in the /library/webserver/documents/ folder. To make this file all you need is an editor that will save as plain text – like Textedit or BBedit. Open a new document in Textedit – and add these lines

< ?php



Remove all the quote marks - they are only in there because the formatting in this blog wouldn't print the code correctly - If you can't get it right, let me know and I will post the file or send it to you.
Make sure you select under the textedit menu FORMAT – make plain text. Then save it as info.php and place it where I said in the paragraph above.
Now, open a new page in Safari and type your web server address Example:

And you should get a page that show you the PHP logo and tells you your php configuration. Congrats to YOU! You are now in the web server bidness! If you have probs, feel free to leave a question or an answer in the comments on this article. Thanks for playing “You’ve got PHP!”

So You Want To Host a Forum Server? You can with just a little know-how.

You see all those forums and Bulletin boards (BBS) that you can get help with computer probs, talk to other people who are into collecting left-handed pliers or used soup spoons - whatever you want, they got! And you asked yourself "why can't I have one of those so I can talk about what I want to talk about?" The answer is - you can! And just like all other servers on the mac, this one is really easy to do - unless you are afraid of a few unix commands. Let's go through the steps.

First, you gotta turn on a few things in your unix kernal. IN order to use the forum software (see my example forum- just Click on the title of this article), you need mysql started, and php started. To see what you have available and running in your Unix underlayer, you need to use the Terminal program that came with your mac os x - you will find it in the aplications folder under utilities - (unixspeak this would be /applications/utilities). First drag the Terminal icon onto your dock and let go - this will give you an alias that will open your Terminal from the dock and it will always be available. Now, open Terminal - it will say something like this: Garbo:~ maybeso$ This tells me that I am talking to Garbo - my other powerbook G3 Lombard mac, the squiggle is a tilde, and since there are no brackets around the Garbo name, I know I am in the Bash shell, and I am logged in as myself, and the dollar sign is the prompt in Bash. To see if you have php installed type in "php -v" do not use the quote marks. It should give you something like this: Garbo:~ maybeso$ php -v
PHP 4.3.11 (cli) (built: May 25 2005 14:03:43)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
Garbo:~ maybeso$

If you don't have php in your system, you can download php for free at any unix or darwin or freeBSD website - download the correct php for your system, but as of this writing, you should not be loading php version 5.x.x - it is brand new, You want php 4.x.x.. Follow the instructions and it will work for you.

Next, you need to start up mysql - You might want to download it from the net and follow the instructions for installing -but, you should have it somewhere in your unix files. Again, use terminal and try to find the folder. More on this later - I have to cook din-din for my wife!

Your Own Mail Server on Your Mac! But first - DYNDNS.org

You already have a mail server on your mac - it resides in the Darwin underlayer of your computer, you know, the FreeBSD Unix layer that drives the modern macintosh computers. Fortunately, you can turn on most of what you need to operate your own mail server by accessing the prefs of the Mail.app (the Eagle Postage Stamp Icon). To serve email to folks that are not on your household or office network (intranet), you need to do a few things under the hood.

First things first - you have to have some way for people to find you on the internet. Most of us have a dynamic IP address that is assigned by your ISP when you connect. Each time you connect, the ISP gives you a new IP address. That is no good if you want folks to get to your server from afar. You could solve this by having your ISP assign you a Static IP Address - but it usually costs more than you are willing to pay. The solution is: DYNDNS, http://www.dyndns.org/, a place where you can get a subdomain name that points folks to your computer.

Let's look at my setup: I have a dialup connection that is connected to my Airport Extreme Base Station w/modem. Whenever it detects one of my computers - connected with a wireless card or through ethernet, the Base Station assigns an IP address based on my settings. I have my server computer set up to have an assigned network address as - the base station is set as The next computer to connect is - get the picture. There are ways of making sure each computer has a permanent intranet IP address, but is beyond the scope of this article. Now, when I coonect with the Base station to my ISP - it assigns a real IP address to the base station that I can use with any of my five computers. The Base acts as a router and translates anything for my server computer and sends the info request on to - my server mac. If I set up a subdomain at dyndns.org, such as: serverman.gotdns.com, the base will now send anything to my server mac if it comes from serverman.gotdns.com. All I had to do to get this free service was to register at dyndns.org, download and set up an application that lets dyndns.org know what dynamic IP my ISP has given me each time I reconnect to my ISP. THe application is called DNSupdate, and you can find it a lot of places. Once set up, DNSupdate will tell dyndns.org every 15 minutes what my IP address is, and whether or not it changed. Dyndns then tells the DNS databases all over the internet what my new IP address is whenver it tries to find serverman.gotdns.com. To recap, People can find your servers even if you have a dynamic IP assigned to you. THe way the base and your mac distinguishes which server someone wants to talk to is by the port number - each server on your computer uses a different port, ftp access is through ports 20 -21, http is reached through port 80, etc. As long as the base know your intranet IP ( - and DNSupdate is working its magic (it loads a daemon in your unix area), and you are connected to the internet, folks can get to your servers - mail, webserver, etc. It's cool to be connected!