Nginx 安装
Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。基于 Tengine 验证。
搭建步骤
-
安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
或
注意:如果 Linux 没有安装 gcc,会出现如下错误: checking for C compiler ... not found 在 yum 源环境下安装 gcc: yum -y install gcc ./configure: error: the HTTP rewrite module requires the PCRE library. 安装 pcre-devel 解决问题 yum -y install pcre-devel ./configure: error: SSL modules require the OpenSSL library. 安装 openssl 解决问题 yum -y install openssl openssl-devel
-
PCRE安装
PCRE 作用是让 Nginx 支持 Rewrite 功能。- 下载 PCRE 安装包,下载地址:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
或 https://ftp.pcre.org/pub/pcre/ (手动下载)cd /data/tengine wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
- 解压安装包
tar -zxvf pcre-8.35.tar.gz
- 进入安装包目录
cd pcre-8.35
- 安装编译
./configure make && make install
- 查看 pcre 版本
pcre-config --version
- 下载 PCRE 安装包,下载地址:http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
-
解压
tar -zxvf tengine-2.2.0.tar.gz
-
创建安装目录
mkdir -p /data/tengine/tengine
-
编译安装
cd /data/tengine/tengine-2.2.0 # 编译安装 ./configure --prefix=/data/tengine/tengine --with-http_stub_status_module --with-http_ssl_module --with-pcre=/data/tengine/pcre-8.35 make make install
-
Nginx 配置
copy 样本的 nginx.conf 到 /data/tengine/tengine/conf 目录下 # 编辑 nginx.conf vi nginx.conf # 修改几个参数 修改 listen 的监听端口,根据要求修改 修改 proxy_pass http://localhost:48655/,地址为需要的代理的 url 切换到 nginx 的 html 路径下 # 新建文件夹 dashboard mkdir dashboard 复制文件 screenshot.js 到 dashboard 目录下
-
Nginx 启动停止
# 启动代理服务器 cd /data/tengine/tengine/sbin ./nginx # 停止代理服务器 通过端口查找 nginx 进程 ps -ef | grep nginx kill -9 pid