第一步:下载、上传服务器后
第二步:安装依赖包
yum install pcre-devel make zlib zlib-devel gcc-c++ libtool openssl openssl-devel -y
第三步:解压到指定位置
tar -zxvf nginx-1.20.2.tar.gz -C /usr/local
第四步:新建用户名nginx
useradd nginx -s /sbin/nologin -M
第五步:开始编译
./configure \
> --user=nginx \ #指定程序运行时的用户
> --group=nginx \ #指定程序运行时的用户组
> --prefix=/usr/local/nginx-1.20.2 \ #指定安装目录
> --with-http_ssl_module \ #启动ngx_http_ssl_module支持(使其支持https请求)
>--with-http_sub_module \ #启动ngx_http_sub_module支持(允许用一些其他文本代替nginx响应中的一些文本)
>--with-http_stub_status_module \ #启动ngx_http_stub_module的支持,可以获取自上次启动以来的工作状态
>--with-http_gzip_static_module \ #启动ngx_http_gzip_static_module支持,(在线实时压缩输出数据流)
>--with-pcre #启动pcre库
make && make install
第六步:启动nginx
1、检查语法:/usr/local/nginx/sbin/nginx -t
2、启动nginx:/usr/local/nginx/sbin/nginx
3、查看端口:lsof -i :80
4、浏览器访问测试:192.168.178.76 出现welcome to nginx 安装成功!