Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Apache/10.1 errors

Apache/10.1 errors
Thread Tools
bluehz
Dedicated MacNNer
Join Date: Feb 2001
Status: Offline
Reply With Quote
Nov 5, 2001, 08:44 AM
 
I have followed all the directions found around and disabled the Apple_HFS line within my httpd_conf file, yet I still can not start Apache via the terminal unless I am logged in as ROOT. Every time I try to start via terminal I get some error "fopen". Although I can start web sharing via the control panel with no problems. I feel like the server is running and I can access pages, etc. but I am not sure it is functioning 100% considering I get the above error and can not startup Apache via the CLI.

Any one have any suggestion how to fix this?
     
Millennium
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Nov 5, 2001, 09:37 AM
 
OK, to explain this one, it's time for a little lesson in network sockets.

Most computers have only one network interface, maybe two or three for those with AirPort, Ethernet, and a modem, and even then they generally only use one at a time. However, it's obvious that people need to be able to make multiple connections at once; otherwise, you couldn't use a Web server or any other network stuff, or you wouldn't be able to check e-mail or instant messages while surfing the Web. So how is this possible?

Unix (or, to be more accurate, TCP/IP), solved this problem by creating a concept called sockets. Each socket represents one connection. Every network packet which goes on your machine is tagged with the socket it's meant for. That way, even though there's only one stream of data going into your machine, it can carry many connections, and they won't get in each other's way.

Now, each machine has a whole lot of sockets: 65,535 of them to be exact. Each interface (whether it's an Ethernet card, AirPort card, modem, or whatever) has its own set of sockets, and each socket has its own number. And the machine itself has yet another set which doesn't use the network; applications can use these to talk with each other. Sockets which use the network are also called "ports"; you might have heard that term before. But anyway, when a server starts up, it "opens" one of these ports and "listens"; that is, it waits for people to connect to it. Normally, these numbers are well-defined; the Web uses Port 80, for example, while FTP uses Port 21.

Now, there's one catch: by convention, only root can open sockets with numbers less than 1024. This was done so that there would be a set of "trusted" sockets; when you connect to one of these on another machine, you know it should be safe, because only that machine's root user could have opened that socket. It's a security issue, basically. Not much of one, but every little bit helps.

Remember what I said about the Web using Port 80? Well, that's why you can't run Apache except as root. Apache wants to use that port, but only root can open it. When you run as anyone else, it can't open the port, so it fails. Web Sharing doesn't actually gets around this restriction; it uses sudo (or something along the same principles) to get Apache to run. By the way, it's important to note that Apache does not run as root all the time; it stays as root only long enough to open that port, and then it switches to another, less dangerous user (usually "www").

How can you work with this? Well, there are a couple of ways. First, use sudo to run Apache (and disable that root account while you're at it). If you don't want to do that, then configure Apache to use a high-numbered port (it's customary to use port 8000 or 8080 if you want to do this but any port from 1025 on up will work).

By the way, what are you using to run Apache from the Terminal? You should be using the apachectl command. Just checking to make sure.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
bluehz  (op)
Dedicated MacNNer
Join Date: Feb 2001
Status: Offline
Reply With Quote
Nov 5, 2001, 10:34 AM
 
Excellent advice! You answered my question exactly. I know all about ports but i was unaware of the root/ports>1024 issue. This actually works out best for me anyway - because I have another machine I run as a primary webserver on 80. This way I can use 8080 and have the router direct port 8080 to the OS X machine.

BTW - I am using apachectl to start Apache in the CLI.

One other question (and this may be solved by the whole root/port>1024 issue)...whenever I have been attempting to apachectl and getting that fopen error, immediately after that I get another error:

"could not open error log file /private/var/httpd/error_log"

I checked the permissions on that file and set them to 755 and still get the error. Is this a related issue?

Thx for the great info!
     
bluehz  (op)
Dedicated MacNNer
Join Date: Feb 2001
Status: Offline
Reply With Quote
Nov 5, 2001, 10:44 AM
 
Changed the port to 8080 and tried apachectl again and I still get the fopen and error_log open errors.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:14 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,