LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2006, 11:37 AM   #1
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Rep: Reputation: 15
Can't get apache server to automatically start on boot


Hi all. I'm using apache 2.0.53 that I compiled from a tarball on my RHEL4 OS. There's a reason why I didn't go with the Apache that comes preinstalled. But that reason might not be so big anymore. anyway...

I installed the Apache binary to it's directory in /usr/local/apache2/bin/httpd . My guess is that the system keeps thinking it's gonna be in /etc/httpd, but alas, it's not there. I'm getting ahead of myself. ...

At startup, the HTTPD service doesn't start. After start up, I try to do it manually using the same file in the init.d directory (instead of directly on the binary, as a form of troubleshooting)

and I get this :

service httpd start
Starting httpd: execvp: No such file or directory
[FAILED]

-----------------------------------------------------

I'm VERY MUCH a newbie with shell scripts, as I am just modifying ones i find. but for the life of me, i can't see what'swrong with the script. maybe there is it's something that isn't there that should be.

/etc/rc.d/init.d/httpd {start¦stop¦restart¦reload¦status}
[root@icecream etc]# /etc/rc.d/init.d/httpd status
httpd dead but subsys locked

and /etc/rc.d/init.d/httpd script reads like thus:

!/bin/sh
#
# Startup script for the Apache Web Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd

# config: /usrlocal/apache2/bin/httpd
# config: /usr/local/apache2/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon httpd
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
killproc httpd
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
;;
status)
status httpd
;;
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
killproc httpd -HUP
echo
;;
*)
echo "Usage: $0 {start¦stop¦restart¦reload¦status}"
exit 1
esac

exit 0
-----------------------------------------
I read somewhere that I maybe have to put a symbolic link somewhere in a subdirectory of the rc.d directory?

please help!
 
Old 05-02-2006, 11:51 AM   #2
The-Archangel
LQ Newbie
 
Registered: Apr 2006
Location: London, UK
Posts: 8

Rep: Reputation: 0
Just insert /usr/local/apache2/bin/httpd at the end of /etc/rc.d/rc.local file and should be fine.
 
Old 05-02-2006, 12:19 PM   #3
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Copy /usr/local/apache2/bin/apachectl to /etc/init.d and rename it to something like httpd. After that do
Code:
#chkconfig -a /etc/init.d/httpd 
#chkconfig httpd on
 
Old 05-02-2006, 01:22 PM   #4
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
Ok, so since I'm so new at this kind of thing, can I follow one person's idea, and not the other, or both , and it won't matter which, as either one will work, and both is just a bit of overkill that won't harm anything?



Quote:
Originally Posted by The-Archangel
Just insert /usr/local/apache2/bin/httpd at the end of /etc/rc.d/rc.local file and should be fine.

You mean the text as written or the file /usr/local/apache2/bin/httpd? into the end of exactly the file named rc.local in the /etc/rc.d/ directory? (not sure how exact you were being)
 
Old 05-02-2006, 02:12 PM   #5
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by reddazz
Copy /usr/local/apache2/bin/apachectl to /etc/init.d and rename it to something like httpd. After that do
Code:
#chkconfig -a /etc/init.d/httpd 
#chkconfig httpd on
-a isn't an option . do you mean "add"?
 
Old 05-02-2006, 02:13 PM   #6
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
[ init.d]# chkconfig --add httpd
service httpd does not support chkconfig
 
Old 05-02-2006, 02:17 PM   #7
The-Archangel
LQ Newbie
 
Registered: Apr 2006
Location: London, UK
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by bowie101
Ok, so since I'm so new at this kind of thing, can I follow one person's idea, and not the other, or both , and it won't matter which, as either one will work, and both is just a bit of overkill that won't harm anything?






You mean the text as written or the file /usr/local/apache2/bin/httpd? into the end of exactly the file named rc.local in the /etc/rc.d/ directory? (not sure how exact you were being)
Open /etc/rc.d/rc.local and add text /usr/local/apache2/bin/httpd at the end of its contents.
 
