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 |
check your /etc/rc.conf file - there should be an option to enable Apache at startup.
|
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. |
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?
|
#!/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 $? |
All times are GMT -5. The time now is 03:25 AM. |