In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
My linuxnginx file:
Nginx= "/ application/nginx/sbin/nginx"
NGINX_CONF_FILE= "/ application/nginx/conf/nginx.conf"
Create the file nginx under / etc/init.d
[root@localhost ~] # vim / etc/init.d/nginx
Its contents refer to the official documentation of nginx.
Configurations to pay attention to:
Nginx= "/ usr/local/nginx/sbin/nginx" / / is modified to the path where the nginx executes the program. NGINX_CONF_FILE= "/ usr/local/nginx/conf/nginx.conf" / / modify the path to the nginx.conf file.
Set the execution permissions of the file after saving
[root@localhost ~] # chmod adepx / etc/init.d/nginx
At this point, you can control the start and stop with the following instructions
/ etc/init.d/nginx start
/ etc/init.d/nginx stop
The above method completes the function of managing nginx services with scripts, but it is still not very convenient.
First add the nginx service to the chkconfig management list:
[root@localhost] # chkconfig-- add / etc/init.d/nginx
[root@guojincheng init.d] # chkconfig-- list | grep nginx
Nginx 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@guojincheng init.d] # chkconfig nginx-- level 3 on
[root@guojincheng init.d] # chkconfig-- list | grep nginx
Nginx 0:off 1:off 2:off 3:on 4:off 5:off 6:off
After adding this, you can use service to start, restart and other operations on nginx.
Service nginx start
Service nginx stop
Service nginx restart
Finally, set the boot to start automatically.
[root@localhost ~] # chkconfig nginx on
Nginx official documentation:
#! / 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:.*--user=" | sed's / [^ *] *-user=\ ([^] *\). * /\ 1grep g'- if [- n "$user"]; then if [- 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 fi} 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 $prog-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 | status | restart | condrestart | try-restart | reload | force-reload | configtest}" exit 2esac
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.