CentOS 安装nginx1.22

一、下载安装

下载

http://nginx.org/en/download.html

cd /opt
wget http://nginx.org/download/nginx-1.22.1.tar.gz
tar -zxvf nginx-1.22.1.tar.gz

安装依赖库

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

可以先查询安装情况,如:

[root@bogon ~]# rpm -q gcc
gcc-4.8.5-36.el7.x86_64

[root@bogon opt]# cd nginx-1.22.1/

[root@bogon nginx-1.22.1]# ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-stream

Configuration summary

+ using system PCRE library

+ using system OpenSSL library

+ using system zlib library

[root@bogon nginx-1.22.1]# make install

(可能用到的,就先安上吧,省着以后添加模块不方便)

./configure 参数官方文档

http://nginx.org/en/docs/configure.html

nginx编译安装之-./configure 参数详解

https://www.cnblogs.com/flashfish/p/11025961.html

--with-stream

允许构建用于通用TCP/UDP代理和负载平衡的流模块。默认情况下不会生成此模块。

Module ngx_stream_core_module 官网文档

http://nginx.org/en/docs/stream/ngx_stream_core_module.html

安装后目录

CentOS 安装nginx1.22_第1张图片

查看安装配置

[root@bogon nginx-1.22.1]# cd /opt/nginx/sbin

[root@bogon sbin]# ./nginx -V

nginx version: nginx/1.22.1

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

built with OpenSSL 1.0.2k-fips 26 Jan 2017

TLS SNI support enabled

configure arguments: --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-stream

二、启动、停止、访问

启动

[root@bogon sbin]# ./nginx &

[1] 24191

防火墙打开端口

firewall-cmd --permanent --zone=public --add-port=80/tcp

firewall-cmd --reload

访问地址

http://ip

CentOS 安装nginx1.22_第2张图片

停止nginx

[oracle@dev sbin]$ ./nginx -s stop

[oracle@dev sbin]$ ./nginx -s quit

nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)

nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。(graceful exit)

nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)

nginx -s reopen 重新打开日志文件。(reopenging log files)

检测配置文件

[root@bogon sbin]# ./nginx -t

nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

配置开机自启动

CentOS7 配置nginx开机自启动

卸载:

删除nginx目录即可

rm -rf /opt/nginx

(rm -rf /usr/local/nginx)

如果配置了自启动,也需要删除

官方文档:

http://nginx.org/en/docs/

参考:

linux下nginx安装,启动,停止,卸载,平滑升级,添加模块

https://blog.csdn.net/haveqing/article/details/84391623

你可能感兴趣的:(nginx,centos,nginx,安装配置)