In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Nginx is a powerful high-performance Web and reverse proxy server. Although you can use the command line to perform various operations on nginx, such as starting, etc., it is still not convenient. The following describes how to set up boot self-boot after installation under Linux.
First, create the nginx file under the / etc/init.d/ directory of the linux system, using the following command:
Vim / etc/init.d/nginx
Add the following command to the script:
#! / bin/sh## nginx-this script starts and stops the nginx daemon## chkconfig:-85 "description: NGINX is an HTTP (S) server, HTTP (S) reverse\ # proxy and IMAP/POP3 proxy server# processname: nginx# config: / etc/nginx/nginx.conf# config: / etc/sysconfig/nginx# pidfile: / var/run/nginx.pid# Source function library.. / etc/rc.d/init.d/functions# Source networking configuration.. / etc/sysconfig/network# Check that networking is up. ["$NETWORKING" = "no"] & & exit 0nginx = "/ usr/sbin/nginx" prog=$ (basename $nginx) NGINX_CONF_FILE= "/ etc/nginx/nginx.conf" [- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginxlockfile=/var/lock/subsys/nginxmake_dirs () {# make required directories user= `$nginx-V 2 > & 1 | grep "configure arguments:" | sed's / [^ *] *-- user=\ ([^] *\). * /\ 1if [- z "`grep $user / etc/ passwd`]; then useradd-M-s / bin/nologin $user fi options=` $nginx-V 2 > & 1 | grep 'configure arguments:' `for opt in $options Do if [`echo $opt | grep'. *-temp-path' `]; then value= `echo $opt | cut-d "="-f 2` if [!-d "$value"] Then # echo "creating" $value mkdir-p $value & & chown-R $user $value fi fi done} start () {[- x $nginx] | | exit 5 [- f $NGINX_CONF_FILE] | | exit 6 make_dirs echo-n $"Starting $prog:" daemon $nginx-c $NGINX_CONF_FILE retval=$? Echo [$retval-eq 0] & & touch $lockfile return $retval} stop () {echo-n $"Stopping $prog:" killproc $prog-QUIT retval=$? Echo [$retval-eq 0] & & rm-f $lockfile return $retval} restart () {configtest | | return $? Stop sleep 1 start} reload () {configtest | | return $? Echo-n $"Reloading $prog:" killproc $nginx-HUP RETVAL=$? Echo} force_reload () {restart} configtest () {$nginx-t-c $NGINX_CONF_FILE} rh_status () {status $prog} rh_status_q () {rh_status > / dev/null 2 > & 1} case "$1" in start) rh_status_q & & exit 0 $1; stop) rh_status_q | | exit 0 $1 Restart | configtest) $1;; reload) rh_status_q | | exit 7 $1;; force-reload) force_reload;; status) rh_status;; condrestart | try-restart) rh_status_q | | exit 0;; *) echo $"Usage: $0 {start | stop | restart | condrestart | try-restart | reload | force-reload | configtest}" exit 2esac
As a matter of fact, I didn't write this script. Who wrote it? nginx officially wrote it. The script address: http://wiki.nginx.org/RedHatNginxInitScript, but note that if you are custom compiled and installed nginx, you need to modify the following two configurations according to your installation path:
Nginx= "/ usr/sbin/nginx" is modified to the path where the nginx executes the program.
NGINX_CONF_FILE= "/ etc/nginx/nginx.conf" is modified to the path of the configuration file.
Set the execution permissions for the file after saving the script file:
Chmod axix / etc/init.d/nginx
You can then manage the nginx service through this script:
/ etc/init.d/nginx start/etc/init.d/nginx stop
Use chkconfig for management
The above method completes the function of managing nginx services with scripts, but it is still not very convenient, such as setting nginx boot and so on. You can use chkconfig to set it at this point.
First add the nginx service to the chkconfig management list:
Chkconfig-add / etc/init.d/nginx
After adding this, you can use service to start, restart and other operations on nginx.
Service nginx startservice nginx stop
Set the terminal mode to boot:
Chkconfig nginx on
There are not many ways to use the chkconfig command, so you can search it on your own.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.