
正文
CentOS 7 源代码安装Nginx
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
本篇简要介绍CentOS 7 源代码安装Nginx。
Preface
# yum install epel-release -y
# yum group install "Development Tools" -y# 安装基本编译工具
安装依赖
Nginx依赖如下三个库:
• PCRE (for the HTTP Rewrite module)
• Zlib (for the HTTP Gzip module)
• OpenSSL (for HTTPS protocol support)
# yum install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel -y
安装Nginx
官网下载您想安装的Nginx版本,如当前最新版本nginx-1.17.6。
# wget http://nginx.org/download/nginx-1.17.6.tar.gz
# tar -xvf nginx-1.17..tar.gz
# cd nginx-1.17./
# ./configure
# make
# make install
# /usr/local/nginx/sbin/nginx -v# nginx默认安装位置/usr/local/nginx
nginx version: nginx/1.17.
创建软连接
# ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
# nginx -v
nginx version: nginx/1.17.
# which nginx
/usr/bin/nginx
常用命令
# systemctl start nginx # 启动
# systemctl status nginx # 查看状态
# systemctl stop nginx # 停止
# nginx -s reload # 重载配置
# 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
以上!






