Apache Web-Serving with Mac OS X: Part 1
by Kevin Hemenway12/07/2001
Editor's note: Most people know that Mac OS X ships with a built-in Apache web server, but don't realize that it's easy to configure and run. In fact, you can host a web site in minutes after completing just a few simple steps.
But that doesn't mean that Mac OS X is a lightweight in this category. It's not. In fact, you can drill down and get very serious with this state-of-the-art serving software.
In this first installment of a multi-part series, Kevin Hemenway shows you how to start serving web pages directly from your Mac. In the articles that follow, he'll show you the techniques that system administrators use for maintaing robust web sites. As you read Kevin's tutorials, you'll learn the functions of some of those mysterious folders deep within your Mac OS X hard drive, and will soon become your own "X" Sys Admin.
You stare at the screen, fingers twitching nervously. You've been telling the rest of the world how great Mac OS X is, basking in the sheer enjoyment of upgrading your Classic applications to jelly-powered delights. After much spouting, your boss has finally given you a chance to prove your saliva-laced rantings. The task is quite simple: "build the GatesMcFarlaneCo [1] intranet with features up the wazoo."
Once again, it's time to convince the herd about Mac superiority. What better way to begin than to use a well-respected web server that's proven its mettle time and time again?
Introducing Apache to the Mac faithful
Apache is regarded as the most popular web server available today. With its incredible portability and support for anything you'd ever want to do, Apple wisely decided to ship Apache with its Unix-based operating system. With this web-serving powerhouse at your fingertips, I'll explain how you can impress your boss and solidify your love for Mac OS X, all at the same time.
Getting started with Apache and Mac OS X
The easiest way to begin Apache web-serving is via your Mac OS X system preferences. Click your Apple Menu, choose "System Preferences," then select "Sharing". Within the Sharing preference panel you'll see a number of options, only one of which is of immediate value. See that Web Sharing label? Simply click the Start button beneath it to fire-up the built-in Apache web server.

