简介:
Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。
1、前期准备
1.1、安装gcc/make等:yum -y install gcc gcc-c++ automake autoconf libtool make
1.2、编译安装pcre库:
1.2.1、在根目录下创建文件夹soft,用于存放下载的安装包:mkdir -p /soft
1.2.2、切换至该目录:cd /soft
1.2.3、下载安装包:wget http://ftp.exim.llorien.org/pcre/pcre-8.40.tar.gz
1.2.4、解压安装包:tar -zvxf pcre-8.40.tar.gz
1.2.5、切换至该目录:cd pcre-8.40
1.2.6、写入配置文件:./configure
1.2.7、编译:make
1.2.8、安装:make install
1.3、编译安装zlib库:
1.3.1、切换至安装包目录:cd /soft
1.3.2、下载安装包:wget http://zlib.net/zlib-1.2.11.tar.gz
1.3.3、解压安装包:tar -zvxf zlib-1.2.11.tar.gz
1.3.4、切换至该目录:cd zlib-1.2.11
1.3.5、写入配置文件:./configure
1.3.6、编译:make
1.3.7、安装:make install
1.4、下载openssl并安装openssl:
1.4.1、切换至安装包目录:cd /soft
1.4.2、下载安装包:wget http://www.openssl.org/source/openssl-1.1.0c.tar.gz
1.4.3、解压安装包:tar -zvxf openssl-1.1.0c.tar.gz,待会配置nginx用到
1.4.4、安装openssl:yum -y install openssl openssl-devel
2、安装tengine(未安装nginx)
2.1、切换至安装包目录:cd /soft
2.2、下载安装包:wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
2.3、解压安装包:tar -zvxf tengine-2.2.0.tar.gz
2.4、切换至该目录:cd tengine-2.2.0
2.5、写入配置文件:
1
2
3
4
5
6
7
8
|
./configure —sbin–path=/usr/local/nginx
—conf–path=/usr/local/nginx/nginx.conf
—pid–path=/usr/local/nginx/nginx.pid
—with–http_ssl_module
—with–http_stub_status_module
—with–pcre=/soft/pcre–8.40
—with–zlib=/soft/zlib–1.2.11
—with–openssl=/soft/openssl–1.1.0c
|
2.6、编译:make
2.7、安装:make install
2.8、启动tengine:/usr/local/nginx/nginx
2.9、检测是否已正确安装:访问服务器对应IP显示Welcome to tengine即安装成功!
3、安装php-fpm
3.1、前期安装一堆类库:
1
2
3
4
5
6
7
|
yum –y install mhash–devel libxslt–devel
libjpeg libjpeg–devel libpng libpng–devel
freetype freetype–devel libxml2 libxml2–devel
zlib zlib–devel glibc glibc–devel glib2 glib2–devel
bzip2 bzip2–devel ncurses ncurses–devel curl curl–devel
e2fsprogs e2fsprogs–devel krb5 krb5–devel libidn
libidn–devel openssl openssl–devel
|
3.2、安装mcrypt:
3.2.1、切换至安装包目录:cd /soft
3.2.2、下载安装包:wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
3.2.3、解压安装包:tar -vxf libmcrypt-2.5.7.tar.gz
3.2.4、切换至该目录:cd libmcrypt-2.5.7
3.2.5、写入配置文件(将mcrypt安装到/usr/local目录下):./configure --prefix=/usr/local
3.2.6、编译:make
3.2.7、安装:make install
3.3、安装php-fpm:
3.3.1、切换至安装包目录:cd /soft
3.3.2、下载安装包:wget http://museum.php.net/php5/php-5.5.38.tar.gz
3.3.3、解压安装包:tar -zvxf php-5.5.38.tar.gz
3.3.4、切换至该目录:cd php-5.5.38
3.3.5、写入配置文件(将php安装到/usr/local/php目录下):
1
2
3
4
5
6
|
./configure —prefix=/usr/local/php —enable–fpm —with–mcrypt
—enable–mbstring —disable–pdo —with–curl —disable–debug
—disable–rpath —enable–inline–optimization —with–bz2 —with–zlib
—enable–sockets —enable–sysvsem —enable–sysvshm —enable–pcntl
—enable–mbregex —with–mhash —enable–zip —with–pcre–regex
—with–mysql —with–mysqli —with–gd —with–jpeg–dir
|
3.3.6、编译:make
3.3.7、安装:make install
3.4、修改nginx配置文件:
3.4.1、修改nginx.conf配置文件:vi /usr/local/nginx/nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
//找到该配置信息
#location ~ .php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /script$fastcgi_script_name;
# include fastcgi_params;
#}
//去掉注释,并将”/script” 改为 “$document_root”
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
|
3.5、配置php-fpm文件:
3.5.1、切换至php目录:cd /usr/local/php/etc
3.5.2、复制一个配置信息:cp php-fpm.conf.default php-fpm.conf
3.6、重启tengine并启动php-fpm:
3.6.1、重启tengine:/usr/local/nginx/nginx -s reload
3.6.2、启动php-fpm:/usr/local/php/sbin/php-fpm
3.7、测试是否安装正确:
3.7.1、编写测试文件:vi /usr/local/nginx/html/index.php
3.7.2、写入:<?php echo phpinfo(); ?>
3.7.3、访问服务器IP/index.php,出现php信息即正确安装
4、安装mysql
4.1、安装:yum install mysql-server
4.2、启动mysql服务:service mysqld start
4.3、开机启动mysql服务:chkconfig mysqld on
4.3.1、查看开机启动的服务:chkconfig –list
4.4、修改mysql密码:
1
2
3
4
|
[root@localhost /]# mysql
[root@localhost /]# mysql> use mysql
[root@localhost /]# mysql> update user set password=password(‘密码’) where user=’root’;
[root@localhost /]# mysql> flush privileges;
|
4.5、设置Mysql远程访问:
1
|
[root@localhost /]# grant all privileges on *.* to ‘root’@’%’ identified by ‘密码’ with grant option;
|
4.6、好了,可以通过Navicat等工具链接了
5、为tengine(同nginx)和php-fpm添加系统服务
5.1、添加nginx系统服务 | 添加php-fpm系统服务
6、结束语
6.1、本文有任何错误,或有任何疑问,欢迎留言说明。
编译tengine 报错 openssl
src/event/ngx_event_openssl.c:2872: error: ‘RAND_pseudo_bytes’ is deprecated (declared at /opt/soft/openssl-1.1.0c/.openssl/include/openssl/rand.h:47)
cc1: warnings being treated as errors
src/event/ngx_event_openssl_stapling.c: In function ‘ngx_ssl_stapling_issuer’:
src/event/ngx_event_openssl_stapling.c:284: error: implicit declaration of function ‘CRYPTO_add’
src/event/ngx_event_openssl_stapling.c:284: error: dereferencing pointer to incomplete type
src/event/ngx_event_openssl_stapling.c:284: error: ‘CRYPTO_LOCK_X509’ undeclared (first use in this function)
src/event/ngx_event_openssl_stapling.c:284: error: (Each undeclared identifier is reported only once
src/event/ngx_event_openssl_stapling.c:284: error: for each function it appears in.)
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
make[1]: *** Waiting for unfinished jobs….
make[1]: *** [objs/src/event/ngx_event_openssl_stapling.o] Error 1
make[1]: Leaving directory `/opt/soft/tengine-2.2.0′
make: *** [build] Error 2