不败君

前端萌新&初级后端攻城狮

Centos编译安装Nginx

Centos编译安装Nginx

2020-11-07 19:32:16

围观(4487)

在安装 Nginx 前需要安装一些依赖软件,否则编译安装过程会报错。


安装 GCC:

yum install gcc-c++


安装 PCRE:

yum install -y pcre pcre-devel

否则报错:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.


安装 zlib:

yum install -y zlib zlib-devel

否则报错:

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.


安装 OpenSSL:

yum install -y openssl openssl-devel


安装 Nginx

打开官网下载页:http://nginx.org/en/download.html

复制某个版本的连接,如:

1.png

在 Centos 执行下载:

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

下载完成后解压:

tar -xvf nginx-1.19.4.tar.gz

进入刚解压的目录:

cd nginx-1.19.4

使用默认配置并执行编译(依次执行命令):

./configure
make
make install

安装完成后 Nginx 路径在 /usr/local/nginx

启动 Nginx 可以将目录切换到:/usr/local/nginx/sbin 执行:

./nginx


常用命令

关闭退出 Nginx:

./nginx -s stop
./nginx -s quit

重启 Nginx:

./nginx -s reload

查看 Nginx 进程:

ps aux|grep nginx


本文地址 : bubaijun.com/page.php?id=221

版权声明 : 未经允许禁止转载!

评论:我要评论
发布评论:
Copyright © 不败君 粤ICP备18102917号-1

不败君

首 页 作 品 微 语