The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Apache won't start (http://hintsforums.macworld.com/showthread.php?t=27330)

DJ_Max 08-26-2004 04:06 PM

Apache won't start
 
Hello all, I've been around these forums but never signed up. Anyway, thats not my problem. For some odd reason, whenever I do
sudo apachectl start
it ask for my password, so I enter it correctly, put I still get this error.
Code:

/usr/sbin/apachectl: permission denied: /etc/httpd [71]
/usr/sbin/apachectl start: httpd could not be started

When I got to System preferences, and try to enable web sharing it won't start either.

This is odd, as the day i installed 10.1, I was running Apache fine.

I ran apache configtest, I still get a permissions error.

I also did a ls -ld on /etc/httpd
Code:

drwxr-xr-x  11 root  wheel  330 Jul 15 19:04
Any help would be good.
Mac OS 10.1.5

nkuvu 08-26-2004 04:35 PM

First, can you use sudo for other commands successfully? Maybe the authentication isn't working correctly*. When I try to run just apachectl graceful, I get permission denied errors (as well as "httpd is not running, trying to start" even though it is running).

Second, what does ls -l /usr/sbin/httpd say**? I have the same result on my /etc/httpd directory that you do.


* I've seen this happen before, so if this is the case you could search the forums and probably find the solution.

** Assuming that which httpd returns /usr/sbin/httpd on 10.1.5, I'm on 10.3.5 so things may have changed (but I doubt it).

DJ_Max 08-26-2004 04:59 PM

Thanks for your reply.
Yes, I can use sudo for other things, such as editing files and such.

ls -l /usr/sbin/httpd returns:
Code:

-rwxr-xr-x  1 root  wheel  397048 Jul 31  2002 /usr/sbin/httpd

nkuvu 08-26-2004 05:10 PM

Hmm. I'm not sure if the potential version difference is the reason for the size difference, but my httpd is listed as
Code:

-rwxr-xr-x  1 root  wheel  398492 26 May 20:09 /usr/sbin/httpd
What version of Apache are you running? I don't remember what came as default on 10.1.x. You can find out via httpd -v (if you didn't know that already).

Any recent changes to your httpd.conf file?

Wild guessing here... what do you get with ps -aux | grep http ?

DJ_Max 08-26-2004 05:18 PM

I'm running 1.3.26.
I haven't even been in terminal after the last time I had Apache running.
ps -aux | grep http returns this.
Code:

daejuanj  476  0.0  0.1    1412    316 std  S+    0:00.01 grep http

hayne 08-26-2004 06:03 PM

1) To double-check that 'sudo' is working properly, please show us the results of the following command:

sudo id


2) /usr/sbin/apachectl is just a shell script so you can look at it and maybe see why it is going wrong. Or maybe add some extra debugging lines in the script to help understand what is happening. Or just manually execute the commands that the script does and see what happens.

DJ_Max 08-26-2004 06:31 PM

Quote:

Originally Posted by hayne
1) To double-check that 'sudo' is working properly, please show us the results of the following command:

sudo id


2) /usr/sbin/apachectl is just a shell script so you can look at it and maybe see why it is going wrong. Or maybe add some extra debugging lines in the script to help understand what is happening. Or just manually execute the commands that the script does and see what happens.

Ok, sudo id shows
Code:

uid=0(root) gid=0(wheel) groups=0(wheel), 1(daemon), 2(kmem), 3(sys), 4(tty), 5(operator), 20(staff), 31(guest), 80(admin)
I'll take a look at that file, and see what I can do.

Gnarlodious 08-27-2004 02:10 PM

Consider taking a look at the errorlog:

open /private/var/log/httpd/error_log.log

You can also say:

apachectl configtest

for a report on the configuration.

-- Gnarlie

nkuvu 08-27-2004 02:27 PM

Have you tried repairing disk permissions? I'm not sure if it affects the files in /etc, but it's worth a shot.

DJ_Max 08-27-2004 03:21 PM

Quote:

apachectl configtest
Yeah, did that before but got a permissions error:
Code:

/usr/sbin/apachectl: permission denied: /etc/httpd [145]
Quote:

Consider taking a look at the errorlog:

open /private/var/log/httpd/error_log.log
Says No Such file.

Quote:

Have you tried repairing disk permissions? I'm not sure if it affects the files in /etc, but it's worth a shot.
I'll boot up from the cd after this post. And see what it does.

hayne 08-27-2004 03:43 PM

Quote:

Originally Posted by DJ_Max
Yeah, did that before but got a permissions error:
Code:

/usr/sbin/apachectl: permission denied: /etc/httpd [145]
Says No Such file.

Please copy & paste the results of the following commands back here so we can see:

ls -ld /etc
ls -ld /etc/httpd
ls -l /etc/httpd


Quote:

I'll boot up from the cd after this post. And see what it does.
To repair permissions (as opposed to "Repair Disk") you don't want to boot from the CD. You should run "Repair Permissions" from the Disk Utility when booted from the hard disk that you want to repair permissions on. Using the one on the CD will use an obsolete version of the list of correct permissions (under /Library/Receipts)

DJ_Max 08-27-2004 04:13 PM

Ok, from ls -ld /etc
Code:

lrwxrwxr-t  1 root  admin  11 Aug 27 15:03 /etc -> private/etc
ls -ld /etc/httpd
Code:

drwxr-xr-x  11 root  wheel  330 Jul 15 19:04 /etc/httpd
ls -l /etc/httpd

Code:

total 448
-rw-r--r--  1 root  wheel  37438 Aug 26 15:59 httpd.conf
-rw-r--r--  1 root  wheel  37323 Nov 13  2001 httpd.conf.bak
-rw-r--r--  1 root  wheel  37441 Nov 13  2001 httpd.conf.default
-rw-r--r--  1 root  wheel  37439 Jul 15 18:48 httpd.confy
-rw-r--r--  1 root  wheel  12441 Nov 13  2001 magic
-rw-r--r--  1 root  wheel  12441 Nov 13  2001 magic.default
-rw-r--r--  1 root  wheel  12322 Nov 13  2001 mime.types
-rw-r--r--  1 root  wheel  12322 Nov 13  2001 mime.types.default
drwxr-xr-x  4 root  wheel    264 Jul 28 14:12 users

Quote:

To repair permissions (as opposed to "Repair Disk") you don't want to boot from the CD. You should run "Repair Permissions" from the Disk Utility when booted from the hard disk that you want to repair permissions on. Using the one on the CD will use an obsolete version of the list of correct permissions (under /Library/Receipts)
Yeah, I don't have that option in Disk Utility, verfy & repair are grayed out.

kfaulhaber 08-27-2004 04:25 PM

Quote:

Originally Posted by Gnarlodious
/private/var/log/httpd/error_log.log

No .log at the end. Just /var/log/error_log


It is remotely possible that there is a leftover run file that it can't delete. Check for the existence of /var/run/http.pid


Also, apachectl is a sh script to make life easier. It would be interesting to see the output of httpd -t the equivalent of apachectl configtest.

DJ_Max 08-27-2004 04:29 PM

Quote:

Originally Posted by kfaulhaber
No .log at the end. Just /var/log/error_log


It is remotely possible that there is a leftover run file that it can't delete. Check for the existence of /var/run/http.pid


Also, apachectl is a sh script to make life easier. It would be interesting to see the output of httpd -t the equivalent of apachectl configtest.

Ok, I forgot about that. First I got this,
Code:

Syntax error on line 281 of /etc/httpd/httpd.conf:
Cannot add module via name 'mod_php4.c': not in list of loaded modules

I tried to comment out that file, still nothing.


As for the other files, they didn't exsist. (/var/run/http.pid & var/log/error_log)
Code:

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK


hayne 08-27-2004 04:32 PM

Quote:

Originally Posted by DJ_Max
Yeah, I don't have that option in Disk Utility, verfy & repair are grayed out.

You mean Disk Utility on the CD when you have booted from the CD?

Anyway, have you done the "Repair Permissions" from Disk Utility on your hard disk when booted normally?

The listings you provided of /etc/httpd look fine.
I would investigate starting httpd manually following the command that the apachectl script uses. That should show you what part is failing and why.

