Nginx web service (thin decompile installation manual)

Nginx Web Services

Nginx concept

Nginx (engine x) is a high-performance HTTP server and reverse proxy web server, but also provides IMAP / POP3 / SMTP services. Nginx by伊戈尔赛索Aliyev to Russia visited the second Ramblerru site (Russian: Pamonep) developed the first - a public version was released in 2004 0.5 1.0 4 October.
Its source code to BSD license issued in the form, because of its stability, rich feature set, simple configuration files and low system resource consumption is known. June 1, 2011, nginx 1.0.4 release.
Nginx is a lightweight Web server reverse proxy server and e-mail (IMAP / POP3) proxy server, distributed under BSD-like agreement. It features occupy less memory, high concurrency, concurrent nginx fact the same type of ability in web server performance is better, mainland China use nginx web site users are: Baidu, Jingdong, Sina, Netease, Tencent, Taobao.

Nginx installation manual translation

Installation environment: Centos7, nginx-1.12.0.tar.gz

Nginx installation manual translation fine solution process steps as follows:

#Nginx设置
nginx-1.12.0.tar.gz 
1.解压缩软件包
tar zxf nginx-1.12.0 tar.gz -C /opt/
2.安装所需编译安装环境包
yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y
3.创建家目录但不创建家目录
useradd -M -s /sbin/nologin nginx
4.配置相关参数
cd /opt/nginx-1.12.0
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module 
(统计模块)
5.编译安装
make &&make install
6.测试 
#cd /usr/local/nginx 
#ls
#conf html logs sbin 
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
#nginx -t 
nginx 
netstat -natp | grep 80
systemctl stop firewalld.service 
setenforce 0
#yum install -y elinks (测试网页工具)
#elinks http://localhost 

7.#基本管理
killall -3 (-s QUIT) nginx 
netstat -antp | grep 80
killall -1 (-s HUP) nginx

8.制作管理脚本

Nginx installations manual translation

[root@localhost ~]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel -y

[root@localhost ~]# cd LNMP-C7/
[root@localhost LNMP-C7]# ls
Discuz_X3.4_SC_UTF8.zip    php-7.1.10.tar.bz2
mysql-boost-5.7.20.tar.gz  php-7.1.20.tar.bz2
ncurses-5.6.tar.gz         php-7.1.20.tar.gz
nginx-1.12.2.tar.gz        zend-loader-php5.6-linux-x86_64_update1.tar.gz
php-5.6.11.tar.bz2
[root@localhost LNMP-C7]# tar zxf nginx-1.12.2.tar.gz -C /opt/

[root@localhost nginx-1.12.2]# useradd -M -s /sbin/nologin nginx

[root@localhost LNMP-C7]# cd /opt/
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module

.....//省略部分内容
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@localhost nginx-1.12.2]# make && make install
...//省略部分内容
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/opt/nginx-1.12.2'
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
[root@localhost nginx-1.12.2]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx-1.12.2]# nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      66585/nginx: master 
[root@localhost nginx-1.12.2]# systemctl stop firewalld.service 
[root@localhost nginx-1.12.2]# setenforce 0

[root@localhost nginx-1.12.2]# yum install -y elinks
[root@localhost nginx-1.12.2]# elinks http://localhost
//这里执行命令后显示对话框,ok回车,输入q选择yes回车则退出到原本界面

These are the process of manually compiling Nginx installation, here we introduce the basic commands for managing the Nginx

Nginx's basic management

[root@localhost nginx-1.12.2]# killall -3 nginx    //关闭Nginx服务
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
[root@localhost nginx-1.12.2]# nginx               //启动Nginx服务
[root@localhost nginx-1.12.2]# killall -1 nginx    //重启Nginx服务
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      76326/nginx: master 
//也可以使用以下命令进行关闭和重启
killall -s QUIT nginx 
killall -s HUP nginx
[root@localhost nginx-1.12.2]# killall -s QUIT nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
[root@localhost nginx-1.12.2]# nginx 
[root@localhost nginx-1.12.2]# killall -s HUP nginx
[root@localhost nginx-1.12.2]# netstat -natp | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      79214/nginx: master 

More than basic management is not convenient, we can produce their own management script, the script follows

vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: - 99 20
# description: Nginx Service Control Script
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in 
    start)
        $PROG
        ;;
    stop)
        kill -s QUIT $(cat $PIDF)
        ;;
    restart)
        $0 stop 
        $0 start
        ;;
    reload)
        kill -s HUP $(cat $PIDF)
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload}"
        exit 1
esac
exit 0
[root@localhost init.d]# chmod +x nginx 
[root@localhost init.d]# chkconfig -add nginx 
[root@localhost init.d]# service nginx restart 

summary

This paper mainly on the basis of relevant point about Nginx, we need to know is its own characteristics and differences with the Apache.

Features: stability, lightweight, high concurrency, low resource
advantages: good at handling static web site (text pictures and video files) access to resources;

Apache is good at dynamic (for example: interactive account registration required)

Next article we will describe how to set up Nginx virtual host on the basis of manual translation services on installing Nginx, Thanks for reading!

Guess you like

Origin blog.51cto.com/14557673/2461328