In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to install the source code Nginx automatic installation script and adapt to CentOS6, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.
On the operating system of CentOS6 series, download Nginx source code automatically through script, configure and install Nginx service, and finally add nginx to system service. You can operate nginx server through commands such as "service nginx start".
Nginx installation script (install-nginx.sh):
#! / bin/bash# installation configurationNGINX_VERSION=1.12.2NGINX_SRC_PATH=/rootNGINX_BIN_PATH=/usr/local/nginx# disable firewallservice iptables stopsetenforce installation dependenceyum install-y pcre-devel zlib-devel openssl-devel# download nginx source packagecd ${NGINX_SRC_PATH} wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz# unzip source packagetar-xzvf nginx-$ {NGINX_VERSION} .tar.gzcd. / nginx-$ {NGINX_VERSION} # install nginx. / configure-- prefix=$ {NGINX_BIN_PATH}-- with-http_ssl_modulemake & make install# add nginx to system serviceln-s ${NGINX_BIN_PATH} / sbin/nginx / usr/sbin/nginxcd ${NGINX_BIN_PATH} wget http://download.cloudhosts.xyz/linux/nginx/config/service-nginx # if this file cannot be downloaded Please replace mv service-nginx / etc/init.d/nginxcd / etc/init.d/chmod 755 nginx# test nginx serviceservice nginx restart with the service-nginx.sh file below
Add Nginx to system Services (service-nginx.sh):
This file is it (http://download.cloudhosts.xyz/linux/nginx/config/service-nginx)
#! / 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=\ ([^] *\). * /\ 1user= 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 $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 | status | restart | condrestart | try-restart | reload | force-reload | configtest}" exit 2esac the above is how to install the Nginx automatic installation script with source code and adapt to CentOS6. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.