centos7安装nginx
1.安装前准备
对于nginx编译安装需要先安装编译 的工具,然后再安装nginx依赖
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
2.下载nginx
2.1手动下载
2.2wget下载
wget -c https://nginx.org/download/nginx-1.25.1.tar.gz
2.3解压
tar -xf nginx-1.25.1.tar.gz
3.配置nginx
#配置nginx
#--prefix 指定安装的目录
#/usr/local/nginx 是安装目录,不能和自己下载的文件目录重了
#./configure --prefix=/usr/local/nginx
#带ssl stub_status模块 添加strem模块 –with-stream,这样就能传输tcp协议了
#http_stub_status_module 状态监控
#http_ssl_module 配置https
#stream 配置tcp得转发
#http_gzip_static_module 压缩
#http_sub_module 替换请求
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream
如下:
cd nginx-1.25.1/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream
4.安装nginx
make && make install
5.启动nginx
cd /usr/local/nginx/sbin
./nginx
6.重载配置
cd /usr/local/nginx/sbin
./nginx -s reload