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

web集群学习:源码安装nginx配置启动服务脚本

1、源码安装nginx,并提供服务脚本。

1、源码安装会有一些软件依赖

(1)检查并安装 Nginx 基础依赖包 pcre-devel 、openssl-devel

# rpm -qa | egrep 'pcre-devel | openssl-devel'

(2)安装 Nginx 所需的 pcre 库 正则支持

pcre 的全称为 perl compatible regular expressions,中文译为 “ perl 兼容正则表达式”,官方站点为 http://www.pcre.org/, 安装 pere 库是为了使 Nginx 支持具备 URI 重写功能的 rewrite 模块,如果不安装 pere 库,则 Nginx 无法使用 rewrite 模块功能,Nginx的 rewrite 模块功能几乎是企业应用必须的。

yum install -y pcre-devel

(3) 安装 openssl-devel 加密支持
Nginx 在使用 HTTPS 服务的时候要用到此模块,如果不安装 openssl 相关包,安装Nginx 的过程中会报错。

yum install -y openssl-devel

(4)安装编译软件

yum install gcc gcc-c++ make -y

2、 nginx获取

RPM包获取:Index of /packages/

源码包获取:Index of /download/

(1)这里我选择的版本为nginx-1.22.0,通过wget安装

wget http://nginx.org/download/nginx-1.22.0.tar.gz

(2)解压tengine到指定文件夹

[root@node3 ~]# tar xf nginx-1.22.0.tar.gz -C /usr/local/src/
[root@node3 ~]# cd /usr/local/src/nginx-1.22.0/

(3)创建用户nginx 此处只设置便于不登录即可

useradd nginx -u 996 -r -g 1000 -s /sbin/nologin -c "nginx user"

 (4)开始安装 Nginx

[root@localhost nginx-1.22.0]# ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module 

(5)编译安装

make && make install

  (6)  为nginx提供SysV init脚本

[root@node3 nginx-1.22.0]# vim /usr/lib/systemd/system/nginx.service[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c   /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true[Install]
WantedBy=multi-user.target               

重新加载启动脚本并启动服务

 测验通过本机测试
显示此网页访问成功

 

http://www.lryc.cn/news/111179.html

相关文章:

  • LNMP
  • Python网络爬虫在信息采集中的应用及教程
  • 云主机测试Flink磁盘满问题解决
  • iOS开发-NSOperationQueue实现上传图片队列
  • 通过 CCIP 构建跨链应用(5 个案例)
  • 基于 yolov8 的人体姿态评估
  • 计算机视觉(六)图像分类
  • 解决:vue通过params传参刷新页面参数丢失问题以及实现vue路由可选参数的解决办法
  • 将postman接口导出的json转换为markdown
  • 教您一招解决找素材困难好的方法
  • python_PyQt5开发验证K线视觉想法工具V1.2_批量验证
  • 应急响应-web后门(中间件)的排查思路
  • XML 学习笔记 7:XSD
  • neo4j图数据库基础操作命令(CQL语法)
  • vscode无法连接远程服务器的可能原因:远程服务器磁盘爆了
  • SSL 证书过期巡检脚本 (Python 版)
  • 从0到1自学网络安全(黑客)【附学习路线图+配套搭建资源】
  • Michael.W基于Foundry精读Openzeppelin第20期——EnumerableMap.sol
  • 深入探索二叉树:应用、计算和遍历
  • 关于 1 + 1 = 2 的证明
  • 【C++】——内存管理
  • Jmeter录制HTTPS脚本
  • Linux 的Centos 7 安装 启动 Google Chrome
  • DNS WEB HTTP
  • 微信小程序animation动画,微信小程序animation动画无限循环播放
  • node.js
  • 【微信小程序创作之路】- 小程序远程数据请求、获取个人信息
  • XML基础知识讲解
  • (十二)大数据实战——hadoop集群之HDFS高可用自动故障转移
  • Ubuntu下载deb包及其依赖包