lamp automatically start the service configuration

A, Apache service configuration
1, first copy installed to the lower /etc/init.d/httpd directory apachectl
2, X + A #chmod /etc/init.d/httpd
. 3, the httpd #chkconfig -add
. 4, #chkconfig 345 -Level
5, #chkconfig httpd ON
6, Note: If the error is not supported, edit vim /etc/init.d/httpd file, add the following code
#chkconfig: 345 85 15
#description: Start at The STOP and the Apache hTTPD Service

7、#service httpd start/stop/restart

Two, Mysql service configuration
1, first copy installed support-files / mysql.server file to the directory /etc/init.d/mysqld
2, A + X /etc/init.d/mysqld #chmod
. 3, #chkconfig mysqld -add
. 4, 345 #chkconfig -Level mysqld
. 5, ON #chkconfig mysqld
. 6, #service mysqld Start / STOP / the restart

Three, Php service configuration
1, the first to file php-fpm.conf remove pid = /run/php-fpm.pid Notes
2, create the service startup script, as follows:
#vim /etc/init.d/php-fpm
# ! / bin / SH
#chkconfig: 2345 15 95
#Comments to Support chkconfig ON CentOS

Seven

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="php-fpm nobody"
NAME=php-fpm
DAEMON=/usr/local/php/sbin/$NAME

CONFIGFILE=/usr/local/php/etc/php-fpm.conf
PIDFILE=/usr/local/php/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

test -x $DAEMON || exit 0

s_start() {
$DAEMON -y $CONFIGFILE || echo -n " already running"
}

s_stop() {
kill -QUIT cat $PIDFILE || echo -n " not running"
}

s_reload() {
kill -HUP cat $PIDFILE || echo -n " can't reload"
}

case "$1" in
start)
echo -n "Starting is success"
s_start
echo "."
;;
stop)
echo -n "Stopping is success"
s_stop
echo "."
;;
reload)
echo -n "Reloading configuration..."
s_reload
echo "reloaded."
;;
restart)
echo -n "Restarting is success"
s_stop
sleep 1
s_start
echo "."
;;
*)
echo "Usage: {start|stop|restart|force-reload}" >&2
exit 3
;;
Esac

. 3, A + X /etc/init.d/php-fpm #chmod
. 4, PHP #chkconfig -add-FPM
. 5, PHP-#chkconfig -Level 345 FPM
. 6, PHP-FPM #chkconfig ON
. 7, see boot services case
#chkconfig --list
8, service operations
# start the service
#service PHP-FPM start
# stop service
#service PHP-FPM sTOP
# to restart the service
#service php-fpm restart

NOTE: If no errors appear written, online google can solve;

Guess you like

Origin blog.51cto.com/1243047/2429547