Old 05-02-2006, 02:33 PM   #8
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
thanks. Did that. rebooted, and it didn't work (not sure why). I also think that with Cold Fusion starting in the init.d , I should have apache starting before the Cold Fusion service.
 
Old 05-03-2006, 02:26 AM   #9
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Take a look here for some help on starting apache at boot time.

I have just noticed that "chkconfig -a" does not work on Redhat and Mandriva (works fine on Suse) so --add would be the right option. Since chkconfig says that httpd is not a valid chkconfig service (wierd because setting it up on Mandriva and Suse works fine), you could download the apache 2.x srpm and extract its contents. Copy the httpd init script to /etc/init.d/httpd and then modify the paths so that they are the same as those on your system.

Last edited by reddazz; 05-03-2006 at 10:56 AM.
 
Old 05-03-2006, 09:53 AM   #10
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
Wow, when you step back, and you realize that among aaaaaaalll the computer books you have, there is something in one of them on this very problem that goes into detail about what happens at boot time, then everything is a whole lot better.

I got the answer in "administering Apache" by Arnold, Almeida, and Miller (McGraw Hill).
c. 2000 p. 68.

First, I went into /etc/rc.d/rc3.d and looked at the directory to figure out the appropriate start number for Apache. Since Apache is dependant on mail services that is listed as S80sendmail and possibly dependant on postgresql that we will one day use, that I found out usually defaults to S85, I'm starting apache at 86, so I make a note of that. I then go to /etc/rc.d/rc0.d directory and make the same determination for when to Kill apache process, after things that depend on it, are killed (Cold Fusion and some other stuff for me) and before sendmail and PostGre. So apache will be killed at 29 for me. I make a note of that.

then I copy the (apache root)/bin/apachectl script to /etc/rc.d/init.d .

Then I create start up script links to the apachectl script . I have it in the book as wanting to start at run level 2, instead of 3, so what the hell. i'll do that.

Quote:
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc2.d/S86apachectl
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc3.d/S86apachectl
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc4.d/S86apachectl
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc5.d/S86apachectl
Then, I'll create the kill scripts for the other run levels

Quote:
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc0.d/K29apachectl
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc1.d/K29apachectl
ln /etc/rc.d/init.d.apachectl /etc/rc.d/rc6.d/K29apachectl
(Notice I'm K29 - killing at 29 and S86 & starting at 86 for the various run-levels.)

And that's it! Now to test...

Shut down and reboot.

then after logging in again...

Quote:
ps ax | grep httpd
(or whatever arguments for ps is appropriate for my system. in this case, ax works)

and I get somethign like this :


387 ? S 0:00 (apache root)/bin/httpd
404 ? S 0:00 (apache root)/bin/httpd
405 ? S 0:00 (apache root)/bin/httpd
406 ? S 0:00 (apache root)/bin/httpd
407 ? S 0:00 (apache root)/bin/httpd
408 ? S 0:00 (apache root)/bin/httpd


which tells me its working! Oh Happy DAy!
 
Old 05-03-2006, 10:57 AM   #11
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
I'm glad you got it sorted. The link in my last post uses a similar method.
 
Old 05-03-2006, 11:07 AM   #12
bowie101
Member
 
Registered: Nov 2005
Distribution: FC4 & RHES
Posts: 105

Original Poster
Rep: Reputation: 15
yeah, but it's all the way on the bottom of the page! i didn't know what you were pointing at yesterday, and I got too tired before I scrolled all the way down! ha!

seriously, thanks for the help. I bookmarked the page you linked. that may come in real handy in the near future!
 
  


Reply



Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Start a server automatically? timmyk0 Linux - General 8 06-24-2006 02:58 AM
How do I start a program automatically when I boot up? bad_andy Mandriva 2 11-27-2004 08:15 PM
How do I start programs automatically with boot up? Kasperisa Linux - Newbie 6 07-15-2004 03:29 PM
how to start automatically apache server when boot-up? eye Linux - Software 7 10-28-2003 01:22 PM
How to start programs automatically at boot? onchiman Linux - Hardware 2 03-18-2003 10:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration