LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 08-14-2001, 03:09 AM   #1
epic
Member
 
Registered: May 2001
Location: Shanghai,China
Distribution: Gentoo Linux 1.3b
Posts: 51

Rep: Reputation: 15
how to start some service at booting?


I installed Debian 2.2r2 and upgrade to unstable,I want to compile apache php MySQL etc by myself.and I want to know
how to start some service(Apache MySQL..) at system booting
 
Old 08-14-2001, 04:06 AM   #2
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
check your /etc/rc.conf file - there should be an option to enable Apache at startup.
 
Old 08-14-2001, 04:10 AM   #3
gizmola
Member
 
Registered: Jun 2001
Location: Los Angeles, CA USA
Distribution: RedHat
Posts: 53

Rep: Reputation: 15
The usual method is to have it start and stop by placing a script in the /etc/rc.d/init.d directory. You then create symbolic links to that file in the appropriate run level directory. The run level directories exist in /etc/rc?.d (for example /etc/rc5.d is the directory holding the scripts for runlevel 5).

You will probably want to put your scripts in the rc5.d directory, but you might want to determine the multiuser runlevel first by running runlevel. This will print the previous and current runlevels on your server.

The symbolic links to the scripts have names with an S?? or K??. S are executed at startup, K during shutdown. The lower the number, the earlier that script is executed in the sequence.

A lot of times, there's a user contributed script that you can use, and just copy into init.d. Check the docs and subdirectories of your mysql, php and apache source. Since PHP isn't a listener, you won't be starting it up, but for apache and mysql these are definately processes it would be good to start and stop with the appropriate inet.d scripts.

These scripts usually follow the convention of honoring parameters like start, restart and stop. Look at some of the other scripts for examples.
 
Old 08-14-2001, 07:28 PM   #4
epic
Member
 
Registered: May 2001
Location: Shanghai,China
Distribution: Gentoo Linux 1.3b
Posts: 51

Original Poster
Rep: Reputation: 15
Talking Thank you very much,but i still have a question!

Thank you very much,but i still have a question! Apache,proftpd,as I know there is no startup scripts like mysql.server in MySQL,how to start it at system booting?
 
Old 08-15-2001, 12:35 AM   #5
gizmola
Member
 
Registered: Jun 2001
Location: Los Angeles, CA USA
Distribution: RedHat
Posts: 53

Rep: Reputation: 15
#!/bin/bash
#
# mysqld This shell script takes care of starting and stopping
# the MySQL subsystem (mysqld).
#
# chkconfig: - 78 12
# description: MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid
# put this in the /etc/rc.d/init.d dir

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

# Source networking configuration.
. /etc/sysconfig/network

# Source subsystem configuration.
[ -f /etc/sysconfig/subsys/mysqld ] && . /etc/sysconfig/subsys/mysqld


prog="MySQL"

start(){
touch /var/log/mysqld.log
chown mysql.mysql /var/log/mysqld.log
chmod 0640 /var/log/mysqld.log
if [ ! -d /var/lib/mysql/mysql ] ; then
action $"Initializing MySQL database: " /usr/bin/mysql_install_db
ret=$?
chown -R mysql.mysql /var/lib/mysql
if [ $ret -ne 0 ] ; then
return $ret
fi
fi
chown mysql.mysql /var/lib/mysql
chmod 0755 /var/lib/mysql
/usr/bin/safe_mysqld --defaults-file=/etc/my.cnf >/dev/null 2>&1 &
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $prog: " /bin/true
else
action $"Starting $prog: " /bin/false
fi
[ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
return $ret
}

stop(){
/bin/kill `cat /var/run/mysqld/mysqld.pid 2> /dev/null ` > /dev/null 2>&1
ret=$?
if [ $ret -eq 0 ]; then
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
fi
[ $ret -eq 0 ] && rm -f /var/lock/subsys/mysqld
[ $ret -eq 0 ] && rm -f /var/lib/mysql/mysql.sock
return $ret
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/mysqld ] && restart || :
}

reload(){
[ -e /var/lock/subsys/mysqld ] && mysqladmin reload
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status mysqld
;;
reload)
reload
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|reload|condrestart|restart}"
exit 1
esac

exit $?
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
when i try to start samba pdc's smb service nmbd failed to start . sandeepchau123 Linux - Newbie 2 10-20-2007 01:59 PM
service does not start Aljaber Fedora 11 12-01-2005 07:07 PM
help on service booting bruse Mandriva 2 07-08-2005 07:50 AM
Service start-up n.antonio Linux - Software 2 05-02-2003 09:57 PM
Start service HiGate Linux - General 3 01-25-2003 04:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:57 AM.

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