Apache 2.2 startup problem run_rc_command

Hi everyone,

I'm a bit stumped about this problem, and it's probably (hopefully) something obvious I'm overlooking. I recently upgraded my ports, and some scripts got changed/added which is now causing a problem with starting Apache.

When I try [cmd=]/usr/local/etc/rc.d/apache22 start[/cmd] it doesn't start and gives me a warning. I turned on rc_debug, but get little extra help. I also checked as many relevant log files I could, but I can't find any clues. Also looking on the net for
Code:
run_rc_command: cannot run /usr/local/sbin/httpd
doesn't help much.

Here's some output:
Code:
Oct 19 17:49:44 newton root: ./apache22: DEBUG: checkyesno: apache22_http_accept_enable is set to NO.
Oct 19 17:49:44 newton root: ./apache22: DEBUG: checkyesno: apache22_enable is set to YES.
Oct 19 17:49:44 newton root: ./apache22: DEBUG: pid file (/var/run/httpd.pid): not readable.
Oct 19 17:49:44 newton root: ./apache22: WARNING: run_rc_command: cannot run /usr/local/sbin/httpd

-rwxr-xr-x  1 root  wheel  1310853 Oct 18 15:05 /usr/local/sbin/httpd

For now, I can start Apache with apachectl, but I'm pretty sure the service won't start after a reboot.

Oh, also.. before the upgrade, the system used /usr/local/etc/rc.d/apache-chroot.sh, which also uses apachectl instead of httpd. What are the benefits of using the apache22 script over apachectl anyway? I can easily fix the apache-chroot.sh, as only the path to apachectl has changed. But yeah, I want to do the right thing here instead of the easy way out :)

Thanks!
 
Not sure what else might be relevant?..
Code:
apache22_enable="YES"
apache22_chroot="NO"
apache_accf_enable="YES"
 
You could've just said that straight away, lol. But no, I don't see any typos. Would be a bit weird if an upgrade would cause typos in your rc.conf?!

Also, I didn't mention very well it's ONLY the (re)start that doesn't work, the rest does!
Code:
./apache22 status
apache22 is running as pid 31820.

./apache22 configtest
Performing sanity check on apache22 configuration:
Syntax OK

./apache22 rcvar
# apache22
apache22_enable=YES

./apache22 restart
Performing sanity check on apache22 configuration:
Syntax OK
Stopping apache22.
Waiting for PIDS: 31820.
./apache22: WARNING: run_rc_command: cannot run /usr/local/sbin/httpd

./apache22 stop
Stopping apache22.
Waiting for PIDS: 91153.

./apache22 graceful
Performing sanity check on apache22 configuration:
Syntax OK
Performing a graceful restart
Normally I'd figure out the script to see if there's a problem there, but apache22 is a bit too complex. Besides, I think a LOT more people should've had this problem ;p
 
Alright, does the file /usr/local/sbin/httpd actually exist? And does it have the proper permissions set?

Oh, almost forgot, also take a look at the permissions on /usr/local/sbin/.
 
Yeah, and the permissions look fine to me.. but I could be wrong :)

Code:
drwxr-xr-x   2 root  wheel 2048 Oct 19 17:28 sbin

-rwxr-xr-x  1 root  wheel  1310853 Oct 18 15:05 /usr/local/sbin/httpd
 
You're not wrong, they are indeed fine. Which only complicates the puzzle :(

Try this, see if that produces anything helpful:
[cmd=]sh -x /usr/local/etc/rc.d/apache22 start[/cmd]

The -x will cause the shell to print a lot of extra information.
 
Well, if it was simple, I wouldn't be asking here ;)

Nice tip on the sh -x, that really shows a lot. Here's the part of the apache22 script:

