首页 > 系统相关 >Rocky Linux:编译安装nginx 1.24.0(Rocky Linux 9.1)

Rocky Linux:编译安装nginx 1.24.0(Rocky Linux 9.1)

时间:2023-05-10 11:35:20浏览次数:54  
标签:Rocky img local nginx usr Linux root 1.24

一,官网:

http://nginx.org/ 如图:

二,下载并解压

下载:

[root@img nginx]# wget http://nginx.org/download/nginx-1.24.0.tar.gz
解压:
[root@img nginx]# tar -zxvf nginx-1.24.0.tar.gz 

说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest

         对应的源码可以访问这里获取: https://github.com/liuhongdi/
         或: https://gitee.com/liuhongdi

说明:作者:刘宏缔 邮箱: [email protected]

三,安装

配置

#--prefix 指定安装路径

#--with-http_stub_status_module    允许查看nginx状态的模块

# --with-http_ssl_module     支持https的模块

[root@img nginx-1.24.0]# ./configure --prefix=/usr/local/soft/nginx-1.24.0 --with-http_stub_status_module --with-http_ssl_module
编译并安装
[root@img nginx-1.24.0]# make && make install  

四,configure时遇到报错的处理:

报错:
./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.
解决:
[root@img nginx-1.24.0]# dnf install pcre-devel

五,查看软件信息

1,查看版本
[root@img nginx-1.24.0]# /usr/local/soft/nginx-1.24.0/sbin/nginx -v
nginx version: nginx/1.24.0
2,查看编译参数
[root@img nginx-1.24.0]# /usr/local/soft/nginx-1.24.0/sbin/nginx -V
nginx version: nginx/1.24.0
built by gcc 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
built with OpenSSL 3.0.1 14 Dec 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/soft/nginx-1.24.0 --with-http_stub_status_module --with-http_ssl_module

六,用systemctl管理nginx服务:

1,创建目录
[root@img nginx-1.24.0]# mkdir /web/logs/nginxlogs
[root@img nginx-1.24.0]# chmod 777 /web/logs/nginxlogs/
2,创建用户

#-g:指定所属的group

#-s:指定shell,因为它不需要登录,所以用/sbin/nologin

#-M:不创建home目录,因为它不需要登录

[root@img nginx-1.24.0]# groupadd nginx
[root@img nginx-1.24.0]# useradd -g nginx -s /sbin/nologin -M nginx
3,编辑配置文件:
[root@img nginx-1.24.0]# cd /usr/local/soft/nginx-1.24.0/conf/
[root@img conf]# vi nginx.conf
文件内容 指定运行nginx的用户和组
user  nginx nginx;
指定错误日志的路径
error_log   /web/logs/nginxlogs/error.log;
指定pid的路径
pid        logs/nginx.pid;
指定日志格式(去掉注释即可)
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for”';
指定访问日志的路径
access_log  /web/logs/nginxlogs/access.log  main;
  4,创建service文件
[root@img nginx-1.24.0]# vi /usr/lib/systemd/system/nginx.service
文件内容
[Unit]
Description=nginx-The High-performance HTTP Server
After=network.target


[Service]
Type=forking
PIDFile=/usr/local/soft/nginx-1.24.0/logs/nginx.pid
ExecStartPre=/usr/local/soft/nginx-1.24.0/sbin/nginx -t -c /usr/local/soft/nginx-1.24.0/conf/nginx.conf
ExecStart=/usr/local/soft/nginx-1.24.0/sbin/nginx -c /usr/local/soft/nginx-1.24.0/conf/nginx.conf
ExecReload=/usr/local/soft/nginx-1.24.0/sbin/nginx -s reload
ExecStop=/usr/local/soft/nginx-1.24.0/sbin/nginx -s stop
PrivateTmp=true


[Install]
WantedBy=multi-user.target
5,重新加载服务文件
[root@img nginx-1.24.0]# systemctl daemon-reload

 

启动服务:
[root@img nginx-1.24.0]# systemctl start nginx
6,访问nginx服务,如图:  

七,查看linux的版本:

[root@blog ~]# cat /etc/redhat-release
Rocky Linux release 9.1 (Blue Onyx)

 

