当前位置: 首页 > article >正文

【Nginx】编译安装(Centos)

下载编译包

https://nginx.org/download/nginx-1.24.0.tar.gz

解压: tar -zxvf nginx-1.24.0.tar.gz 

进入目录:  nginx-1.24.0

配置

 ./configure --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module 

 如果不加扩展模块就直接执行:  ./configure

提示缺少:rewrite

./configure: error: the HTTP rewrite module requires the PCRE library

安装: sudo yum install pcre pcre-devel  

提示缺少: OpenSSL

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

然后安装: 

 yum install openssl 

 yum install openssl-devel

然后执行:

 ./configure --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module

成功了:

creating objs/Makefile (生成了编译配置文件,)

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

---生成了一堆配置

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/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"

编译

   确保安装了gcc,然后

    make

安装

[root@master01 nginx-1.24.0]# make install
make -f objs/Makefile install
make[1]: Entering directory `/root/soft/nginx-1.24.0'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
        || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
        || mv '/usr/local/nginx/sbin/nginx' \
                '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
        || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
        || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
        '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
        '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
        || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
        '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
        || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
        || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory `/root/soft/nginx-1.24.0'

查看安装目录

whereis nginx

启动

 cd /usr/local/nginx/sbin/

./nginx

启动结果

ps -aux | grep nginx

[root@master01 sbin]# ./nginx 
[root@master01 sbin]# ps -aux | grep nginx
root      30808  0.0  0.0  46136   956 ?        Ss   17:33   0:00 nginx: master process ./nginx
nobody    30809  0.0  0.0  48672  3780 ?        S    17:33   0:00 nginx: worker process
root      30828  0.0  0.0 112820  2308 pts/2    S+   17:33   0:00 grep --color=auto nginx

       Nginx 在启动时,默认情况下会使用一个主进程(master process)和多个工作进程(worker processes)。主进程通常以 root 用户权限运行,以便能够绑定到特权端口(如 80 和 443),而工作进程则通常以一个非特权用户(如 nobody)的身份运行,以提高安全性。

如何更改工作进程的用户

vi /etc/nginx/nginx.conf

把: user nobody;  改成xxxx  然后启动后就是 woker进程就是xxx用户组

一些配置介绍

     proxy_temp_file_write_size属性。属性作用:当你访问资源信息超过该参数设置的大小时,nginx会先将文件写入临时目录(这里是:/var/lib/nginx/tmp)。

,如果使用root用户执行nginx -t命令,则会导致临时文件(fastcgi、scgi、uwsgi、client_body、proxy)目录权限所有者被更改为nobody

 client_body_temp、fastcgi_temp、proxy_temp、scgi_temp、uwsgi_temp


http://www.kler.cn/a/374917.html

相关文章:

  • Pytorch | 利用DTA针对CIFAR10上的ResNet分类器进行对抗攻击
  • 详解MySQL在Windows上的安装
  • 41.3 将重查询记录增量更新到consul和redis中
  • 联通 路由器 创维SK-WR9551X 联通华盛VS010 组mesh 和 锐捷X32 PRO 无缝漫游
  • 为什么需要设置 `NCCL_P2P_DISABLE=1` 和 `NCCL_IB_DISABLE=1`?
  • XQR5VFX130-1CN1752V,,具有高度的可编程性和灵活性的FPGA中文技术资料
  • Windows下Jenkins自动启动jar包
  • 技术总结(十九)
  • unity后端kbengine用DOTween让 移动同步丝滑
  • HJ106 字符逆序
  • 发布 NPM 包时,终端显示发布成功但实际上版本并没有更新,可能是由于以下原因
  • 基于 Postman 和 Elasticsearch 测试乐观锁的操作流程
  • Java的多态
  • LEADTOOLS 版本 23 现已发布,引入了 Excel API等众多新功能!
  • 就业市场变革:AI时代,我们将如何评估人才?
  • Python之groupby()及aggregate()方法
  • 手机实时提取SIM卡打电话的信令声音-新的篇章(三、Android虚拟声卡探索)
  • 每日互动基于 Apache DolphinScheduler 从容应对ClickHouse 大数据入库瓶颈
  • 巨好看的登录注册界面源码
  • 【 纷享销客-注册安全分析报告-无验证方式导致安全隐患】
  • C++:二叉搜索树进阶
  • flink 自定义kudu connector中使用Metrics计数平均吞吐量,并推送到自定义kafkaReporter
  • DDIM扩散模型的加速采样(去噪)算法 Denoising Diffusion Implicit Models
  • windows 11 配置 kafka 使用SASL SCRAM-SHA-256 认证
  • 操作符详解
  • Java第二阶段---15异常---第三节 自定义异常