一、下载Nginx包
下载地址:http://nginx.org/en/download.html
二、解压源码包
tar -zxvf nginx-1.18.0.tar.gz
三、安装依赖包
# 一键安装下面四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
四、安装Nginx
- cd到解压目录,执行configure命令
cd nginx-1.18.0/
–prefix 代表安装的路径,
–with-http_ssl_module 安装ssl模块,
–with-http_stub_status_module查看nginx的客户端状态
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
- 在解压目录,编译并安装nginx。成功后会在/usr/local/下生成nginx文件夹
make & make install
- 修改配置文件
vim /usr/local/nginx/conf/nginx.conf
- 启动nginx
# cd /usr/local/nginx/sbin目录下执行
./nginx #启动nginx
五、常用命令
./nginx -t #验证配置文件是否能正常启动
./nginx #启动nginx
./nginx -s quit #正常停止
./nginx -s stop #快速停止
./nginx -s reload #重新加载
./nginx -V #查看版本信息