nginx 编译安装及配置解析
一、编译安装
安装插件
安装需要的组件
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
1、gcc是linux下的编译器在此不多做解释,感兴趣的小伙伴可以去查一下相关资料,它可以编译 C,C++,Ada,Object C和Java等语言
查看gcc版本
gcc -v
ldd --version
安装命令 gcc、gcc-c++
yum -y install gcc gcc-c++
2、pcre、pcre-devel安装
pcre是一个perl库,包括perl兼容的正则表达式库,nginx的http模块使用pcre来解析正则表达式,所以需要安装pcre库。
安装命令:
yum install -y pcre pcre-devel
3、zlib安装
zlib库提供了很多种压缩和解压缩方式nginx使用zlib对http包的内容进行gzip,所以需要安装
安装命令:
yum install -y zlib zlib-devel
4、安装openssl
yum install -y openssl openssl-devel
安装nginx
1、下载nginx安装包并解压
mkdir /software && cd /software
wget http://nginx.org/download/nginx-1.19.9.tar.gz
tar -zxvf nginx-1.19.9.tar.gz
cd nginx-1.19.9.tar.gz
2、编译并安装
检查环境配置环境,默认配置路径在/user/local/nginx
./configure --prefix=/usr/local/nginx

也可以自定义路径
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
执行安装
make&&make install
3、配置文件并启动
切换到/usr/local/nginx主目录

配置文件 vim conf/nginx.conf
启动nginx
cd /usr/local/nginx/sbin/
./nginx
启停检查语法
cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload
./nginx -t
4、检查访问主页
防火墙添加80端口
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload
web端访问ip

二、nginx服务启动
nginx启动脚本
# chkconfig: 2345 85 15
# description:Nginx Server NGINX_HOME=/usr/local/nginx
NGINX_SBIN=$NGINX_HOME/sbin/nginx
NGINX_CONF=$NGINX_HOME/conf/nginx.conf
NGINX_PID=$NGINX_HOME/logs/nginx.pid NGINX_NAME="Nginx" . /etc/rc.d/init.d/functions if [ ! -f $NGINX_SBIN ]
then
echo "$NGINX_NAME startup: $NGINX_SBIN not exists! "
exit
fi start() {
$NGINX_SBIN -c $NGINX_CONF
ret=$?
if [ $ret -eq 0 ]; then
action $"Starting $NGINX_NAME: " /bin/true
else
action $"Starting $NGINX_NAME: " /bin/false
fi
} stop() {
kill `cat $NGINX_PID`
ret=$?
if [ $ret -eq 0 ]; then
action $"Stopping $NGINX_NAME: " /bin/true
else
action $"Stopping $NGINX_NAME: " /bin/false
fi
} restart() {
stop
start
} check() {
$NGINX_SBIN -c $NGINX_CONF -t
} reload() {
kill -HUP `cat $NGINX_PID` && echo "reload success!"
} relog() {
kill -USR1 `cat $NGINX_PID` && echo "relog success!"
} case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
check|chk)
check
;;
status)
status -p $NGINX_PID
;;
reload)
reload
;;
relog)
relog
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status|check|relog}"
exit 1
esac
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
三、安装nginx遇到的问题
已经安装gblic版本 2.17-324.el7.9.x86_64版本太高 需要降级

查看当前rpm安装版本
rpm -qa |grep glibc

解决方法:挂载iso镜像 添加本地yum仓库
降低版本,再查看
yum clean all && yum makecache
yum downgrade glibc glibc-devel glibc-common glibc-headers
rpm -qa |grep glibc

