- 官网下载nginx压缩包
-
官网下载页面
http://nginx.org/en/download.html
选择稳定版
右键点击图中的Stable version下的 nginx-1.20.1,选择复制链接-
下载到linux
命令wget url
在这里选择个目录存放压缩包,然后执行wget 复制的下载地址
- 解压
命令tar -xvf 文件名
顺带一提tar -cvf 文件
是压缩
-
解压后进入这个文件夹
- 配置
- 执行
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin --modules-path=/usr/local/nginx/modules --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/logs/error.log --pid-path=/usr/local/nginx/logs/nginx.pid --lock-path=/usr/local/nginx/logs/nginx.lock
关于配置的参数的含义,在官方文档中有说明
http://nginx.org/en/docs/configure.html可能遇到的报错
./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.
解决方法
需要安装pcre的devel包,pcre-devel。使用yum安装即可:(以下命令还带有ssl、zlib等依赖的安装)
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
- 安装
- 执行
make & make install
- nginx的基本命令
- 官网 http://nginx.org/en/docs/beginners_guide.html
- 首先进入到安装目录,如果没改configure参数,安装目录在 /usr/local/nginx
启动 ./sbin
停止 ./sbin -s quit
重新加载配置文件 ./sbin -s reload