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

Introduction to nginx and installation of nginx

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Introduction to 1.nginx

Common WebServer (ranking https://news.netcraft.com/archives/2018/, https://w3techs.com/technologies/overview/web_server/all)

Veteran: Httpd (early called Apache), open source, with the highest market share

Microsoft: IIS

Lightweight: Lighttpd, high performance, low energy consumption, lack of function

The birth of Nginx

Released in October 2004, Russian Igor Sysoev developer, rambler.ru

Nginx official website, version

Nginx.org 1.14.0 stable version

Domestic Branch Tengine (http://tengine.taobao.org/)

Introduction to Nginx function

Http services, reverse proxy, load balancing, mail proxy, cache acceleration, SSL, flv/mp4 streaming media

2.nginx installation-yum installation

Vi / etc/yum.repos.d/nginx.repo

# https://coding.net/u/aminglinux/p/nginx/git/blob/master/2z/nginx.repo

[nginx]

Name=nginx repo

Baseurl= http://nginx.org/packages/centos/$releasever/$basearch/

Gpgcheck=0

Enabled=1

Yum install-y nginx

Systemctl start/stop/restart/reload nginx

Test: browser access or curl access

Check the service process: ps aux | grep nginx

Check port snooping: netstat-lnp | grep': 80'

With firewall, you need to add rules iptables-I INPUT-p tcp-- dport 80-j ACCEPT

Nginx-V view version as well as various directories and parameters

Here is a small module that my script automatically installs

OS_VERSION=rpm-Q-queryformat'% {VERSION} 'centos-release

Echo ".nginx..."

Cp / root/tools/nginx.repo / etc/yum.repos.d/

Sed-I "s/6/$OS_VERSION/g" / etc/yum.repos.d/nginx.repo

Yum install-y nginx

Yum install-y libselinux-python

Yum install-y telnet nc

Cp / root/tools/nginx.conf / etc/nginx/nginx.conf ".bakdate +% F"

Cat / root/tools/nginx.conf > / etc/nginx/nginx.conf

If [["$OS_VERSION" = 6]]; then

Setenforce 0 & & chkconfig nginx on

Elif [["$OS_VERSION" = 7]]; then

Setenforce 0 & & systemctl enable nginx.service

Fi

Echo ".nginx.."

3.nginx installation-source code installation

Wget http://nginx.org/download/nginx-1.14.0.tar.gz / / download package

Tar zxf nginx-1.14.0.tar.gz / / decompress the package

Cd nginx-1.14.0

. / configure-- prefix=/usr/local/nginx / / start compilation and installation

Make & & make install

/ usr/local/nginx/sbin/nginx / / start

Pkill nginx / / Kill the nginx process and stop the nginx service

/ usr/local/nginx/sbin/nginx-t / / detect configuration file syntax error

/ usr/local/nginx/sbin/nginx-s reload// overload configuration

Service management script

Https://coding.net/u/aminglinux/p/aminglinux-book/git/blob/master/D15Z/etc_init.d_nginx

System startup script

#! / bin/bash

Chkconfig:-30 21description: http service.Source Function Library

. / etc/init.d/functions

Nginx Settings

NGINX_SBIN= "/ usr/local/nginx/sbin/nginx"

NGINX_CONF= "/ usr/local/nginx/conf/nginx.conf"

NGINX_PID= "/ usr/local/nginx/logs/nginx.pid"

RETVAL=0

Prog= "Nginx"

Start ()

{

Echo-n $"Starting $prog:"

Mkdir-p / dev/shm/nginx_temp

Daemon $NGINX_SBIN-c $NGINX_CONF

RETVAL=$?

Echo

Return $RETVAL

}

Stop ()

{

Echo-n $"Stopping $prog:"

Killproc-p $NGINX_PID $NGINX_SBIN-TERM

Rm-rf / dev/shm/nginx_temp

RETVAL=$?

Echo

Return $RETVAL

}

Reload ()

{

Echo-n $"Reloading $prog:"

Killproc-p $NGINX_PID $NGINX_SBIN-HUP

RETVAL=$?

Echo

Return $RETVAL

}

Restart ()

{

Stop

Start

}

Configtest ()

{

$NGINX_SBIN-c $NGINX_CONF-t

Return 0

}

Case "$1" in

Start)

Start

Stop)

Stop

Reload)

Reload

Restart)

Restart

Configtest)

Configtest

*)

Echo $"Usage: $0 {start | stop | reload | restart | configtest}"

RETVAL=1

Esac

Exit $RETVAL

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