安装gblic版本 2.17-317.el7.9.x86_64就可以继续了
nginx 编译安装及配置解析的更多相关文章
- nginx编译安装以及配置tcp转发
依赖包安装 yum -y install gcc gcc-c++ make automake autoconf pcre pcre-devel zlib zlib-devel openssl open ...
- [nginx]编译安装及安全优化
nginx配置-最后整理版 nginx_upstream_check_module nginx-module-vts nginx打补丁 nginx编译安装 - 下载 cd /usr/local/src ...
- CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境
CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境 什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/ ...
- nginx编译安装支持lua脚本
一.准备编译环境 1.操作系统:CentOS7.6 2.安装编译所需安装包 yum install gcc pcre pcre-devel zlib zlib-devel openssl openss ...
- nginx的安装与配置
1.nginx的安装与配置 编译安装nginx需要实现安装开发包组“Development tools”和“Server Platform Development”.“Desktop Platform ...
- LNMP平台搭建之一:nginx编译安装
参考博客:https://www.cnblogs.com/zhang-shijie/p/5294162.html jack.zhang 一.环境说明 系统环境:centos6.5 [root@lo ...
- Nginx编译安装lua-nginx-module
lua-nginx-module 模块可以将Lua的强大功能嵌入NGINX服务器. 下载Nginx源码 如果已安装Nginx,需要查看当前安装版本的编译参数: $ /usr/local/nginx/s ...
- Linux下nginx编译安装教程和编译参数详解
这篇文章主要介绍了Linux下nginx编译安装教程和编译参数详解,需要的朋友可以参考下 一.必要软件准备1.安装pcre 为了支持rewrite功能,我们需要安装pcre 复制代码代码如下: # y ...
- Nginx编译安装第三方模块http_substitutions_filter_module2222
Nginx编译安装第三方模块http_substitutions_filter_module Rming -- 阅读 安装 Http 编译 module filter nginx 模块 >> ...
- Nginx编译安装第三方模块http_substitutions_filter_module
Nginx编译安装第三方模块http_substitutions_filter_module 分类:服务器技术 作者:rming 时间:-- . >>ngx_http_substitu ...
随机推荐
- laravel框架之ORM操作
Laravel 支持原生的 SQL 查询.流畅的查询构造器 和 Eloquent ORM 三种查询方式: 流畅的查询构造器(简称DB),它是为创建和运行数据库查询提供的一个接口,支持大部分数据库操作, ...
- phpstorm之代码质量工具
在进行php开发的时候, 经常由于编码上的不规范导致了隐藏的bug,这里介绍代码质量工具 PHP CodeSniffer: phpcs [安装] composer require squizla ...
- offline RL · PbRL | LiRE:构造 A>B>C 的 RLT 列表,得到更多 preference 数据
论文标题:Listwise Reward Estimation for Offline Preference-based Reinforcement Learning,ICML 2024. arxiv ...
- bat隐藏窗口运行
在bat脚本开头添加: if "%1" == "h" goto begin mshta vbscript:createobject("wscript. ...
- SpringCloudStream极简教程
简介 Spring Cloud Stream 是一个轻量级消息驱动微服务框架,旨在简化与消息中间件(如 Kafka.RabbitMQ 等)的集成,支持消息的发布和订阅模式.它提供了一种基于 Sprin ...
- 通用的定时任务工具 schedule-server
背景: 我曾经在一个自动化测试平台中集成定时任务,基于 APScheduler 库花了好长时间解决重复执行的问题.定时任务集成在服务中也让服务变得复杂.最后,我们选择了公司其他团队go语言开发的一个定 ...
- 揭秘“山姆黄牛”背后的技术逻辑:用Java实现会员管理系统的防黄牛策略
在浙江绍兴的山姆超市外,"黄牛"现象引发了广泛关注.这些"黄牛"通过提供带入和结账服务,让未办理会员卡的消费者也能进入超市购物.这一行为不仅扰乱了市场秩序,也对 ...
- COSBrowser 文件夹分享——多端文件实时共享
您还在为临时分享某个文件夹而烦恼吗? 您是否对授权的复杂度感到震惊? 关于存储桶 Policy 权限,您是否很迷茫,不知如何设置? 不用着急,用 COSBrowser 开始文件夹分享,一键简化分享 ...
- 类型判断运算符(as、is、is!)
类型判断运算符 as.is.is! 运算符是在运行时判断对象类型的运算符. as 类型转换(也用作指定 类前缀)) is 如果对象是指定类型则返回 true is! 如果对象是指定类型则返回 fals ...
- 实用干货分享(2) - Docker使用操作指南
一.Docker安装部署 1. 安装仓库 执行以下命令,安装Docker所需的包.其中yum-utils提供yum-config-manager工具:device-mapper-persistent- ...