kfaulhaber 08-27-2004 04:36 PM

Quote:

Originally Posted by DJ_Max
Code:

Syntax error on line 281 of /etc/httpd/httpd.conf:
Cannot add module via name 'mod_php4.c': not in list of loaded modules

I tried to comment out that file, still nothing.


Take a close look at your httpd.conf and make sure both mod_php lines are commented out (or not commented out, depending on your situation) and run the config test again again.

As for the run and error logs, there lack of existence is not necessarily a bad thing.

hayne 08-27-2004 04:39 PM

Quote:

Originally Posted by DJ_Max
Ok, I forgot about that. First I got this,
Code:

Syntax error on line 281 of /etc/httpd/httpd.conf:
Cannot add module via name 'mod_php4.c': not in list of loaded modules

I tried to comment out that file, still nothing.

You aren't being clear enough, not telling us enough details. What do you mean by "still nothing" ???
Do you mean that you get exactly the same error message from 'httpd -t' before and after editing the httpd.conf file?
Or what?

Quote:

As for the other files, they didn't exist. (/var/run/http.pid & var/log/error_log)[CODE]
I believe the correct log file name is: /var/log/httpd/error_log

DJ_Max 08-27-2004 04:50 PM

Quote:

Originally Posted by hayne
You aren't being clear enough, not telling us enough details. What do you mean by "still nothing" ???
Do you mean that you get exactly the same error message from 'httpd -t' before and after editing the httpd.conf file?
Or what?


I believe the correct log file name is: /var/log/httpd/error_log

'Still nothing' as in the same error when trying to start apache

Quote:

You mean Disk Utility on the CD when you have booted from the CD?
I can't run Disk utility from my hard drive, it's only available from the cd, which I don't wanna do.

Code:

/var/log/httpd/error_log
That last error was on July 15
Code:

[Thu Jul 15 19:12:42 2004] [notice] caught SIGTERM, shutting down
Quote:

I would investigate starting httpd manually following the command that the apachectl script uses.
Yeah, if I understand it'll, I'll try to start it manulally.

hayne 08-27-2004 05:16 PM

Quote:

Originally Posted by DJ_Max
'Still nothing' as in the same error when trying to start apache

Please don't try to save on keystrokes when doing this sort of remote debugging. I.e. if you changed the httpd.conf file that previously was giving a syntax error upon 'httpd -t' and now it no longer gives any errors, please tell us that explicitly. Don't make us guess. We're not good at it.

So - is it true that 'httpd -t' now gives your config file a clean bill of health?

Quote:

I can't run Disk utility from my hard drive, it's only available from the cd
Whoa - slow down there and explain what you mean by not being able to run Disk Utility from your hard drive. If you can't do that (I'm talking about "Repair Permissions" not "Repair Disk") then you have much bigger problems than Apache!
Tell us in full detail what happens when you run Disk Utility from your hard drive, then select your disk in its window, and press "Repair Permissions".

DJ_Max 08-27-2004 05:29 PM

Quote:

Originally Posted by hayne
Please don't try to save on keystrokes when doing this sort of remote debugging. I.e. if you changed the httpd.conf file that previously was giving a syntax error upon 'httpd -t' and now it no longer gives any errors, please tell us that explicitly. Don't make us guess. We're not good at it.

So - is it true that 'httpd -t' now gives your config file a clean bill of health?



Whoa - slow down there and explain what you mean by not being able to run Disk Utility from your hard drive. If you can't do that (I'm talking about "Repair Permissions" not "Repair Disk") then you have much bigger problems than Apache!
Tell us in full detail what happens when you run Disk Utility from your hard drive, then select your disk in its window, and press "Repair Permissions".

httpd -t returns:
Code:

Processing config directory: /private/etc/httpd/users
 Processing config file: /private/etc/httpd/users/brothers.conf
 Processing config file: /private/etc/httpd/users/daejuanj.conf
Syntax OK

When I go to Disk Utility ->First Aid; while my drive is selected, the sections are grayed out. If I can get a screenshot, i will...
Link

