Nginx部署安装教程

Posted DATA数据猿

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx部署安装教程相关的知识,希望对你有一定的参考价值。

nginx部署安装教程

一、Nginx简介

Nginx是一个高性能的HTTP和反向代理Web服务器,同时也提供了IMAP/POP3/SMTP服务。

Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器。其特点是占用内存少,并发能力强,事实上Nginx的并发能力在同等类型的网页服务器中表现较好。

二、下载

nginx官网: http://nginx.org/

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-MP1nUeGT-1670133627262)(001.png)]

可自行选择版本并下载

wget http://nginx.org/download/nginx-1.10.1.tar.gz

三、安装Nginx依赖

yum install -y gcc-gcc++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

[root@zxy_master nginx-1.10.1]# yum install -y gcc-gcc++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
......

四、解压

[root@zxy_master software]# tar -zxvf nginx-1.10.1.tar.gz -C /zxy/apps/
nginx-1.10.1/
nginx-1.10.1/auto/
nginx-1.10.1/conf/
nginx-1.10.1/contrib/
nginx-1.10.1/src/
......

五、配置

./configure --prefix=/usr/local/nginx

[root@zxy_master nginx-1.10.1]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 3.10.0-1160.45.1.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found

六、编译和安装

make & make install -j 4

[root@zxy_master nginx-1.10.1]# make & make install -j 4
[1] 22058
make -f objs/Makefile
make -f objs/Makefile install
make[1]: Entering directory `/zxy/apps/nginx-1.10.1'
make[1]: Entering directory `/zxy/apps/nginx-1.10.1'
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \\
        -o objs/src/core/nginx.o \\
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \\
        -o objs/src/core/nginx.o \\
        src/core/nginx.c
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \\
        -o objs/sr

七、创建软连接(可选)

刚才配置路径在/usr/local/nginx,通过创建软连接,方便查看

[root@zxy_master nginx-1.10.1]# ln -s /usr/local/nginx/

八、启动nginx

[root@zxy_master sbin]# ./nginx
[root@zxy_master sbin]# ps -ef | grep nginx
root     24318     1  0 13:56 ?        00:00:00 nginx: master process ./nginx
nobody   24319 24318  0 13:56 ?        00:00:00 nginx: worker process
root     24365  2006  0 13:56 pts/0    00:00:00 grep --color=auto nginx

九、关闭nginx

[root@zxy_master sbin]# ./nginx -s quit
[root@zxy_master sbin]# ps -ef | grep nginx
root     24876  2006  0 13:57 pts/0    00:00:00 grep --color=auto nginx

以上是关于Nginx部署安装教程的主要内容,如果未能解决你的问题,请参考以下文章

Nginx Linux安装与部署

Nginx部署文档(官方版yum安装)

linux centos7 nginx 安装部署和配置

Nginx部署文档(二进制包安装)

Linux下安装Nginx详细图解教程

Linux下安装Nginx详细图解教程