Nginx - 安装步骤
一、下载nginx安装包
官方下载地址
https://nginx.org/en/download.html
执行下载:
wget https://nginx.org/download/nginx-1.18.0.tar.gz
二、安装nginx
2.1 解压nginx安装包
tar -zxvf nginx-1.18.0.tar.gz
解压后进入nginx目录 生成安装文件
--prefix
nginx安装目录
./configure --prefix=/usr/local/nginx
运行后发现报错
错误信息:
./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.
./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.
2.2 安装依赖包
pcre 、 pcre-devel 、zlib-devel
yum install -y pcre pcre-devel zlib-devel
依赖包安装成功后继续执行编译命令
Configuration summary + using system PCRE library + OpenSSL library is not used + using system zlib library nginx path prefix: "/usr/local/nginx-1.18.0/" nginx binary file: "/usr/local/nginx-1.18.0//sbin/nginx" nginx modules path: "/usr/local/nginx-1.18.0//modules" nginx configuration prefix: "/usr/local/nginx-1.18.0//conf" nginx configuration file: "/usr/local/nginx-1.18.0//conf/nginx.conf" nginx pid file: "/usr/local/nginx-1.18.0//logs/nginx.pid" nginx error log file: "/usr/local/nginx-1.18.0//logs/error.log" nginx http access log file: "/usr/local/nginx-1.18.0//logs/access.log" nginx http client request body temporary files: "client_body_temp" 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"
安装成功!!!
2.3 开始安装
1、make
2、编译成功后,执行安装
make install
3、安装成功后,进入nginx安装目录:/usr/local/nginx
查看nginx版本
./sbin/nginx -v
三、命令
关闭:
./nginx -s stop
启动:./nginx
配置文件更新测试:./nginx -t
重新加载配置文件:./nginx -s reload