Figure 1. Apple has cleverly disguised the Apache Web Server as the "Web Sharing" option in the "Sharing" system preference.
By default, the Apache server has been configured to use your Mac OS X "short" user name. (You can find your short user name in the Users preference panel. Click on "Edit User".) If your short user name is "morbus", for example, you can access your personal web site by opening any web browser on the local network and typing http://127.0.0.1/~morbus/. Don't forget that last forward slash!
That 127.0.0.1 (also known as "localhost") is pretty special -- every computer has one. Both names represent the computer itself; by going to 127.0.0.1 in a web browser, you are accessing the local Apache web server you activated in the Sharing preference panel.
Now that you know an easy way to serve a site to local users, how do make your web pages available to folks on the World Wide Web?
The answer is found in your Sharing preference panel. Go there and note the IP address listed. Using that IP address is how outsiders can access your Apache server. If you see 209.204.146.22, visitors could access http://209.204.146.22/~morbus/ and visit your personal web site. In a future article, I'll discuss how to block outside access to only those you deem worthy.
Your personal web space
If you went to your personal web site now, you'd see a generic introduction written by Apple describing Apache and how to use "Personal Web Sharing." We'll soon be deleting this page, but be sure to give it a read because it contains some helpful bits of information.
Much in the same way your personal web site is based on your user name, so is the location of your web space in the Mac OS X file system. Continuing our assumption of the "morbus" user name, our current web space lives at /Users/morbus/Sites/.
If you browse there now, you'll see the introductory file (index.html) as well as an images/ subdirectory. Delete (or back up) everything, and use a text editor (such as BBEdit) to create a new index.html file with the following contents:
<html>
<body>
<h1>Gleefully Served by Mac OS X</h1>
</body>
</html>
Upon saving, reload http://127.0.0.1/~morbus/, and you'll see your rather bland, boring homepage. This certainly isn't very impressive -- downright pathetic, actually. You can't use server-side includes, can't install CGI programs to your /Sites directory, and can't use PHP or mod_perl. Plus, your inTRAnet is wide open to the InTERnet. Not so good, bub.
Turning on the magic
|
Related Reading
|
What we've done so far won't impress anyone. We have no features and an ugly web site address filled with tildes and unprofessional user names. We've got a long way to go before we can feel good about showing off our masterful Mac OS X box.
Our first step is to give the site a prettier URL. Above, we placed our index.html file into our own user directory (such as /Users/morbus/Sites/) -- now, we'll place a copy into Apache's DocumentRoot. The DocumentRoot is the default server (not user) location that Apache will serve documents from. For Mac OS X, this is located in the /Library/Webserver/Documents/ directory.
This directory also has a default introductory file -- to see it, visit http://127.0.0.1/ within your preferred web browser.
Localization or "content negotiation"
If you browse to /Library/Webserver/Documents/, you'll inadvertently run across another nice feature of Apache: content negotiation. Depending on your visitor, Apache can serve up international versions of your site -- for example, index.html.en for English speakers, or French (index.html.fr)
and German (index.html.de) versions. Apache for OS X comes with over 25 translated versions of the default index.html file.
You can take advantage of this feature on your own pages. When you're creating the GatesMcFarlaneCo intranet in your native language, you can translate your pages into other languages and add the two-letter language encoding ("de" for German", "fr" for French, "es" for Spanish, etc.) to the file name. Any time international employees of GatesMcFarlaneCo access your intranet, they'll automatically be served the page that's in their native tongue.
For now, backup or delete all the
files you see in /Library/Webserver/Documents/ and copy over the index.html file we created a few steps ago. If you return to http://127.0.0.1/, you'll see our "Gleefully Served"
page.
What's next?
This is a good point to catch your breath and play with what I've outlined here. You might want to build some nicer HTML pages to serve as your test site.
In the next installment of this series, I'll tackle CGI access for your Apache server. Until then, enjoy playing with your new Mac OS X web server.
[1] A rather stupid joke within a joke. McFarlane Toys is often considered the "one to beat" in action figures, and thus the loose association with Bill Gates. The combination of the two names resembles "Gates McFadden" who played Beverly Crusher on Star Trek: The Next Generation. Wil Wheaton, who played her TV son, Wesley Crusher, recently announced that he may be reprising his role with a cameo appearance in the final Star Trek: TNG movie. Wesley Crusher is often regarded as the most-despised Star Trek: TNG character, and that's where we make full circle back to Bill Gates. Glad you wondered?
Kevin Hemenway is the coauthor of Mac OS X Hacks, author of Spidering Hacks, and the alter ego of the pervasively strange Morbus Iff, creator of disobey.com, which bills itself as "content for the discontented."
Return to the Mac DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 251 through 335 of 335.
Previous Page
-
connection failure on first use of http://127.0.0.1/~me/
2002-01-31 14:23:37 pablo2001 [Reply | View]
I'm new to this. (spoiled by GUIs on my Mac) When I try to use a browser to go to http://127.0.0.1/~me/ I get a connection failure message. Is Apache located in wrong part of my Mac? -
connection failure on first use of http://127.0.0.1/~me/
2002-01-31 14:28:15 Kevin Hemenway |
[Reply | View]
Is your username "me"? Are you sure that Apache is turned on? What version of OS X do you have? What browser are you using? Are you a dialup user, or are you connected to a network? -
connection failure on first use of http://127.0.0.1/~me/
2002-01-31 17:15:00 pablo2001 [Reply | View]
Oh yes, I'm not on a dial up. My connection is AT&T broadband. -
connection failure on first use of http://127.0.0.1/~me/
2002-01-31 14:51:43 pablo2001 [Reply | View]
Thanks for responding.
My username is not "me". I just used that to state the probblem.
I don't know if Apache is on. I did hit "start" in the web sharing panel. Was that it?
I'm using OS 10.1 and browsing with IE 5.1 browser.
I know absolutely nothing about how to tell if Apache is on.
-
connection failure on first use of http://127.0.0.1/~me/
2002-02-01 06:26:34 Kevin Hemenway |
[Reply | View]
Ok. I think I know where this is leading.
Go to a Terminal, and type "httpd -t". If you see the error message below, then it's a common problem. The URL with more information is also below.
httpd -t
dyld: httpd Undefined symbols:
_apple_hfs_module
http://www.oreillynet.com/cs/user/view/cs_msg/5087
-
Changed the index.html, now getting "forbidden" on both IP's!!
2002-01-28 11:18:44 tatlar [Reply | View]
Hi there - I liked the clear tutorial, but I have had no success viewing my new "index.html" pages. I could see the default ones just fine, but when I made my own ones, I just got the:
Forbidden
You don't have permission to access /index.html on this server.
On both the "127.0.0.1/" IP and my own IP.
Ideas?
Also, using the Terminal window, I don't get a prompt - just the welcome message. What am I doing wrong???
Cheers,
Tatlar -
Changed the index.html, now getting "forbidden" on both IP's!!
2002-01-28 18:03:59 Kevin Hemenway |
[Reply | View]
Not really that much of a clue, actually. You only changed the index.html files, located in /Library/WebServers/Documents/? You didn't change anything else?
What do the last couple of lines in your error log say? To get that info, do the following on a command line:
tail -f /var/log/httpd/error_log -
Changed the index.html, now getting "forbidden" on both IP's!!
2002-03-20 10:41:13 jaymzalgen [Reply | View]
I also get a statfs failed because: No such file or directory
in my error log, What does this mean?
It seems to happen on any page access
although everything appears to be working fine.
Here is the log:
[Wed Mar 20 13:26:07 2002] [notice] Accept mutex: flock (Default: flock)
statfs failed because: No such file or directory
statfs failed because: No such file or directory
statfs failed because: No such file or directory
-
Changed the index.html, now getting "forbidden" on both IP's!!
2002-01-30 13:54:38 tatlar [Reply | View]
Thanks for the help. The error log shows the following:
[Tue Jan 29 08:09:38 2002] [notice] Apache/1.3.20 (Darwin) configured -- resuming normal operations
statfs failed because: No such file or directory
[Tue Jan 29 12:10:29 2002] [error] [client 24.132.68.122] File does not exist: /Library/WebServer/Documents/scripts/.%2e/.%2e/winnt/system32/cmd.exe
[Tue Jan 29 15:15:04 2002] [notice] caught SIGTERM, shutting down
Processing config directory: /private/etc/httpd/users
Processing config file: /private/etc/httpd/users/donut.conf
Processing config file: /private/etc/httpd/users/test.conf
[Wed Jan 30 13:48:14 2002] [notice] Apache/1.3.20 (Darwin) configured -- resuming normal operations
statfs failed because: No such file or directory
[Wed Jan 30 13:48:30 2002] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /Users/donut/Sites/index.html
statfs failed because: No such file or directory
[Wed Jan 30 13:50:17 2002] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /Users/donut/Sites/index.html
[Wed Jan 30 13:50:22 2002] [error] [client 132.239.153.80] (13)Permission denied: file permissions deny server access: /Library/WebServer/Documents/index.html
I have checked, and there is definitely a index.html file in the Site folder of my Users area.
Any ideas?
Cheers,
Tatlar -
Changed the index.html, now getting "forbidden" on both IP's!!
2002-08-09 07:41:03 mrecord [Reply | View]
I was having this same problem for a while. Then I figured out that I had to change the privileges for the items in the directory to "Read Only" (for Group and Everyone). That solved the Permission Denied problems. -
Okay, figured it out....
2002-01-30 16:15:13 tatlar [Reply | View]
Okay, I think I messed up - I replaced ALL the default files with my newwebsite - I guess this threw everything out the window of Apaches default folder. After putting everything back to how it was when I first started messing around, I can now see the old website.
Sorry for the confusion.
I guess that the previous message with the error log just shows me turning web sharing off and on as I tried to figure out what was going on?
Cheers,
Tatlar
-
changing document root
2002-01-28 08:57:15 louabill [Reply | View]
I thought I'd try to follow the instructions, but change the document root to my Site folder. I went through the httpd.conf file, changing both occurrances of /Library/WebServer/Documents to /Volumes/etc. etc. After doing this, Apache wouldn't start.
Is this a really poor idea, or should I take some effort to figure out the solution.
Bill -
changing document root
2002-01-28 08:59:59 Kevin Hemenway |
[Reply | View]
Your Site folder is in /Volumes? To find out what error message Apache is giving you, go to your Terminal, and type:
httpd -t
This will test your configuration file for any problems that could stop Apache from stopping. If there are any, it should spit out why. If you don't understand what it spits out, copy it into here, and I'll help you out. -
changing document root
2004-10-12 20:01:31 diad [Reply | View]
great yes I did that .. but don't understand it.
'{\rtf1\mac\ansicpg10000\cocoartf102', perhaps mis-spelled or defined by a module not included in the server configuration
(I have a question above from today about moving my httpd.config file to desktop and then back again and have apache not working now)
thanks
-
Can access using 127.0.0.1 but not http://localhost
2002-01-26 23:02:19 liamcody [Reply | View]
I'm using OS X.1.
I've turned web Sharing on, and can access my apache server using http://127.0.0.1, but when I attempt to access it at http://localhost, Explorerer gives me a "connection failure" error.
I am connected to the Internet via a modem at the time, but that shouldn't be a problem, should it.
so, any clues? -
Can access using 127.0.0.1 but not http://localhost
2002-01-27 08:41:11 Kevin Hemenway |
[Reply | View]
I've had this happen infrequently as well, but nothing that I could pin my fingers on. Do you have any other browsers on your machine? I've found that when IE chokes, I can normally use iCab or others to open localhost with no difficulties.
-
Cannot access username via the http://127.0.0.1/~username/
2002-01-22 23:28:37 busboy [Reply | View]
I can access my Apache webpage via 127.0.01, but when I use the 127.0.0.1/~me
it doesn't work. I know my username is correct , but it doesn't work.
Any ideas? -
Cannot access username via the http://127.0.0.1/~username/
2007-03-14 14:00:28 broken_idol [Reply | View]
FileVault was causing this issue for me. Check System Preferences > Security to see if FileVault is on. -
Cannot access username via the http://127.0.0.1/~username/
2002-01-23 04:20:15 Kevin Hemenway |
[Reply | View]
Not immediately. What error message do you get? Have you messed with your Apache configuration before? Have you deleted the Sites directory from within your User folder? -
Cannot access username via the http://127.0.0.1/~username/
2002-01-30 07:16:27 agoraphone [Reply | View]
I have the same problem. I get the default apache "this is working" page, but adding /~username/ to the end gives an error 404.
The sites directory is there, with an index.html file in it. It hasn't been touched. The only thing I have touched with the whole configuration was copying httpdconf.bak over httpd.conf, since the server wouldn't start at all before I did that.
Like busboy, I'm typing the username correctly. Any clues? -
Cannot access username via the http://127.0.0.1/~username/
2002-01-31 14:30:46 Kevin Hemenway |
[Reply | View]
Unfortunately, I don't have any clues. You could send your httpd.conf to me at morbus@disobey.com, and I could take a look in there.
I have gotten spurious reports here and there of an httpd.conf file that only contains a few scant lines. A "normal" Apple supplied httpd.conf file should have hundreds and hundreds of lines. How big is yours? -
Cannot access username via the http://127.0.0.1/~username/
2002-11-09 06:25:24 hanssolmssen [Reply | View]
I have developed a similar problem. I get a 403 error in my http://127.0.0.1~username/ , but I can see the http://127.0.0.1/ site. I notice In Netinfo Manager the title of the window is local@127.0.0.1-/ (that has changed) and selecting machines then localhost or broadcasthost, the 3 items in the lower window ip_address, name and serves are grayed out. I can not select them. I did play with this after winstonford offered a way to see a site inside a airport network.
-
Why not iTools?
2001-12-30 20:02:21 hanske [Reply | View]
Thank you for an inspiring article.
I just read an article in a Japanese Mac magazine that recommends iTools (from Tenon) for setting up a web server, since it "uses the world standard BIND 8.2, and makes possible a simple and correct DNS setup." But it's costly, and one gets the impression from your article that all this can be done by hand. What is your opinion on this?
-
Why not iTools?
2001-12-31 07:50:19 Kevin Hemenway |
[Reply | View]
I've actually been contacted by Tenon (the people who make iTools), and I'll be reviewing the complimentary copy they sent me. If it's good, I'll be throwing together a few words on it for the O'Reilly Network. If it's not so good, I'll be mysteriously silent ;)...
Either way, yes, everything that iTools does can be done by hand - it's just a matter of how much time you want to spend learning (and doing) it.
-
Why not iTools?
2002-01-04 01:29:03 hanske [Reply | View]
That's interesting! If one compare to HTML, I think it's safe to say that it's good to start out with simple hand coding (and simple pages) to learn what's going on, but at a certain point a visual tool starts be more practical for the lay out, and BBEdit or the like is better for polishing code, the two working in tandem.
In the case of building a Web server, is the situation the same, i.e., is it better to start out by hand, and then perhaps combine with a visual tool like iTools? In the field of UNIX networking administration on, I haven't done any more difficult task than setting up UUCP on a couple of NeXT machines, but I found it useful to gain some understanding of how the configuration files actually work, setting up permissions correctly etc.
Also, iTools do a lot of things one may not need initially, like eCommerce stuff. So perhaps hand coding is not too bad a path to tread even for a beginner, looking to set up a Web and ftp server? (I also want to do streaming QuickTime stuff) -
Why not iTools?
2002-01-04 06:50:39 Kevin Hemenway |
[Reply | View]
Well, it depends how you look at things. I can sorta agree with your HTML thing, but I *still* use BBEdit to hand code and hand design all my pages - and my first site appeared in 1997. I've never used a WYSIWIG editor for layout - may have used Photoshop once or twice to quickly jot an idea, but I never depend or trust on a WYSIWIG's ability to create what I mean.
>In the case of building a Web server, is the
>situation the same, i.e., is it better to start
>out by hand, and then perhaps combine with a
>visual tool like iTools?
Depends on the purpose or mission. If I'm building a webpage for my dog, I don't really care that it won't show in IE 3.0. But if I'm building an Amazon, then yeah, it better work in Mosaic too.
Same thing with webservers - if I'm going to build a tiny testbed for my PHP coding, or just to sample some CGI or SSI code before I make the junk live, then yeah, a visual editor will save you some time. But if you're actually going to build a webserver that needs to be good at what it does, then I definitely lean toward "learn everything there is and baby it with loving care".
-
Dumb question, I think: IP address
2001-12-28 16:22:34 dafann [Reply | View]
The IP address I see in the Sharing preferences (192.168.1.100) is the default address of my LinkSys router. That address is printed in the LinkSys manual, so it belongs to thousands of devices out there. Surely it is of no use for a personal Web site. What am I overlooking?
Thanks! -
Dumb question, I think: IP address
2002-03-02 15:39:03 dci [Reply | View]
Because of how long it's been since your post I assume you've probably gotten this figured out, but here goes anyway...
When you authenticate to get into your Linksys router you'll see a series of tabs. Click on the status tab and look down and you'll see LAN: and WAN:. Under WAN you'll see "IP Address:". THAT's the IP address you're looking for.
DW -
Dumb question, I think: IP address
2002-01-07 08:19:50 pizzasub [Reply | View]
There are a few IP blocks that are reserved for intranet addresses; 192.168.x.x is one of them.
What this means is that that IP address is only accessible from inside your network. I've got a 192.168.1.100 inside my network, too; but I can only get to it from inside.
Make any sense? -
Dumb question, I think: IP address
2001-12-29 08:41:44 Kevin Hemenway |
[Reply | View]
Sadly, I'm no networking guru, but it sounds like the Sharing preference panel is showing you the IP from the inside of your router - do you know the IP address on the outside (ie. the IP address your ISP gives you?).
Either way, until you figure that IP out, you can still use http://127.0.0.1/ or http://localhost/. -
Dumb question, I think: IP address
2002-01-07 10:13:22 ngb [Reply | View]
The easiest way I've found is to point your browser at http://checkip.dyndns.org and it will return the current IP address and hostname of your router.
You can then write shell script to regularly poll for your IP address and save it on your iDisk or ftp it somewhere else. Direct people to your iDisk web site and it will refer them your desktop machine behind the router.
More details are here:
http://www.macosxhints.com/article.php?story=20011114214229220 -
Dumb question, I think: IP address
2001-12-30 12:57:30 dafann [Reply | View]
According to their FAQ, my ISP (Cox cable) does not allow servers on their system and will not provide static IP addresses.
However, I can still have a Web site on a university server. That might be better, anyway, considering the miserable uplink speed on cable.
Many thanks,
David Fann
-
Ah Ha!
2001-12-22 19:19:28 stoddad [Reply | View]
Your article is a great help. I am an art professor who manages one of the few Mac labs on our campus. The university has moved all of its web to FrontPage Server. I am also responsible for my department's web and I do not find Virtual PC a very eloquent solution to maintaining the website. OS X and Apache has made it possible to serve our own web address. Until your article I had no idea how to get the ~ out of the address. Thanks!
I am interested in knowing if the OS X Apache server will allow me to have more than one static IP or name server addresses on Mac? Any hope that you will address this issue?
David Stoddard -
Ah Ha!
2001-12-24 08:26:44 Kevin Hemenway |
[Reply | View]
David,
Glad you like the articles. To answer your question, yes, you can set up Apache to listen to more than one IP address - the technique is part of something called "virtual hosting". Sadly, we won't be touching on it in our series.
To find more about virthosting with Apache: http://httpd.apache.org/docs/vhosts/index.html
-
great article-will you talk about sendmail & cgi forms?
2001-12-10 20:35:55 mollicat [Reply | View]
Hi;
I enjoyed the article. I have been playing with the webserver in X and am trying to learn about using sendmail & cgi to process web forms (like a user could fill out a repair/maintenance request on a web page and it would be emailed to the appropriate department.)
Sendmail is rather...intimidating. I did manage to get it halfway working but I'm still confused about the Fully Qualified Domain Names and how it uses those,since I don't have a domain name myself.
Any and all info is useful-I look forward to the rest of the articles.
-
great article-will you talk about sendmail & cgi forms?
2001-12-11 20:24:17 chet [Reply | View]
> I have been playing with the webserver in X and am > trying to learn about using sendmail & cgi to
> process web forms...
Yes, how can all the pieces (sendmail, postgres, Apache, PHP, Python, Perl, MySQL) be made to play
nicely together on OS X? -
great article-will you talk about sendmail & cgi forms?
2002-01-04 10:11:40 mr_t [Reply | View]
It would be great if they could get an article together on using sendmail with Perl.
I got so frustrated with sendmail, that I eventually used MacPerl to AppleScript to Eudora on Mac OS 9. This isn't too bad, but I'd much rather have it all run on Mac OS X.
Perhaps another article on using OS X Perl with AppleScript?
-
dk = Denmark, de = Germany
2001-12-10 16:58:47 bubbasixpack [Reply | View]
I suppose it must be common to mistake all germanic languages for German - my son's potty chair has the german word: "Achtung!" for the warning, but the text underneath is Dutch. They did the opposite for the Dutch warning... Way to go Wal-Mart :P -
dk = Denmark, de = Germany
2007-01-23 08:21:43 bobga [Reply | View]
You actually shop at Walmart?
I haven't set foot in one for 5 or 6 years. Even though my neighbors say that they have the best produce in town (small town!), I won't do it and I encourage everyone I know to avoid Walmart. I was in The Hague once and heard an American tourist (which I was at the time too) ask a Dutch person if they spoke German in bad German (i.e. reading from the German <> English Dictionary). Apparently, they visited The Netherlands without understanding the history of the Dutch and the Germans.
Down with Walmart! -
dk = Denmark, de = Germany
2001-12-12 22:40:37 jonasmunk [Reply | View]
Please don't mistake danes with germans, it makes me sad -
dk = Denmark, de = Germany
2001-12-10 17:15:02 Kevin Hemenway |
[Reply | View]
Yup, you're right, but not the first ;) ... See: http://www.oreillynet.com/cs/user/view/cs_msg/5063 - this should be fixed in the main text shortly...
-
Good start...
2001-12-10 13:42:49 djwudi [Reply | View]
...and I'm looking forward to the rest. I've managed to muddle some of the more advanced features (cgi, customising the httpd.conf file, and so on) for my site, but I'm sure there's bits I've overlooked, and hopefully when you touch on PHP that'll give me a jumping point to start diving into that. Thanks for the series...
-
Apache won't start
2001-12-10 06:03:44 wcostain [Reply | View]
Hi, I am running OS X on an ibook, and when I try to start web sharing, the button grays and nothing happens (ie, the button doesn't become a stop button). When I check the active processes, no httpd. Any ideas?
-
Apache won't start
2001-12-10 12:01:53 loren3 [Reply | View]
i had the same problem. see recent article in macfixit os x section. i
looking at the console, i saw i was missing a file called:
/etc/httpd/httpd.conf
there was a file called:
/etc/httpd/httpd.conf.bak
i went to the /etc/httpd/ directory and duplicated the backup file as:
%sudo cp httpd.conf.bak httpd.conf
then it worked.
who knew.
-
Apache won't start
2001-12-10 08:07:40 Kevin Hemenway |
[Reply | View]
Do you know how to get into your Terminal? If so, run "httpd -t". What do you get for output? What version of the OS are you running? -
Apache won't start
2001-12-10 12:28:30 wcostain [Reply | View]
I am running 10.1.1
[wcostain:~] willardc% httpd -t
dyld: httpd Undefined symbols:
_apple_hfs_module
Seems to be the same as the other guy. -
Apache won't start
2001-12-10 12:42:37 Kevin Hemenway |
[Reply | View]
This is a common problem after updating to 10.1. There's a Apple Knowledge Base article that will explain how to fix it in depth:
http://docs.info.apple.com/article.html?artnum=106505
Unfortunately, you do need a username and a password to see this document. For a quicker explanation, check out this article:
http://www.stepwise.com/Articles/Technical/2001-09-29-01.html
It's under the "Apache breaks upon update" heading. I have to admit that I haven't run into this error myself, but the answers I've seen are solid and make sense, so things should go smoothly for you.
-
How to serve up during sleep
2001-12-10 01:43:51 dowobeha [Reply | View]
I have Mac OS X's serving up some nice stuff here on my machine at home. Unfortunately, the content's not accessible when the machine is asleep.
Is there any way around this. I don't really want to leave the machine awake all the time.
Thanks,
Lane Schwartz
los20@cam.ac.uk -
How to serve up during sleep
2001-12-10 13:23:25 djwudi [Reply | View]
You do have to leave the system awake, unfortunately. I've been running a site on my OS X box (original Rev. A iMac) since the Public Beta, and I set the system and the hard drive to 'never', while setting the display to sleep after 15 minutes. That at least saves me the electricity from the monitor being on all the time. -
How to serve up during sleep
2001-12-10 07:53:17 Kevin Hemenway |
[Reply | View]
Lane, unfortunately, I personally don't know of any way. After doing a quick search through Google and the various Mac forums as well, nothing magical popped out either. Sorry!
-
sleeping on/off
2001-12-09 19:52:05 sryu [Reply | View]
Shouldn't the mac be kept from sleeping to
serve the web pages?
-
sleeping on/off
2001-12-10 07:51:54 Kevin Hemenway |
[Reply | View]
That would be correct -the Mac has to be told NOT to sleep to continue serving web pages. Thanks for reminding the readers. (For those who don't know, to do so, go to your "System Preferences", and choose "Energy Saving". From there, move all sliders to "None".)
-
International
2001-12-08 17:45:32 areh [Reply | View]
An uninformed question: Shouldn't it be .de for German (instead of .dk) ? -
International
2001-12-08 19:30:39 Kevin Hemenway |
[Reply | View]
You are correct - this is an error purely on my part. .dk is for Denmark, .de is for Germany, and .da is Danish. Also of interest is these notes from Apache's configuration file:
# Note 2: The example entries below illustrate that in quite
# some cases the two character 'Language' abbreviation is not
# identical to the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
-
configuration httpd.conf
2001-12-08 11:19:39 mcollins@kuwago.com [Reply | View]
Considering this is the O'Reilly Web site I expected this simple introduction to ramp up quickly from intro remarks to something a bit more technical. For example, mention of the file located at: /etc/httpd/httpd.conf. How about a few words on what things one might want to change at a minimum in the Apache configuration file (and what role this file plays). -
configuration httpd.conf
2001-12-08 14:14:08 Kevin Hemenway |
[Reply | View]
Yup, you can expect all that stuff in the second part, which is really the intro to that file, exploring it as we learn about CGI, and also a teensy bit about the httpd daemon itself. -
configuration httpd.conf
2001-12-10 17:41:08 sjmagy [Reply | View]
Are you going to touch upon the .conf file that is also unique to each user?
I was working just this past weekend on setting up Apache for the very first time (following instructions from a MacWorld article). After editing httpd.conf and enabling the options I wanted, I *still* couldn't see sites ("Forbidden -- you don't have access, blah blah") even though I should have according to the conf file.
Turns out, as I was browsing around, if you have multiple users set up on your OS X box, the system creates a username.conf file for each user, which is in the etc/httpd/users directory path. If you don't also edit that file, then certain options don't get turned on, even if they are turned on in the main httpd.conf file.
Primarily, I was trying to enable "Includes" and turn off "Indexes". If I didn't edit my own username.conf file to also enable "Includes", the functionality just plain didn't work....
If you can provide some more thorough info. RE: access control, etc..., that would also be great! -
configuration httpd.conf
2001-12-10 17:48:31 Kevin Hemenway |
[Reply | View]
Sjmagy, we won't be specifically touching on the user .conf files because they don't fall into the example intranet that were building in the series. However, we will go into SSI's and turning them on, as well as access control. Modifications that we make to the httpd.conf for those features can also be entered (with no change in syntax) into your specific user .conf files. -
configuration httpd.conf
2001-12-10 12:08:53 loren3 [Reply | View]
no doubt... i learned from this page that i had to type:
http://<myip>/~myshortname
i had been frustrated that i was typing just http://<myip> and I was getting the apache default page even tho i had already replaced the index.html file in my ~/Sites/ folder.
so that clarified that much.
but what if you don't want to use your short name? how do you reconfigure it so that:
a) it goes straight to your user index.html file with http://myip (without having to build your site in the /Library/WebServer directory...)
or
b) create some kind of alias so that each user can have his/her own page but not necessarily use their short name to define it, as in:
http://myip/~animals (for the site owned by user "morbus") and http://myip/~cars (for the site owned by user "Joe")
thanks.....
also, is there ANY decent WYSIWYG html editor for OS X??
and... How do you use BBEDIT to create a simple go to blah link???? believe it or not I couldn't figure that out.
-
configuration httpd.conf
2001-12-10 14:28:38 bbicapslock [Reply | View]
Straight to user index file:
Change <Directory "/Library/WebServer/Documents"> to <Directory "/Users/whatever/Sites"> ("whatever" should be replaced by your short name.)
Different users to different pages:
If it's not going to be systematic then you'll need one line for each user. One way to do it is to use alias, for example, to alias cars and Joe from your example.
You could also create some rewrite rules and let mod_rewrite take care of it.
(Check the apache doc files shipped with OSX for syntax.) -
configuration httpd.conf
2001-12-10 13:36:09 djwudi [Reply | View]
Since BBEdit is 'just' a text processor, the easiest way to put a link in is to just type the HTML code for the link in. Since you added the link to go to blah link to your post, I'm assuming you know that much HTML code, so it should work fine.
Don't know about WYWIWYG editors, though - personally, I've never liked them. I've been coding my site with BBEdit, Pepper (another OS X text editor), or vi ('cause I'm a glutton for punishment) long enough that I've never liked any WYSIWYG editor I've played with.
For pages under URLs such as http://yourip/animals/ or http://yourip/cars/ and such, those would just be subdirectories within...well...
(My apologies if I'm jumping ahead in the lessons here...)
As morbus said, the url http://yourip/~yourname/ points to your /Users/yourname/sites/ directory. However, the base url http://yourip/ points to the /Library/WebServer/Documents/ directory. Creating a subdirectory called 'cars' in there would give a system path of /Library/WebServer/Documents/cars/ that would be accessible from the outside as http://yourip/cars/ and would display whatever was inside the 'cars' directory. That's the easiest way that I can think of. The user (Joe, in your example) would still have to navigate to that folder rather than having it residing in his home directory...but if you really wanted to then, I suppose some creative aliasing could take care of that. -
configuration httpd.conf
2001-12-11 15:25:50 loren3 [Reply | View]
thanks for the reply...
with regard to subdirectories issue:
1. i would want to avoid users--including myself once i got apache set up--from mucking about in the /Library directory! not a good idea IMHO.
2. i've had terrible experience with aliases when it comes to system files in OS X, such that my principle is don't do it. i created some hard symbolic links and mucked things up badly before.
3. i did find a suitable solution, which is to create an account with www.dyndns.org and set up free domain names linked to your ip (or dynamic ip). then you can set up the httpd.conf file to use virtual hosts, which is pretty easy to do. so each user can have his/her own domain name and have that go to anywhere it his/her user directory.
with regards to bbedit, yeah sure i can code a simple link. but so what? bbedit has a whole markup toolbar to do nifty things wiht GUI like inserting inline images. The one thing I can't figure out immediately is how to create a link with that toolbar.
unlike many hardcore html coders, i'd rather use dialog boxes than manually do all the tags.
-
configuration httpd.conf
2001-12-10 12:50:02 Kevin Hemenway |
[Reply | View]
loren3, to answer your questions:
a) It's possible. Probably the quickest way to do so is to go into your httpd.conf file, search for "/Library/Webserver/Documents" and replace it with the full path to your user directory. When you see a line that says something like "<Directory /Library/Webserver/Documents>", then that's the place you want to change. Messing around with the httpd.conf is touched upon in later parts of this series.
b) Possible, but will not be touched upon in this series of articles. Generically speaking, the "~" is special in the sense that it denotes a username - if you really wanted "animals" and "cars" owned by separate users, then you should just do http://myip/animals/ and http://myip/cars/. That's left for you to figure out though.
As for WYSIWIGs, dunno, never used them. As for BBEdit, this is the wrong place to ask ;) ...
-
configuration httpd.conf
2001-12-10 13:20:33 loren3 [Reply | View]
- if you really wanted "animals" and "cars" owned by separate users, then you should just do http://myip/animals/ and http://myip/cars/. That's left for you to figure out though.
...sorry i can't figure that out... that's why i came here looking for clues, not being a web admin or anything.
my only guess is that you would have to set up some kind of redirect from a main page. but i don't know enough about either that level of html or about relative path names to figure that out.
i've already run into problems trying to link to images outside of the sites folder (even in the ~/Pictures/ directory!) with relative pathnames and apparent lack of privs.
-g
-
great job again
2001-12-08 09:05:08 sssss1 [Reply | View]
I like this. I'm also waiting for the richer (geekier :) content, but this seems like a great introduction for everyone. My dad could be serving web pages with this - which is the Promise, right? Great job!
2 humble suggestions -
My dad will get hung up on the new OS X specific "/Library/directory/folder/" thing. You may want to walk people more slowly through the first time you use this.
And, please cover folder-specific password access. Please!
s -
great job again
2001-12-08 09:20:31 Kevin Hemenway |
[Reply | View]
Hey sssss (ever see that snake horror flick? oh, nevermind <G>)...
Anyways, the "/Library/directory/folder/" has been in Macs for a while actually - just using a different delimiter. Were I talking in Classic/OS 7-9 lingo, this would be "Mac HD:Users:morbus:Library:directory:folder". In some geekier Classic/OS 7-9 cases, you'd actually use this - if you were coding in MacPerl, for instance, or using a Unix ported utility like cron <URL: http://gargravarr.cc.utexas.edu/cron/>. Describing it was out of the scope of this article (as is how to use the Terminal, which we start using in part 2). I've been told that O'ReillyNet is publishing an Intro to the Terminal though, so there should be no problems there.
As for the password auth access, I'll try to squeeze it in once we get into that area of our journey.
Thanks for the comments.
-
Perl and CGI.pm
2001-12-08 02:14:50 kenyatta [Reply | View]
the above article is fine, ok, and more or less easy to figure out. Let's get to the juice. I was able to find tutorials that explained how to build Apache (the latest build) on Mac OS X along with installling and configuring php4.0.
Hopefully some one will address perl
-
Perl and CGI.pm
2001-12-08 07:00:46 Kevin Hemenway |
[Reply | View]
Kenyatta, we talk about php in a future article, yes. But what would you want to know specifically about Perl? -
Perl and CGI.pm
2001-12-12 09:58:55 kenyatta [Reply | View]
Specifically for Perl? Basically how to configure it for Apache, including the popular Perl module CGI.pm.
I found to useful tutorials for building and configuring PHP/MySQL for Apache on Mac OS X on hotwired.com and www.stepwise.com or (www.darwinos.com).
I've noticed that some books are being release targeting web serving using the Unix underpinnings of Mac OSX.
Thanks in advance for any information -
Perl and CGI.pm
2001-12-18 07:48:47 tmana [Reply | View]
Are you asking about mod_perl? 'Regular' Perl (including the CGI module) doesn't need to be configured for Apache. Though Apache does need to be configured to allow cgi scripts.
I don't remember the specifics off the top of my head but basically there's a SetHandler line in the Apache conf file (which I believe comes commented out...) to the effect of:
SetHandler cgi-script cgi
where 'cgi-script' tells Apache to handle anything with an extension of 'cgi' (and you can add other extensions such as 'pl') as a cgi program.
There's a couple Apache configuration books out there - including O'Reilly's - that will explain it better than me. -
Perl and CGI.pm
2001-12-10 14:07:08 cochella [Reply | View]
I would like to see info on using CPAN to install CGI.pm, libnet.pm, and DBI/DBD.
I have tried to do this and gotten stuck because the OSX Perl install is "non-standard" according to the CPAN module.
Also, with respect to PHP it would be nice to see some info on compiling PHP with different options (MySQL, PDF, XML, DOM,...) for different user/virtual host directories.
I hope this helps guide the future.
Good article! Clear, concise and it works. Many articles do not workout.
Chris
-
Good job
2001-12-08 00:37:13 mcamille [Reply | View]
Good job on part 1. Coming from MS's IIS, I am anxious to know more about Apache. Your introduction to Apache on OS X was very clear. I hope you can maintain that clarity when you get to how you do password authentication in Apache. I look forward to reading the next installments.
Milt Camille -
Good job
2007-04-10 03:29:06 ermileo [Reply | View]
my name is Ermias Shewareged, i am an accountant
in NGO company.i love foot ball and a fan of Arsenal club. i want to work my profession or any other job.my full adderess is
ermias Shewareged
p.O.Box 1909
Nazareth
Ethiopia
TeLe 251 221 110614 -
Good job
2007-04-10 03:25:47 ermileo [Reply | View]
my name is Ermias Shewareged, i am an accountant
in NGO company.i love foot ball and a fan of Arsenal club. i want to work my profession or any other job.my full adderess is
ermias Shewareged
p.O.Box 1909
Nazareth
Ethiopia
TeLe 251 221 110614 -
Good job
2001-12-08 07:03:21 Kevin Hemenway |
[Reply | View]
Mcamille, glad you liked the first part. When we actually do talk about authentication, we focus mostly on location-based authentication, and not password control. I'll see what I can do to throw in a few snippets about passwords and generating them, and so on and so forth.






