LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-19-2004, 01:08 AM   #1
m2azer
Member
 
Registered: Sep 2004
Location: USA
Distribution: red hat, fedora & centos
Posts: 202

Rep: Reputation: 30
Question Automatic Startup of Apache


hello,

i am trying to get Apache to start automatically:
cp /usr/local/apache2/bin/apachect1 /etc/init.d/
then when i do /sbin/chkconfig --add apachect1
i get "service apachect1 does not suppoort chkconfig"
did anyone run into that before please let me know?
thanks alot
 
Old 09-19-2004, 05:28 AM   #2
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Short answer: the Apache daemon's name is httpd (apachectl is just a script that calls httpd with the appropriate arguments).

Slightly longer answer: In Fedora there's already an init script called /etc/init.d/httpd. This calls apachectl, which in turn calls the actual httpd daemon, so you don't need to add that to the list of services.

Instead, you can say:
/sbin/chkconfig --level 345 httpd on
(assuming you want Apache to run in runlevels 3, 4, and 5)

Or if you say system-config-services you'll get Fedora's service-control UI which will let you see what all your services are doing all at once.
 
Old 09-19-2004, 12:16 PM   #3
m2azer
Member
 
Registered: Sep 2004
Location: USA
Distribution: red hat, fedora & centos
Posts: 202

Original Poster
Rep: Reputation: 30
i don't have httpd script under /etc/init.d niether do i have it on the Service Configuration window.

thanks
 
Old 09-19-2004, 12:19 PM   #4
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
How did you install Apache?
 
Old 09-19-2004, 01:47 PM   #5
m2azer
Member
 
Registered: Sep 2004
Location: USA
Distribution: red hat, fedora & centos
Posts: 202

Original Poster
Rep: Reputation: 30
i compiled the source code apache 2.0.51
./configure --enable-so --enable-rewrite --enable-deflate --enable-speling --enable-ssl --enable-usertrack

Path to installation is /usr/local/apache2

when i run /sbin/chkconfig --add /usr/local/apach2/bin/apachect1
this is the error:
error reading info on service /usr/local/apache2/: no such file or directory

Note: i had apache on when i installed fedora the RPM one and i uninstalled and i used to have httpd service as you mentioned but not anymore

thanks for your reply

Last edited by m2azer; 09-19-2004 at 02:17 PM.
 
Old 09-19-2004, 03:02 PM   #6
gypsy_rabbi
Member
 
Registered: Sep 2004
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
A script in /etc/init.d needs to have chkconfig and description lines (as described in chkconfig's man page -- see the fifth and sixth lines in the code below) in order to get onto chkconfig's list.

I'm including the contents of Fedora's /etc/init.d/httpd below. You'll need to edit it to point the paths at your installation rather than Fedora's default, and add other options that you want (probably change start to startssl if you want it to run SSL-enabled, and so on).

Once you've done all that, you'll need to say
/sbin/chkconfig --add httpd

All that's if you want to do it right . If you want a quick-and-dirty solution you can add a call to apachectl in /etc/rc.d/rc.local

I assume you're doing all this because you need something that's not in Fedora's default install?

Hope this helps.



Code:
#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#	       HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

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

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

# check for 1.3 configuration
check13 () {
	CONFFILE=/etc/httpd/conf/httpd.conf
	GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
	GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
	GONE="${GONE}AccessConfig|ResourceConfig)"
	if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
		echo
		echo 1>&2 " Apache 1.3 configuration directives found"
		echo 1>&2 " please read /usr/share/doc/httpd-2.0.50/migration.html"
		failure "Apache 1.3 config directives test"
		echo
		exit 1
	fi
}

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        check13 || exit 1
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}
stop() {
	echo -n $"Stopping $prog: "
	killproc $httpd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
	echo -n $"Reloading $prog: "
	check13 || exit 1
	killproc $httpd -HUP
	RETVAL=$?
	echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status $httpd
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
	if [ -f ${pidfile} ] ; then
		stop
		start
	fi
	;;
  reload)
        reload
	;;
  graceful|help|configtest|fullstatus)
	$apachectl $OPTIONS $@
	RETVAL=$?
	;;
  *)
	echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
	exit 1
esac

exit $RETVAL
 
Old 09-20-2004, 07:39 AM   #7
jgt
LQ Newbie
 
Registered: Apr 2004
Location: Catalonia
Posts: 9

Rep: Reputation: 0
m2azer: I suggest you to try, when it be possible, to install new software using RPM packages. This will avoid to experience this issues and you will have the choice to upgrade them using rpm -F command.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic start of kde at startup thort Linux - Newbie 2 08-28-2004 01:36 PM
How to do automatic ISP sign-on at startup? KlaymenDK Linux - Networking 3 10-10-2003 11:42 AM
gui startup--automatic hpglow Linux - Newbie 3 07-22-2003 12:07 PM
VNC automatic startup script Gianni Linux - Networking 12 02-10-2003 09:57 AM
Automatic Startup script for Firewall Robertb Linux - General 0 03-27-2001 10:53 AM


All times are GMT -5. The time now is 10:38 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration