网站首页 > 技术教程 正文
Nginx的安装方法有两种,一种是rpm安装 方式,另一种是解压安装的方式,第一种方法比较的简单,第二种相对折腾一点,我在第二种安装方式中,编译Nginx出错./configure: error: C compiler cc is not found,
同时还有,checking for PCRE library … not found,还有导致的原因是没有编译工具
对于nginx编译安装需要先安装编译 的工具,然后再安装nginx依赖
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
12
添加www用户
添加www用户,如果没有可能会报错nginx: [emerg] getpwnam(“www”) failed
#添加www 用户
groupadd -f www
useradd -g www www
123
下载nginx
#管网镜像
http://nginx.org/download/
#获取nginx,官方地址
wget http://nginx.org/download/nginx-1.10.1.tar.gz
#1.6.2 这个老版本,不支持 --with-stream 模块,1.9.0后,才支持的,建议大家使用的时候注意
#wget http://nginx.org/download/nginx-1.6.2.tar.gz
#这个是我自己七牛的服务器
wget http://yellowcong.qiniudn.com/nginx-1.10.1.tar.gz
#nginx 2019/4/2 新得版本
wget http://nginx.org/download/nginx-1.15.9.tar.gz
#解压 /usr/local/nginx 目录
tar -zxvf nginx-1.10.1.tar.gz
12345678910111213141516
安装nginx
第一步是配置,第二步是编译安装
编译并安装
make && make install1
启动、停止、重启
# 1.启动nginx
shell> nginx
# 可通过ps -ef | grep nginx查看nginx是否已启动成功
# 2.停止nginx
shell> nginx -s stop
# 3. 重新启动
shell> nginx -s reload1234567
nginx默认配置启动成功后,会有两个进程,一个主进程(守护进程),一个工作进程。主进程负责管理工作进程,工作进程负责处理用户的http请求。
配置nginx开机启动
将/usr/bin/nginx命令添加到/etc/rc.d/rc.local文件中,rc.local文件会在系统启动的时候执行。但CentOS7建议将开机启动服务写成服务描述文件添加到系统服务中,所以rc.local默认没有执行权限,需要给它添加执行权限。
shell> vim /etc/rc.d/rc.local
# 添加如下参数
/usr/bin/nginx
shell> chmod +x /etc/rc.d/rc.local12345
或者通过supervisor管理nginx进程,实现开机自动启动,且进程挂掉后自动重启。详情请参考《Supervisor安装与配置(Linux/Unix进程管理工具)》
错误合集
1、./configure: error: C compiler cc is not found
错误消息
[root@1088d470c710 nginx-1.10.1]# ./configure
checking for OS
+ Linux 3.10.0-514.26.2.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
1234567
解决办法
安装编译工具
[root@1088d470c710 nginx-1.10.1]# yum -y install gcc gcc-c++ autoconf automake make
12
然后再次编译,可以了,然而又遇到了新问题
2、checking for PCRE library … not found
pcre没有发现的问题,需要安装pcre ,他作用是让ngnix支持rewrite功能
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
12345678910
3、安装pcre
我打算安装的,结果发现这鸡毛已经安装过了,然后我需要在./configure的时候指定目录./configure --with-pcre=./auto/lib/pcre
[root@1088d470c710 nginx-1.10.1]# yum install pcre
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package pcre-8.32-15.el7_2.1.x86_64 already installed and latest version
12345678
简单说一下centos如何查找文件
#查找文件,需要获取pcre的安装位置
find -name pcre
4、安装zlib
还缺少zlib library信息,感觉编译nginx是一个错误,直接使用rpm安装包多爽,安装zlib吧,别说别的了
yum -y install make zlib zlib-devel gcc-c++ libtool
1
错误信息
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
1234
5、cp: “conf/koi-win” 与"/usr/local/nginx/nginx-1.6.2/conf/koi-win" 为同一文件
文件为同一个文件的问题
cp: "conf/koi-win" 与"/usr/local/nginx/nginx-1.6.2/conf/koi-win" 为同一文件
make[1]: *** [install] 错误 1
make[1]: 离开目录“/usr/local/nginx/nginx-1.6.2”
make: *** [install] 错误 2
总结:
一起学习的可以后台私信“资料”送学习视频资料包括C/C++,Linux,golang技术,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,TCP/IP,协程,DPDK,ffmpeg等等。。。),免费分享
猜你喜欢
- 2024-10-12 详解定制rpm包一键部署过程(rpm制作安装包)
- 2024-10-12 离线安装所有可直接yum的服务(离线安装文件是什么)
- 2024-10-12 linux之yum下载rpm包离线安装(linux离线安装yum 源)
- 2024-10-12 你不知道的rpm别样用法(rpm格式是什么意思)
- 2024-10-12 CentOS下如何制作nginx RPM包(linux nginx rpm安装)
- 2024-09-22 CentOS 7.X 上 安装Nginx+php环境
- 2024-09-22 Linux centos 安装nginx(linux中nginx安装)
- 2024-09-22 19《Nginx 入门教程》Nginx综合实践
- 2024-09-22 linux下安装nginx(linux安装nginx详细教程)
- 2024-09-22 CentOS7 yum 安装 Nginx最新版本(centos7配置阿里云yum源)
你 发表评论:
欢迎- 最近发表
-
- Win10 TH2正式版官方ESD映像转换ISO镜像方法详解
- 使用iso镜像升级到Windows 10的步骤
- macOS Ventura 13.2 (22D49) Boot ISO 原版可引导镜像
- 安利一个用ISO镜像文件制作引导U盘的的小工具RUFUS
- CentOS 7使用ISO镜像配置本地yum源
- 用于x86平台的安卓9.0 ISO镜像发布下载:通吃I/A/N、完全免费
- AlmaLinux 9.6发布:升级工具、初步支持IBM Power虚拟化技术
- Rufus写入工具简洁介绍与教程(写入模式)
- 新硬件也能安装使用了,Edge版Linux Mint 21.3镜像发布
- 开源工程师:Ubuntu应该抛弃32位ISO镜像
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)