Linux under configuration nginx,mysql,php-fpm boot up

Source: Internet
Author: User
Tags chmod fpm

One. Nginx Boot start

1. Create a script in the/etc/init.d/directory

Vim/etc/init.d/nginx

2. Write the contents of the script (copy the following to change the installation path accordingly)

#!/bin/bash# nginx Startup script forThe Nginx HTTP server# It is v.0.0.2version.# chkconfig:- -  the# Description:nginx is a high-performance Web and proxy server.# It has a lot of features, but it's not for everyone.# processname:nginx# Pidfile:/var/run/nginx.pid# config:/usr/local/nginx/conf/nginx.conf//path to the configuration fileNginxd=/usr/local/webserver/nginx/sbin/nginx//the path of the applicationNginx_config=/usr/local/webserver/nginx/conf/nginx.conf//path to the configuration fileNginx_pid=/usr/local/nginx/logs/nginx.pid//path to the log fileRetval=0Prog="Nginx"# SourcefunctionLibrary:/etc/rc.d/init.d/functions# Source Networking configuration:/etc/sysconfig/network# Check that networking are up. [${networking}="No"] && exit0[ -X $nginxd] | | Exit0# Start Nginx daemons Functions.start () {if[-e $nginx _pid]; ThenEcho "Nginx already running ...."Exit1fiEcho-N $"starting $prog:"Daemon $nginxd-C ${nginx_config}retval=$?Echo[$RETVAL=0] &&Touch/var/lock/subsys/nginxreturn $RETVAL}# Stop nginx daemons functions.stop () {Echo-N $"stopping $prog:"Killproc $nginxdRETVAL=$?Echo[$RETVAL=0] &&RM-f/var/lock/subsys/nginx/usr/local/webserver/nginx/logs/nginx.pid}reload () {Echo-N $"Reloading $prog:"#Kill-hup 'Cat${nginx_pid} ' Killproc $nginxd-Hupretval=$?Echo}# See how we were called. Case " $" inchstart) Start; stop) stop;; reload) reload;; restart) Stopstart;; Status) Status $progRETVAL=$?;;*)Echo$"Usage: $prog {start|stop|restart|reload|status|help}"Exit1EsacExit $RETVAL

3. Change Script Permissions

chmod 775 /etc/init.d/nginx

4. Set Boot start

Chkconfig Nginx on

Two. mysql boot up

1. Copy the Mysql.server file from the MySQL directory to the/etc/init.d/directory and rename it to Mysqld, and change the permissions

chmod 775 /etc/init.d/mysqld

2. Set Boot start

Chkconfig mysqld on

Three. PHP-FPM Boot up

1. Create a script in the/etc/init.d/directory

vim/etc/init.d/php-fpm

2. Write the contents of the script (copy the following to change the installation path accordingly)

#!/bin/bash# # PHP-fpm-this script starts and stops the php-fpm daemin## chkconfig:- -  the# processname:php-fpm# config:/usr/local/php/etc/php-Fpm.confset-Epath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/Bindesc="php-fpm Daemon"NAME=php-Fpmdaemon=/usr/local/php/sbin/$NAME//path to the applicationConfigfile=/usr/local/php/etc/php-fpm.conf//path to the configuration filepidfile=/usr/local/php/var/run/$NAME. PID//I don't seem to have this file .scriptname=/etc/init.d/$NAME # If The daemonfileis not found, terminate the Script.test-X $DAEMON | | Exit0D_start () {$DAEMON-Y $CONFIGFILE | |Echo-N"already running"}d_stop () {Kill-quit 'Cat$PIDFILE ' | |Echo-N"no running"}d_reload () {Kill-hup 'Cat$PIDFILE ' | |Echo-N"could not reload"} Case " $" inchstart)Echo-N"starting $DESC: $NAME"D_startEcho ".";; Stop)Echo-N"stopping $DESC: $NAME"D_stopEcho ".";; Reload)Echo-N"Reloading $DESC Configuration ..."D_reloadEcho "Reloaded.";; Restart)Echo-N"restarting $DESC: $NAME"d_stop# Sleep forSeconds before starting again, this should give the Nginx daemon some TimeTo perform a graceful stopSleep 2D_startEcho ".";;*)Echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)">&2Exit3;;EsacExit0

3. Change Script Permissions

chmod 775 /ETC/INIT.D/PHP-FPM

4. Set Boot start

Chkconfig PHP-FPM on

Setup is complete, you can use the command chkconfig to view the boot service list

Linux under configuration nginx,mysql,php-fpm boot up

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.