Code:
+ sourced_files=:/etc/rc.conf::/etc/rc.conf.local:
+ [ -r /etc/rc.conf.local ]
+ _rc_conf_loaded=true
+ [ -f /etc/rc.conf.d/apache22 ]
+ [ -n  ]
+ eval apache22_envvars=/usr/local/sbin/envvars
+ apache22_envvars=/usr/local/sbin/envvars
+ [ x != x -a xstart != x ]
+ [ start != stop ]
+ apache22_accf
+ checkyesno apache22_http_accept_enable
+ eval _value=$apache22_http_accept_enable
+ _value=NO
+ debug checkyesno: apache22_http_accept_enable is set to NO.
+ return 1
+ apache22_flags= -DNOHTTPACCEPT
+ extra_commands=reload graceful gracefulstop configtest
+ run_rc_command start
+ _return=0
+ rc_arg=start
+ [ -z apache22 ]
+ shift 1
+ rc_extra_args=
+ _rc_prefix=
+ eval _override_command=$apache22_program
+ _override_command=
+ command=/usr/local/sbin/httpd
+ _keywords=start stop restart rcvar reload graceful gracefulstop configtest
+ rc_pid=
+ _pidcmd=
+ _procname=/usr/local/sbin/httpd
+ [ -n /usr/local/sbin/httpd ]
+ [ -n /var/run/httpd.pid ]
+ _pidcmd=rc_pid=$(check_pidfile /var/run/httpd.pid /usr/local/sbin/httpd )
+ [ -n rc_pid=$(check_pidfile /var/run/httpd.pid /usr/local/sbin/httpd ) ]
+ _keywords=start stop restart rcvar reload graceful gracefulstop configtest status poll
+ [ -z start ]
+ [ -n  ]
+ eval rc_flags=$apache22_flags
+ rc_flags= -DNOHTTPACCEPT
+ eval _chdir=$apache22_chdir _chroot=$apache22_chroot _nice=$apache22_nice _user=$apache22_user _group=$apache22_group _groups=$apache22_groups
+ _chdir= _chroot=NO _nice= _user= _group= _groups=
+ [ -n  ]
+ [ -n apache22_enable -a start != rcvar ]
+ checkyesno apache22_enable
+ eval _value=$apache22_enable
+ _value=YES
+ debug checkyesno: apache22_enable is set to YES.
+ return 0
+ eval rc_pid=$(check_pidfile /var/run/httpd.pid /usr/local/sbin/httpd )
+ check_pidfile /var/run/httpd.pid /usr/local/sbin/httpd
+ _pidfile=/var/run/httpd.pid
+ _procname=/usr/local/sbin/httpd
+ _interpreter=
+ [ -z /var/run/httpd.pid -o -z /usr/local/sbin/httpd ]
+ [ ! -f /var/run/httpd.pid ]
+ debug pid file (/var/run/httpd.pid): not readable.
+ return
+ rc_pid=
+ [ start != start ]
+ eval _cmd=$start_cmd _precmd=$start_precmd _postcmd=$start_postcmd
+ _cmd= _precmd=apache22_prestart _postcmd=
+ [ -n  ]
+ [ -z  -a -n  ]
+ [ ! -x NO//usr/local/sbin/httpd ]
+ warn run_rc_command: cannot run /usr/local/sbin/httpd
+ [ -x /usr/bin/logger ]
+ logger apache22: WARNING: run_rc_command: cannot run /usr/local/sbin/httpd
+ echo apache22: WARNING: run_rc_command: cannot run /usr/local/sbin/httpd
apache22: WARNING: run_rc_command: cannot run /usr/local/sbin/httpd
+ return 1

The only thing that looks funny to me is this line:

Code:
+ [ ! -x NO//usr/local/sbin/httpd ]

I've never been very fluent in shell scripting, so I'm not quite sure if the NO/ actually means something..
 
MPaans said:
The only thing that looks funny to me is this line:

Code:
+ [ ! -x NO//usr/local/sbin/httpd ]
Yep, that looks weird to me too. The "NO/" shouldn't be there.

I have a slightly older Apache (Note to self: I need to update) and that part looks like this:
Code:
+ _cmd='' _precmd=apache22_prestart _postcmd=''
+ [ -n '' ]
+ [ -z '' -a -n '' ]
+ [ ! -x /usr/local/sbin/httpd ]
+ _run_rc_precmd
+ check_required_before start
+ local _f
+ [ ! -r /usr/local/etc/apache22/httpd.conf ]

So, we're getting close now :e

Do you have problems starting other services too? Or is it just apache that's causing problems?

If other services fail too it might be in one of the system's scripts. If it's just apache the apache22 rc.script may be the culprit.

Woah, proper formatting is taken pretty seriously here, isn't it? My apologies.
Yeah, it is. Don't worry too much about it. It even happens to me. Just try to make an effort to get it right and no-one will nag about it ;)
 
Good question on the other startup scripts with the
Code:
run_rc_command
, and yes, those work. I'll try and find the problem in the apache22 script. Shouldn't be -too- hard (tho it's pretty complex with all those variables.. :S ).

But again, is there any good reason to use apache22 over the simple script I already had that uses apachectl?.. So far this new script has proven to be buggy :p
 
Problem solved. Apparently the culprit was in /etc/rc.conf :
Code:
apache22_chroot="NO"

I found this in /etc/rc.subr :
Code:
#       ${name}_chroot  n       Directory to chroot to before running ${command}

So to fix this, I changed the line to
Code:
apache22_chroot=""

Thanks for the help!
 
kpa said:
Your apache22 script looks like a custom made script or an old version, the one installed by the latest port does not have any options for chroot, not even a single mention of it.

Actually, the old script was /usr/local/etc/rc.d/apache-chroot.sh which relied on apache_chroot to be YES or NO. Which I think was a custom script by the company whom pre-installed the server for me.

The new one /usr/local/etc/rc.d/apache22 seems definitely the port version:
Code:
# $FreeBSD: ports/www/apache22/files/apache22.in,v 1.10 2010/10/21 18:00:15 pgollucci Exp $
Which uses
Code:
run_rc_command
instead, which caused a conflict with the old configuration. :)

Kinda weird that they installed a custom script, since I got this server early this year. Maybe it has something to do with their customized admin software (which I'm not using..).
 
Yeah I just now noticed that the chroot line is coming from /etc/rc.subr so what I wrote in my now deleted post is incorrect... Glad you got it sorted out :)
 
Back
Top