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 ...
随机推荐
- Java的多线程编程模型5--从AtomicInteger开始(自增长实现)
AtomicInteger,一个提供原子操作的Integer的类.在Java语言中,++i和i++操作并不是线程安全的,在使用的时候,不可避免的会用到synchronized关键字.而AtomicIn ...
- MyBatis入门示例——MyBatis学习笔记之一
MyBatis是另外一款优秀的ORM框架,前身为iBATIS.凡事预则立,不预则废.鉴于以后的项目可能会用到它,因此决定提前学习.本着分享和督促自己学习的目的,笔者将陆续把学习笔记贴出,希望对朋友们有 ...
- JavaCC 研究与应用( 8000字 心得 源程序)
一.JavaCC简介 JavaCC(Java Compiler Compiler)是一个用JAVA开发的最受欢迎的语法分析生成器.这个分析生成器工具可以读取上下文无关且有着特殊意义的语法并把它转换成可 ...
- SQL 语法解释器jsqlparser
是用java 开发的解析器, 可以生成java类层次结构. 主页地址: http://jsqlparser.sourceforge.net 可以完美解析 表的 增删查改等操作. 展开它的源码你会发现. ...
- Python之读写Excel
现有的Excel分为两种格式:xls(Excel 97-2003)和xlsx(Excel 2007及以上). Python处理Excel文件主要是第三方模块库xlrd.xlwt.pyexcel-xls ...
- uniapp安卓在线更新版本
实现逻辑 通过获取线上的版本号和app的版本号进行对比 查看是不是最新版 - app版本号小于线上版本号则不是最新版 提示更新 模拟检测更新请求 起一个服务,也就是检测更新的接口 返回值为最新版本号和 ...
- Win10底部任务栏卡死的终极解决方法
原因:微软自带的资讯和兴趣因国内网络限制,造成失效. 解决方案:底部右键->资讯和兴趣->关闭. 以上仅限WIn10操作系统,win11操作系统以上忽略.
- 07C++选择结构(1)——教学
一.基础知识 1.关系运算符 因为我们要对条件进行判断,必然会用到关系运算符: 名称 大于 大于等于 小于 小于等于 等于 不等于 符号 > >= < <= == != 关系表 ...
- FCM发送测试消息(控制台和postman)
方法1 在firebase控制台新建通知 点击cloud messaging后点击新建通知 输入标题和内容,点击右边的发送测试消息,注意要在真机接收,模拟器收不到 然后添加测试令牌,测试令牌可以在ap ...
- sudo kill -HUP 10146
systemctl status docker systemctl reload docker