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 ...
随机推荐
- PHP5.2-5.6不同版本新特性
温故而知新, 时常复习下之前的东西 还是会有一些收获 本文目录:PHP5.2 以前:autoload, PDO 和 MySQLi, 类型约束PHP5.2:JSON 支持PHP5.3:弃用的功能,匿名函 ...
- python之常用开发包
1.passlib (https://passlib.readthedocs.io/en/stable/) passlib 目前常见的不可逆加密算法有以下几种: 一次MD5(使用率很高) 将密码与一个 ...
- Mac之终端工具iterm2
1. 安装 iTerm2 下载地址:https://www.iterm2.com/downloads.html 下载的是压缩文件,解压后是执行程序文件,你可以直接双击,或者直接将它拖到 Applica ...
- Codeforces Round 895 (Div. 3)
B. The Corridor or There and Back Again 题解 考虑二分答案 \(check\)时判断是否\(s_i \leq 2*(k - d_i),k\geq d_i\) c ...
- 正也科技案例 | 药企使用S2P深入营销管理数据化建设
为了获取更*的市场空间,医药健康行业正迎来一波前所未有的产业升级.尽管不少企业取得了许多成绩,但仍面临诸多挑战. 浙江某知名医药公司,在泌尿系统.心脑血管系统及眼科用药领域均拥有强势品牌.其产品更是荣 ...
- SQLServer使用STUFF-for xml path实现结果行列转置
源数据: 场景1: 查出用户的爱好,并进行行列转置 select cname, stuff((select ','+f.favor from tb_favor f where f.userid=b.u ...
- 有关终端Github无法访问,connection timed out:443等问题
有关终端Github无法访问,connection timed out:443等问题 SSL_connect: Operation timed out in connection to github. ...
- 【项目学习】Morpho 借贷协议简单调研
项目背景 Morpho blue (下称 Morpho)是一个超额抵押借贷协议.与传统的借贷协议不同,Morpho 无需经过治理批准即可创建任意定制化的借贷市场.用户可以通过指定一项贷款资产.一项抵押 ...
- 【前端】CSS:border
border 是CSS中用于设置元素边框的. 第一个参数为线的粗细.除了数字型值外,还可以写: thin(细线) medium(中粗线) thick(粗线) 第二个参数是线条样式,可选参数如下: 小圆 ...
- 使用JSch进行sftp的连接运行状况检查
public boolean checkConnection() throws JSchException { try { JSch jsch = new JSch(); Session sessio ...