双节点安装
1 节点一
1.1 目录
/usr/local
cd /usr/local
1.2 openssl
rpm -ql openssl
/usr/share/doc/openssl-1.0.0
# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/share/doc/pcre-7.8/ --with-zlib=/usr/share/doc/zlib-1.2.3 --with-openssl=/usr/share/doc/openssl-1.0.0
1.3 pcre库
# rpm -qa | grep pcre
pcre-7.8-6.el6.x86_64
[root@r7 software]# rpm -qa | grep pcre
pcre-7.8-6.el6.x86_64
[root@r7 software]#
[root@r7 software]# rpm -e pcre-7.8-6.el6.x86_64
error: Failed dependencies:
libpcre.so.0()(64bit) is needed by (installed) grep-2.6.3-3.el6.x86_64
libpcre.so.0()(64bit) is needed by (installed) less-436-10.el6.x86_64
libpcre.so.0()(64bit) is needed by (installed) httpd-tools-2.2.15-26.el6.x86_64
libpcre.so.0()(64bit) is needed by (installed) sssd-1.9.2-82.el6.x86_64
libpcre.so.0()(64bit) is needed by (installed) httpd-2.2.15-26.el6.x86_64
libpcre.so.0()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
libpcre.so.0()(64bit) is needed by (installed) gnote-0.6.3-3.el6.x86_64
libpcrecpp.so.0()(64bit) is needed by (installed) gnote-0.6.3-3.el6.x86_64
pcre is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64
[root@r7 software]#
[root@r7 software]#
[root@r7 software]# rpm -e --nodeps pcre-7.8-6.el6.x86_64
[root@r7 software]# mkdir /usr/local/pcre
[root@r7 software]# rpm -ivh --prefix=/usr/local/pcre/ pcre-7.8-6.el6.x86_64.rpm
无法安装,重新只用rpm –ivh安装后使用rpm –ql 查看安装路径
[root@r7 software]# rpm -ql pcre
/lib64/libpcre.so.0
/lib64/libpcre.so.0.0.1
/usr/bin/pcregrep
/usr/bin/pcretest
/usr/lib64/libpcrecpp.so.0
/usr/lib64/libpcrecpp.so.0.0.0
/usr/lib64/libpcreposix.so.0
/usr/lib64/libpcreposix.so.0.0.0
/usr/share/doc/pcre-7.8
pcre要使用源码包,不然在安装nginx时会编译pcre,这时会报错。
1.4 zlib库
rpm -qa | grep zlib
zlib-devel-1.2.3-29.el6.x86_64
zlib-1.2.3-29.el6.x86_64
zlib也要使用源码包
1.5 nginx安装
cd /usr/local/
tar -xzvf nginx-1.2.8.tar.gz
cd nginx-1.2.8
./configure --prefix=/usr/local/nginx
需要pcre包
./configure --prefix=/usr/local/nginx --with-pcre=/usr/share/doc/pcre-7.8/
需要zlib包
./configure --prefix=/usr/local/nginx --with-pcre=/usr/share/doc/pcre-7.8/ --with-zlib=/usr/share/doc/zlib-1.2.3
需要OpenSSL
# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/share/doc/pcre-7.8/ --with-zlib=/usr/share/doc/zlib-1.2.3 --with-openssl=/usr/share/doc/openssl-1.0.0
Configuration summary
+ using PCRE library: /usr/share/doc/pcre-7.8/
+ using OpenSSL library: /usr/share/doc/openssl-1.0.0
+ md5: using system crypto library
+ sha1: using system crypto library
+ using zlib library: /usr/share/doc/zlib-1.2.3
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@r7 nginx-1.2.8]# make
make -f objs/Makefile
make[1]: Entering directory `/usr/local/nginx-1.2.8'
cd /usr/share/doc/pcre-7.8/ \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
/bin/sh: line 2: ./configure: No such file or directory
make[1]: *** [/usr/share/doc/pcre-7.8//Makefile] Error 127
make[1]: Leaving directory `/usr/local/nginx-1.2.8'
make: *** [build] Error 2
make 时,在编译pcre时报错。换作pcre的源码包重新编译ngnix
cd /usr/local/nginx-1.2.8
# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.02 --with-zlib=/usr/share/doc/zlib-1.2.3 --with-openssl=/usr/share/doc/openssl-1.0.0
Configuration summary
+ using PCRE library: /usr/local/pcre-8.02
+ using OpenSSL library: /usr/share/doc/openssl-1.0.0
+ md5: using system crypto library
+ sha1: using system crypto library
+ using zlib library: /usr/share/doc/zlib-1.2.3
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
make
zlib也要使用源码包
# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.02 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/share/doc/openssl-1.0.0
Configuration summary
+ using PCRE library: /usr/local/pcre-8.02
+ using OpenSSL library: /usr/share/doc/openssl-1.0.0
+ md5: using system crypto library
+ sha1: using system crypto library
+ using zlib library: /usr/local/zlib-1.2.8
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
make install
2 节点二
nginx依赖openssl、pcre、zlib的源码包。
2.1 安装包
nginx-1.2.8.tar.gz
openssl-1.0.1c.tar.gz
pcre-8.02.tar.gz
zlib-1.2.8.tar.gz
解压安装包至 /usr/local 目录
openssl如果使用rpm安装的话,需要两个都安装
# rpm -qa | grep openssl
openssl-1.0.0-27.el6.x86_64
openssl-devel-1.0.0-27.el6.x86_64
openssl-devel 安装需要的依赖包比较多,配置 yum 可简化安装
本次安装使用
2.2 安装nginx
[root@r8 local]# ls
bin etc games include lib lib64 libexec nginx-1.2.8 openssl-1.0.1c pcre-8.02 sbin share src zlib-1.2.8
[root@r8 local]#
[root@r8 local]# cd nginx-1.2.8/
[root@r8 nginx-1.2.8]# pwd
/usr/local/nginx-1.2.8
[root@r8 local]#
[root@r8 local]# mkdir nginx
[root@r8 local]# cd nginx-1.2.8/
[root@r8 nginx-1.2.8]# ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.02 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/share/doc/openssl-1.0.0
有一些东西没有找到,比如下面的资源,但不影响安装
checking for sys/filio.h ... not found
make
make install
需要说明的是,pcre与zlib的安装,下载相关源码并解压到/usr/local,在configre时使用—with-pcre和—with-zlib指向其解压目录即可。而openssl服务器上已经有了openssl-1.0.0-27.el6.x86_64,我以yum方式安装了openssl-devel-1.0.0-27.el6.x86_64,也可以卸载openssl进行源码安装,然后使用—with-openssl指向其安装目录即可。
3 常用操作
3.1 启动
[root@r8 sbin]# netstat -ntpl | grep 80
tcp 0 0 0.0.0.0:31713 0.0.0.0:* LISTEN 2803/gpnpd.bin
[root@r8 sbin]# pwd
/usr/local/nginx/sbin
[root@r8 sbin]# ./nginx
[root@r8 sbin]# netstat -ntpl | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 27496/nginx
tcp 0 0 0.0.0.0:31713 0.0.0.0:* LISTEN 2803/gpnpd.bin
3.2 配置conf
[root@r8 nginx]# cd conf/
[root@r8 conf]# pwd
/usr/local/nginx/conf
[root@r8 conf]# ls
fastcgi.conf fastcgi_params.default mime.types nginx.conf.default uwsgi_params
fastcgi.conf.default koi-utf mime.types.default scgi_params uwsgi_params.default
fastcgi_params koi-win nginx.conf scgi_params.default win-utf
[root@r8 conf]# vi nginx.conf
#user nobody;
worker_processes 1;
3.3 重启
# 语法检查
[root@r8 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# 重启
[root@r8 sbin]# ./nginx -s reload
4 常用配置
5 遇到问题
5.1 PID错误
[root@r8 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@r8 sbin]#
[root@r8 sbin]#
[root@r8 sbin]#
[root@r8 sbin]# ./nginx -s reload
nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
查看nginx.conf配置文件
[root@r8 conf]# vi nginx.conf
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
解决方法:使用nginx –c重新配置nginx.conf文件
[root@r8 sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
[root@r8 sbin]# ./nginx -s reload
[root@r8 sbin]#
相关推荐
### CentOS 下 Nginx 安装笔记 #### 环境准备 在开始安装 Nginx 之前,首先需要确保 CentOS 系统版本为 6.3 或更高版本。本篇文档将详细介绍如何在 CentOS 6.3 上完成 Nginx 的安装。 #### 安装必备工具:GCC ...
nginx学习笔记(软件+学习笔记) 仅供学习交流! 后续会持续分享相关资源,记得关注哦! nginx学习笔记(软件+学习笔记) 仅供学习交流! 后续会持续分享相关资源,记得关注哦! nginx学习笔记(软件+学习笔记) ...
nginx的笔记资料,nginx的笔记资料
这个“Nginx学习笔记.zip”压缩包文件包含了一系列关于Nginx的教程资源,分别命名为“第1节课”到“第5节课”,暗示着一个逐步深入的学习过程。 在第一节课中,我们通常会了解Nginx的基本概念和安装步骤。Nginx的...
黑马23期Linux+Nginx 的笔记,介绍如何搭建Nginx环境(Linux下)
本学习笔记将深入探讨Nginx的核心概念、安装与配置、反向代理、负载均衡、缓存管理以及日志记录等多个方面,旨在帮助读者全面掌握Nginx的使用技巧。 **一、Nginx核心概念** 1. **事件模型**:Nginx采用异步非阻塞...
里面有关于nginx所有的配置具体的介绍,其中有nginx怎样配置负载均衡,图片服务器,资源压缩,黑白名单限制,websocket反向代理,rewrite重写规则,服务器缓存设置,ssl证书配置,keepalive部署nginx集群,openResty...
【Nginx学习笔记】 Nginx是一款由俄罗斯开发者Igor Sysoev设计的高性能、高并发的Web服务器和反向代理服务器。最初应用于俄罗斯知名网站www.rambler.ru,随后开源,采用类BSD许可,使得全球用户都能使用。Nginx以其...
nginx笔记+资料
Nginx学习笔记1 Nginx是当前使用最广泛的Web服务器之一,它提供了强大的服务器功能和灵活的配置方式。本文档将介绍Nginx的基本概念、安装过程、配置方法和常见问题解决方案。 一、Nginx的基本概念 Nginx是一个...
**Nginx基础概念** ...它的设计目标是高并发、低内存占用以及稳定可靠。Nginx以其事件驱动的异步非阻塞模型在处理静态文件、反向代理、负载均衡等方面...阅读"nginx笔记.pdf",可以更详细地了解Nginx的配置和使用技巧。
**Nginx 知识点详解** Nginx 是一款高性能的 HTTP 服务器,它以其轻量级的内存占用和高并发能力而著名。作为一款反向代理服务器,Nginx 不仅能提供静态文件服务,还能进行动态请求的转发,实现负载均衡,以及隐藏...
### Nginx 学习笔记 #### Nginx 集群与分布式服务架构 在当前互联网技术高速发展的背景下,单台服务器已经无法满足日益增长的业务需求。为了解决这一问题,分布式服务架构应运而生。分布式服务架构通过将服务部署...
以下是关于Nginx安装及配置的详细说明: 首先,你需要从官方或可靠的源下载必要的组件,包括: 1. Nginx:访问http://nginx.org/en/download.html获取最新版本。 2. PCRE库(Perl Compatible Regular Expressions)...
**Nginx简介** ...它以其高并发、低内存消耗以及稳定的工作性能而受到广泛赞誉。... **Nginx安装** ...提供的“nginx笔记+资料”压缩包应该包含了更详细的信息,可以帮助你进一步掌握Nginx的相关知识。
本安装笔记将详细阐述如何在您的服务器环境中安装并配置FastDFS、Nginx和Redis这三款软件,以实现高效的数据存储、访问及缓存功能。 首先,我们来了解FastDFS。FastDFS是一个开源的、高性能的、轻量级的分布式文件...
【Nginx基础与安装】 Nginx 是一款高性能的HTTP和反向代理服务器,广泛应用于网站的负载均衡和静态内容服务。本篇主要讲解如何在CentOS 7.4环境下,通过虚拟机VMware Workstation 16进行Nginx的安装与配置。 首先...