首页 > 系统相关 >Nginx 编译安装

Nginx 编译安装

时间:2022-11-25 17:44:17浏览次数:45  
标签:编译 nginx -- apps module Nginx conf http 安装

Nginx 编译安装

安装环境:
rocky8.0 

**安装前将防火墙和selinux关闭**
**文件中有注释的地方,复制时记得删除掉**

官方包地址:http://nginx.org/en/linux_packages.html

#下载包
wget http://nginx.org/download/nginx-1.22.1.tar.gz

#安装依赖包
yum -y install gcc pcre-devel openssl-devel zlib-devel

#创建NGINX专用账号
useradd -s /sbin/nologin nginx

#解压并进入目录
tar xf nginx-1.22.1.tar.gz 
cd nginx-1.22.1
#功能选择及安装
./configure --prefix=/apps/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module

make && make install


#Nginx目录结构
[root@Rocky8 nginx-1.22.1]# tree /apps/nginx/
/apps/nginx/
├── conf
│   ├── fastcgi.conf
│   ├── fastcgi.conf.default
│   ├── fastcgi_params
│   ├── fastcgi_params.default
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── mime.types.default
│   ├── nginx.conf
│   ├── nginx.conf.default
│   ├── scgi_params
│   ├── scgi_params.default
│   ├── uwsgi_params
│   ├── uwsgi_params.default
│   └── win-utf
├── html
│   ├── 50x.html
│   └── index.html
├── logs
└── sbin
    └── nginx



#创建 Nginx 自启动文件
vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/apps/nginx/run/nginx.pid #指定pid文件的目录,默认在logs目录下,可选配置
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target



#创建pid文件存放的目录
mkdir /apps/nginx/run/
#修改配置文件指定pid文件路径
vim /apps/nginx/conf/nginx.conf
pid /apps/nginx/run/nginx.pid;

#验证自启动文件
systemctl daemon-reload
systemctl enable --now nginx
ss -ntl
#重启测试自启动文件是否生效
reboot

#安装完成后如果没有nginx命令执行一下方法
[root@Rocky8 ~]# nginx -h
bash: nginx: command not found...
Install package 'nginx' to provide command 'nginx'? [N/y] n
[root@Rocky8 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@Rocky8 ~]# vim /etc/profile
export PATH=$PATH:/apps/nginx/sbin #根据nginx的安装路径填写

标签:编译,nginx,--,apps,module,Nginx,conf,http,安装
From: https://www.cnblogs.com/zhangsy714/p/16925872.html

相关文章

  • std::filesystem 使用时编译不过去
    #include<filesystem>namespacefs=std::filesystem;解决方法:https://stackoverflow.com/questions/53201991/how-to-use-stdfilesystem-on-gcc-8实际是需要在编译......
  • go源码学习(零):前置知识-编译过程
    编译原理-从源码到机器码任何一门高级语言,要想最终能够在机器上执行那么就一定要从源码生成机器码,因为对于机器来说,它只认同由0和1组成的二进制程序。从人类可读的源码到......
  • 搭建Prometheus+Grafana+AlertManager监控报警系统之CentOS 7安装node exporter
    简介在Prometheus的架构设计中,PrometheusServer并不直接服务监控特定的目标,其主要任务负责数据的收集,存储并且对外提供数据查询支持。因此为了能够能够监控到某些东西,如......
  • Mac 安装Minikube
    环境信息:guoguo-MacBook-Pro-3:~guoguo$dockerversionClient: Version:   17.12.0-ce APIversion:   1.35 Goversion:   go1.9.2 Gitcommit:   c......
  • centos7安装rabbitmq3.9.16
    下载erlangwget--content-disposition--no-check-certificatehttps://packagecloud.io/rabbitmq/erlang/packages/el/7/erlang-23.3.4.11-1.el7.x86_64.rpm/download.......
  • npm install 国内镜像 安装方式 快
    #建议不要直接使用cnpm安装以来,会有各种诡异的bug。可以通过如下操作解决npm下载速度慢的问题npminstall--registry=https://registry.npm.taobao.orghttps://se......
  • Gitlab 安装与配置
    参考:Gitlab安装与配置Gitlab安装使用docker-compose安装Gitlab,traefik反向代理Gitlab,并开启https编辑docker-compose.yaml文件注意将YOU_XXX换成符合要求的名......
  • 新人ubuntu安装phantomjs踩坑
    PhantomJS​​PhantomJS​​ 是一个基于Webkit的“无界面”(headless)浏览器,它会把网站加载到内存并执行页面上的JavaScript,因为不会展示图形界面,所以运行起来比完整的浏......
  • 阿里云服务(centos8)安装mysql8.0
    注意不同版本间的安装方式不太一样②如果出现:Error:GPGcheckFAILED这是gpg验证不通过的原因,因为我是在centos8系统上安装mysql57-community-release-el7-10.noarc......
  • centos7 关闭firewall安装iptables并配置
     一、配置防火墙,开启80端口、3306端口CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。1、关闭firewall:systemctlstopfirewalld.service ......