标签:Rocky,img,local,nginx,usr,Linux,root,1.24
From: https://www.cnblogs.com/architectforest/p/17387467.html

相关文章

  • Linux 设置 LD_LIBRARY_PATH
    转载:https://www.cnblogs.com/zhanggaofeng/p/7535034.html 在Linux下,如果自己写好一个动态链接库,需要在其他程序里调用,则需要让这些程序能找到这个动态链接库,如果设置的不对,就会出现类似的错误:errorwhileloadingsharedlibraries:libmysqlclientso.so.0:cannotopens......
  • LINUX杂七杂八
    一、防火墙的设置相关开放端口:firewall-cmd--zone=public--add-port=8089/tcp--permanent重启服务,让开放生效:systemctlrestartfirewalld查看是否成功开放:firewall-cmd--list-ports二、调整系统打开文件的限制数:打开终端,输入命令:ulimit-n,查看当前系统的文件打开限制,......
  • linux 查看文件中的特殊字符
    1.cat命令cat-Afilename^M是Windows文件中的字符,即\r优缺点:cat命令会查看文件的全部内容,并不能像more命令那样翻页操作,当文件较大时,不适合使用cat命令!2.vi/vim命令#进入编辑页面vifilename#使用:setlist或者:setinvlist ......
  • linux下拆分PDF、批量裁剪图片及合并为PDF操作
    好久不碰代码,文件操作啥的快忘光了(你丫本来就没怎么学吧!)我先放两串代码在这QAQ拆分PDFpdftoppm-png?.pdfs批量裁剪图片裁剪图片指令,这个指令是ImageMagick带的一个什么东西,单位电脑能装convertsrc.png-crop长x高+起始像素点横坐标+起始像素低纵坐标dest.png然后......
  • nginx部署vue项目显示空白页
    报错提示:index-fbb90c85.js:1Failedtoloadmodulescript:ExpectedaJavaScriptmodulescriptbuttheserverrespondedwithaMIMEtypeof"text/plain".原因:nginx使用容器部署,nginx.conf文件指定引用mime类型文件.解决方法:1.添加include/etc/nginx/mim.ty......
  • Linux安装gitbook
    Linux安装gitbook下载nodejs包wgethttps://npm.taobao.org/mirrors/node/v12.16.1/node-v12.16.1-linux-x64.tar.gz解压tar-zxvfnode-v12.16.1-linux-x64.tar.gz建立软连接[root@VM-16-13-centos~]#lsnode-v12.16.1-linux-x64node-v12.16.1-linux-x64.tar.......
  • rocky linux: 禁止使用root登录ssh,只允许指定用户(Rocky Linux 9.1)
    一,配置可以sudo的用户参考这个:https://www.cnblogs.com/architectforest/p/17386259.html二,禁止使用root登录ssh1,配置ssh[root@img~]#vi/etc/ssh/sshd_config配置内容:设置PermitRootLogin值为no#PermitRootLoginyesPermitRootLoginno新增一行:AllowUsers......
  • Linux系统的内存摘要
    通过free-m查看系统内存使用情况total:总内存大小。used:已经使用的内存大小(这里面包含cached和buffers和shared部分)。free:空闲的内存大小。shared:进程间共享内存(一般不会用,可以忽略)。buffers:内存中写完的东西缓存起来,这样快速响应请求,后面数据再定期刷到磁盘上。cached......
  • Java获取当前路径(Linux+Windows)
    Java获取当前路径(Linux+Windows)获取当前路径(兼容Linux、Windows):StringcurPath=System.getProperty("user.dir");log.info("===========当前路径===========curPath:{}",curPath);输出结果:===========当前路径===========curPath:/home/lizhm......
  • Linux的这七大认识误区,你千万别有!
    本文罗列了大家对Linux的七大认识误区,看看其中那个是你也出现过的。千万别让这些先入为主的观点断送了你体验新事物的机会。Linux的受众群体并不大。对还是错?错!大错而特错。我承认,Linux的实际用户数量很难统计,因为其免费开放下载且并未由单一企业进行控制。没有明确的销......