hayne 08-27-2004 06:09 PM

Quote:

Originally Posted by DJ_Max
When I go to Disk Utility ->First Aid; while my drive is selected, the sections are grayed out. If I can get a screenshot, i will...
Link

Oops - my mistake. I forgot that you are running 10.1 and in that ancient version of the OS, there is no "repair permissions" feature in Disk Utility. At that time, it was a separate utility and it might not have even come standard with the OS - you might have to download it separately. You can read about it and download it via this page:
http://docs.info.apple.com/article.html?artnum=106900

DJ_Max 08-27-2004 06:15 PM

Quote:

Originally Posted by hayne
Oops - my mistake. I forgot that you are running 10.1 and in that ancient version of the OS, there is no "repair permissions" feature in Disk Utility. At that time, it was a separate utility and it might not have even come standard with the OS - you might have to download it separately. You can read about it and download it via this page:
http://docs.info.apple.com/article.html?artnum=106900

Yeah, that must be the reason I couldn't find the button you were talking aboutr, I knew I wasn't going crazy. I'll download after this post.

Arg!!, I ran the program, and it went through my 23k+ files, and said everything went ok.
Code:

2004-08-27 17:30:52 -0500 - The privileges have been repaired on the volume 'Macintosh HD'
But I still get the same error:
Code:

/usr/sbin/apachectl: permission denied: /etc/httpd [71]
/usr/sbin/apachectl start: httpd could not be started
 [71]

I have to look at that shell file, and try to make sense of it.

hayne 08-27-2004 07:17 PM

Quote:

Originally Posted by DJ_Max
I still get the same error:
Code:

/usr/sbin/apachectl: permission denied: /etc/httpd [71]
/usr/sbin/apachectl start: httpd could not be started
 [71]

I have to look at that shell file, and try to make sense of it.

The version I have is the one that shipped with Panther, so it may have changed from what you have, but here are the relevant bits:
Code:

# the path to your httpd binary, including options if necessary
HTTPD=/usr/sbin/httpd

....

    case $ARG in
    start)
        if [ $RUNNING -eq 1 ]; then
            echo "$0 $ARG: httpd (pid $PID) already running"
            continue
        fi
        if $HTTPD ; then
            echo "$0 $ARG: httpd started"
        else
            echo "$0 $ARG: httpd could not be started"
            ERROR=3
        fi
        ;;

From this, it seems that you are getting the error message of the last "echo" line. And this, together with the "permission denied" error you get, seems to indicate that the variable $HTTPD is wrongly defined in your version of the apachectl script. It seems that $HTTPD is defined as /etc/httpd instead of /usr/sbin/httpd as in my version of apachectl.
Have a look and see what is different in your version of the apachectl script.

kfaulhaber 08-27-2004 11:13 PM

My mistake on the error log path.

My memory does not go back to 10.1, but just for fun, which httpd should give you the path to your apache binary, and if it does, sudo httpd should start it since httpd -t gave you a clean bill of health. You will want to fix the errors with apachectl to make life easier.

DJ_Max 08-27-2004 11:43 PM

Quote:

Originally Posted by kfaulhaber
My mistake on the error log path.

My memory does not go back to 10.1, but just for fun, which httpd should give you the path to your apache binary, and if it does, sudo httpd should start it since httpd -t gave you a clean bill of health. You will want to fix the errors with apachectl to make life easier.

Thanks, that worked and got apache running.

Quote:

From this, it seems that you are getting the error message of the last "echo" line. And this, together with the "permission denied" error you get, seems to indicate that the variable $HTTPD is wrongly defined in your version of the apachectl script. It seems that $HTTPD is defined as /etc/httpd instead of /usr/sbin/httpd as in my version of apachectl.
Have a look and see what is different in your version of the apachectl script.
Yeah, I just figured that out. I have to look into what happend, and how to fix it.

BTW, I wanna thank everyone for their help. :cool:

EDIT:
Yeah, you were right on the mark.
I had
Code:

HTTPD=/etc/httpd
When it should have been:
Code:

HTTPD=/usr/sbin/httpd


All times are GMT -5. The time now is 10:36 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.