[LTMP搭建] Centos 6.5 安装配置 Tengine
2014-05-29 18:29
381 查看
接上篇:/article/5751689.html (安装PHP)
一. 安装依赖的扩展
记得前几天编译tengine,不使用 --with-http_lua_module , 也就不需要以下1》、2》、3》 的 lua部分了。
1》 Lua library(Tengine的lua扩展需要),
2》 scrons。 这个只是此处编译tolua++需要才安装
一. 安装依赖的扩展
记得前几天编译tengine,不使用 --with-http_lua_module , 也就不需要以下1》、2》、3》 的 lua部分了。
1》 Lua library(Tengine的lua扩展需要),
[root@localhost src]# yum install readline-devel [root@localhost src]# wget -c http://www.lua.org/ftp/lua-5.1.5.tar.gz [root@localhost src]# tar -zxvf lua-5.1.5.tar.gz [root@localhost src]# cd lua-5.1.5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // 如果是64位系统,到 lua-x.x.x/src/Makefile增加 -fPIC ,否则后面可能会出现(本文错误6) ‘relocation R_X86_64_32 against `luaO_nilobject_' # vim src/Makefile CFLAGS= -fPIC -O2 -Wall $(MYCFLAGS)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@localhost lua-5.1.5]# make linux && make install
2》 scrons。 这个只是此处编译tolua++需要才安装
[root@localhost src]# rpm -ivh http://jaist.dl.sourceforge.net/project/scons/scons/2.3.1/scons-2.3.1-1.noarch.rpm[/code]
3》 tolua++[root@localhost src]# wget -c http://www.codenix.com/~tolua/tolua++-1.0.93.tar.bz2 [root@localhost src]# tar -jvxf tolua++-1.0.93.tar.bz2 [root@localhost src]# cd tolua++-1.0.93[root@localhost tolua++-1.0.93]# vim config_linux.py // 将 LIBS = ['lua50', 'lualib50', 'dl', 'm'] // 改为LIBS = ['lua', 'dl', 'm']
[root@localhost tolua++-1.0.93]# scons all
[root@localhost tolua++-1.0.93]# scons install
lua系列安装完毕,查看
[root@localhost src]# lua -v
[root@localhost src]# tolua++ -v
4》GD (http_image_filter_module 需要). 带过
二. 编译tengine。
此处附带选项比较多,中途出错误终止可能性大,很折腾。
./configure --prefix=/usr/local/tengine
--lock-path=/var/lock/nginx.lock
--pid-path=/var/run/nginx.pid
--error-log-path=/var/logs/nginx/error.log
--http-log-path=/var/logs/nginx/access.log
--user=www
--group=www
--with-pcre=/usr/local/src/pcre-8.35 ## 这里指定的是PCRE的解压目录,不是安装目录,否则报错
--with-pcre-opt=-fPIC
--with-openssl=/usr/local/src/openssl-1.0.1i ## 解压后的源文件目录
--with-openssl-opt=-fPIC
--with-md5=/usr/lib ## openssl 依赖md5
--with-backtrace_module
--with-http_stub_status_module
--with-http_gzip_static_module
--with-http_realip_module
--with-http_concat_module=shared
--with-http_sysguard_module=shared
--with-http_limit_conn_module=shared
--with-http_limit_req_module=shared
--with-http_split_clients_module=shared
--with-http_footer_filter_module=shared
// --with-http_geoip_module=shared ## geoip,可不用
--with-http_sub_module=shared
--with-http_access_module=shared
--with-http_upstream_ip_hash_module=shared
--with-http_upstream_least_conn_module=shared
--with-http_referer_module=shared
--with-http_rewrite_module=shared
--with-http_memcached_module=shared
--with-http_upstream_session_sticky_module=shared
--with-http_addition_module=shared
// --with-http_image_filter_module=shared
--with-http_user_agent_module=shared
--with-http_empty_gif_module=shared
--with-http_browser_module=shared
// --with-google_perftools_module ## google 的分析C/C++软件内存和CPU使用(tcmalloc,CPU)的工具, 非常规项
--with-http_map_module=shared
--with-http_userid_filter_module=shared
--with-http_charset_filter_module=shared
--with-http_trim_filter_module=shared
--with-http_lua_module=shared
// --without-http_fastcgi_module
// --without-http_uwsgi_module
// --without-http_scgi_module
// --without-select_module
// --without-poll_module
// --add-module=../nginx-hmux-module-1.3
// --add-module=../nginx_tcp_proxy_module-0.4.5
// --with-ld-opt='-ltcmalloc_minimal'
// --http-client-body-temp-path=/data/nginx_temp/nginx_client
// --http-proxy-temp-path=/data/nginx_temp/nginx_proxy
// --http-fastcgi-temp-path=/data/nginx_temp/nginx_fastcgi
合并:./configure --prefix=/usr/local/tengine --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --error-log-path=/var/logs/nginx/error.log --http-log-path=/var/logs/nginx/access.log --user=www --group=www --with-pcre=/usr/local/src/pcre-8.35 --with-pcre-opt=-fPIC --with-openssl=/usr/local/src/openssl-1.0.1i --with-openssl-opt=-fPIC --with-md5=/usr/lib --with-backtrace_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-http_limit_conn_module=shared --with-http_limit_req_module=shared --with-http_split_clients_module=shared --with-http_footer_filter_module=shared --with-http_sub_module=shared --with-http_access_module=shared --with-http_upstream_ip_hash_module=shared --with-http_upstream_least_conn_module=shared --with-http_referer_module=shared --with-http_rewrite_module=shared --with-http_memcached_module=shared --with-http_upstream_session_sticky_module=shared --with-http_addition_module=shared --with-http_user_agent_module=shared --with-http_empty_gif_module=shared --with-http_browser_module=shared --with-http_map_module=shared --with-http_userid_filter_module=shared --with-http_charset_filter_module=shared --with-http_trim_filter_module=shared --with-http_lua_module=shared
最好先# make test, 这中间可能会有提示错误
make && make install
# /usr/local/tengine/sbin/nginx -c /usr/local/tengine/conf/nginx.conf ## 指定conf的位置
如果此时还没有编译时指定的user和group,创建[root@localhost src]# groupadd www [root@localhost src]# useradd -s -M /sbin/nologin -g www www
如果能运行 /usr/local/sbin/nginx -v, 看到版本模块信息, 说明已安装成功。
三、报错及解决方法
1. PCRE dir指定错误。 我在指定 --with-pcre=shared时同样出现如下错误,改为 PCRE 解压编译时的原目录就好了[root@localhost tengine-2.0.3]# make test make -f objs/Makefile test make[1]: Entering directory `/usr/local/src/tengine-2.0.3' cd shared \ && if [ -f Makefile ]; then make distclean; fi \ && CC="gcc" CFLAGS="-fPIC -pipe" \ ./configure --disable-shared /bin/sh: line 0: cd: shared: No such file or directory make[1]: *** [shared/Makefile] Error 1 make[1]: Leaving directory `/usr/local/src/tengine-2.0.3' make: *** [test] Error 2
2. 需要 C++ compiler。 可能由于卸载某些软件时一同卸载了。configure: error: You need a C++ compiler for C++ support. make[1]: *** [/usr/local/src/pcre-8.35/Makefile] Error 1 make[1]: Leaving directory `/usr/local/src/tengine-2.0.3' make: *** [test] Error 2
运行 yum install -y gcc gcc-c++
3. 这是因为,openssl的路径指定错误, 同pcre一样,--with-openssl 不是安装目录而是解压后的源文件目录。make[2]: Entering directory `/usr/local/openssl' make[2]: *** No rule to make target `clean'. Stop. make[2]: Leaving directory `/usr/local/openssl' make[1]: *** [/usr/local/openssl/.openssl/include/openssl/ssl.h] Error 2 make[1]: Leaving directory `/usr/local/src/tengine-2.0.3' make: *** [test] Error 2
4. 这个问题,百度google必应都找不到 关于 prove 的了。
只有github上有说TEST_NGINX_BINARY=/path/to/nginx/sbin/nginx prove cases TEST_NGINX_BINARY=/path/to/nginx/sbin/nginx prove nginx-tests/bin/sh: prove: command not found make[1]: *** [test] Error 127 make[1]: Leaving directory `/usr/local/src/tengine-2.0.3' make: *** [test] Error 2
^^ 再次编译时已经找到解决方法了, command not found 一般有两种情况:
1. 该程序已安装但是命令并未这 # echo $PATH 这些路径中, 这种加软链接可以解决。
2. 带该命令的程序并未安装,麻烦就在于不知道由什么程序提供, 不过可以用此方法(也可能你的软件库没有该程序):
# yum provides *bin/prove // 这里 'prove' 就是刚刚缺少的command,
// 找到结果是 perl-Test-Harness.xxx
# yum install perl-Test-Harness
5. 搜了很久, 最新版Tolua++ 1.0.93 暂不支持Lua 5.2.xsrc/http/modules/lua/ngx_http_lua_log.c:81: error: ‘LUA_GLOBALSINDEX’ undeclared (first use in this function) make[1]: *** [objs/src/http/modules/lua/ngx_http_lua_log.o] Error 1
6. 这个据说是64位下可能有的错误。/usr/bin/ld: /usr/local/lib/liblua.a(lapi.o): relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/liblua.a: could not read symbols: Bad value
见编译lua步骤说明,64bit系统可能出现的这个问题。
7. 查看 version时, 提示 libssl.so.1.0.0 找不到。此时nginx也无法启动。[root@localhost tengine]# /usr/local/tengine/sbin/nginx -V sbin/nginx: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
ldd 查看 ,为 not found[root@localhost tengine]# ldd sbin/nginx linux-gate.so.1 => (0x00880000) libpthread.so.0 => /lib/libpthread.so.0 (0x00f05000) libdl.so.2 => /lib/libdl.so.2 (0x001ef000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x00a0b000) libpcre.so.0 => /lib/libpcre.so.0 (0x00c21000) libssl.so.1.0.0 => not found libcrypto.so.1.0.0 => not found libz.so.1 => /lib/libz.so.1 (0x001f4000) libc.so.6 => /lib/libc.so.6 (0x00208000) /lib/ld-linux.so.2 (0x00d5b000) libfreebl3.so => /lib/libfreebl3.so (0x00748000)
这时在 /etc/ld.so.conf.d/ 新建一个.conf 的文件,内容为 libssl 的位置:[root@localhost tengine]# cd /etc/ld.so.conf.d[root@localhostld.so.conf.d]# touch www-libs.conf // *.conf 自动载入[root@localhostld.so.conf.d]# echo '/usr/local/lib' > www-libs.conf // 注:/usr/local/lib 为我 libssl.so.1.0.0 的位置[root@localhostld.so.conf.d]# ldconfig
现在可以看到 nginx的版本及模块信息了
四、 辅助设置
设置开机启动。
先创建nginx启动脚本。
# vim /etc/init.d/nginx
然后修改(红色部分)并粘贴, 保存退出。 (这是copy来的内容)#!/bin/bash # Tengine Startup script# processname: nginx # chkconfig: - 85 15 # description: nginx is a World Wide Web server. It is used to serve # pidfile: /var/run/nginx.pid # config: /usr/local/tengine/conf/nginx.conf nginxd=/usr/local/tengine/sbin/nginx nginx_config=/usr/local/tengine/conf/nginx.conf nginx_pid=/var/run/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "tengine is already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid } reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL
# chmod 775 /etc/rc.d/init.d/nginx
# chkconfig --level 2345 nginx on
如果启动失败,错误提示如:
nginx: [emerg] unknown directive "deny" in ...
这一般是未载入带该directive的module(见官方module页)。 nginx所有的module目前必须编译时选择, 幸好tengine可以动态载入nginx.conf dso { load ngx_http_fastcgi_module.so; load ngx_http_rewrite_module.so; load ngx_http_access_module; ## 'deny', 'allow' 就属于这个module } http { ...... }
错误提示如:
nginx: [emerg] unknown "fastcgi_https" variable ...
这一般是 server 配置中使用了未定义的变量 $fastcgi_https , 使用正确的变量或自定义即可。
配置nginx.conf,使用和 php-fpm 相同的 user 和 group, use epoll ,不出意外nginx已经能够运行php了。
相关文章推荐
- 3、单机运行环境搭建之 --CentOS-6.5安装配置Tengine
- 单机运行环境搭建之 --CentOS-6.5安装配置Tengine
- 3、单机运行环境搭建之 --CentOS-6.5安装配置Tengine
- [LTMP搭建] Centos 6.5 安装配置 PHP
- 2、单机运行环境搭建之 --CentOS-6.5安装配置Tomcat7
- CentOS-6.5安装配置Tengine
- Centos6.5服务器环境搭建之安装Nginx以及Https访问方式的配置
- CentOs6.5配置LTMP服务(Tengine,php,mysql)
- CentOS-6.5安装配置Tengine
- [LTMP搭建] CentOS 6.5 编译安装lnmp的准备工作
- 环境搭建系列-系统安装之centos 6.5安装与配置
- 2、单机运行环境搭建之 --CentOS-6.5安装配置Tomcat8
- 1、单机运行环境搭建之 --CentOS-6.5安装配置JDK-8
- [LTMP搭建] Centos 6.5 安装 Mysql
- CentOS-6.5安装配置Tengine
- Centos6.5服务器环境搭建之安装Tomcat以及开机自启动的配置
- 1、单机运行环境搭建之 --CentOS-6.5安装配置JDK-7
- CentOS 6.5系统中安装配置MySQL数据库
- CentOS 6.5 yum安装配置lnmp服务器(Nginx+PHP+MySQL)
- CentOS6.5安装Darwin Streaming Server搭建RTSP流媒体服务器