Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS7.4 installation Nginx1.14.2 process and configuration

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

CentOS7.4 installation Nginx1.14.2 process and configuration

Install make:

Yum-y install gcc automake autoconf libtool make

Install the galleys:

Yum install gcc gcc-c++

Install pcre and pcre-devel

Yum install-y pcre pcre-devel

Installing zlib zlib provides many ways to compress and resolve, and nginx requires zlib to gzip http.

Yum install-y zlib zlib-devel

Install openssl openssl is a secure socket layer password library, nginx to support https, you need to use openssl

Yum install-y openssl openssl-devel

Download nginx

Wget http://nginx.org/download/nginx-1.14.2.tar.gz

Decompression

Tar-zxvf nginx-1.14.2.tar.gz

Cd to File path

Cd nginx-1.14.2

Compile

/ configure-- prefix=/usr-- sbin-path=/usr/sbin/nginx-- conf-path=/etc/nginx/nginx.conf-- error-log-path=/var/log/nginx/error.log-- pid-path=/var/run/nginx/nginx.pid-- lock-path=/var/lock/nginx.lock-- user=nginx-- group=nginx-- with-http_ssl_module-- with-http_flv_module-- with-http_gzip_static_module-- http-log-path=/ Var/log/nginx/access.log-http-client-body-temp-path=/var/tem/nginx/client-http-proxy-temp-path=/var/tem/nginx/proxy-http-fastcgi-temp-path=/var/tem/nginx/fcgi-with-http_stub_status_module

Installation

Make & & make install

Create a boot command script file

Vim / etc/init.d/nginx

Insert startup script code

#! / 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. ["$NETWORK" = "no"] & & exit 0nginx = "/ usr/sbin/nginx" # corresponds to sbin-pathprog=$ (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 6make_dirsecho-n $"Starting $prog:" daemon $nginx-c $NGINX_CONF_FILEretval=$?echo [$retval-eq 0] & & touch $lockfilereturn $retval} stop () {echo-n $"Stopping $prog:" killproc $prog-QUITretval=$?echo [$retval-eq 0] & rm -f $lockfilereturn $retval} restart () {configtest | | return $? stopsleep 1start} reload () {configtest | | return $? echo-n $"Reloading $prog:" killproc $nginx-HUPRETVAL=$?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" instart) rh_status_q & & exit 0 $1 ; stop) rh_status_q | | exit 0 $1x restart | configtest) $1x reload) rh_status_q | | exit 7 $1x force force reload) rh_status;;condrestart | try-restart) rh_status_q | | exit 0 situation *) echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest}" exit 2esac

Save

: wq

Setup everyone has permission to execute this startup script nginx file

Chmod axix / etc/init.d/nginx

Add nginx to the system service

Chkconfig-add nginx

1) if a [emerg] getpwnam ("nginx") failed error occurs, execute useradd nginx

2) if a [emerg] mkdir () "/ var/temp/nginx/client" failed (2: No such file or directory) error occurs

Mkdir-p / var/tem/nginx/client

Check whether the nginx configuration is successful

Nginx-t

Start

Nginx

Restart

Nginx-s reload

If you are running a firewall, run the following command to allow HTTP and HTTPS to communicate:

Sudo firewall-cmd-permanent-zone=public-add-service=http

Sudo firewall-cmd-permanent-zone=public-add-service=https

Sudo firewall-cmd-reload

At this point, the server configuration is complete.

-

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report