CentOS 7.2编译安装Tengine_ALLBET技术分享博客

CentOS 7.2编译安装Tengine

2022-11-12 18:04:14  浏览:526  作者:YAXIN
CentOS需使用7.*版本, 8.*版本因 OPENSSL_TLS_SECURITY_LEVEL=2 的问题暂没有很好的解决办法;配置firewalld,iptables,关闭SELINUXsystemctl disable firewalld1、安...

CentOS需使用7.*版本, 8.*版本因 OPENSSL_TLS_SECURITY_LEVEL=2 的问题暂没有很好的解决办法;

配置firewalld,iptables,关闭SELINUXsystemctl disable firewalld

1、安装必要的编译环境好

由于Tengine安装需要使用源代码自行编译,所以在安装前需要安装必要的编译工具:

yum -y updateyum-y install gcc gcc-c++bzip2perlcurl curl-devel expat-devel gettext-devel libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel autoconf openssl openssl-develyum -y install epel-release //扩展包更新包yum -y update//更新yum源yum -y install libmcrypt libmcrypt-devel mcrypt mhash###wget下载必要软件cd /mnt/wgetwget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz wget http://zlib.net/zlib-1.2.11.tar.gzwget https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2wget https://www.openssl.org/source/openssl-1.1.1g.tar.gzwget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz

2、安装需要的组件

A、PCRE

PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx rewrite依赖于PCRE库,所以在安装Tengine前一定要先安装PCRE

cd /mnt/wget&& tar zxvf pcre-8.43.tar.gz && cd pcre-8.43 && ./configure --prefix=/usr/local/pcre && make && make install

B、Zlib

Zlib是提供资料压缩之用的函式库,当Tengine想启用GZIP压缩的时候就需要使用到Zlib(http://www.zlib.net/)。

cd /mnt/wget&& tar zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && ./configure --prefix=/usr/local/zlib && make && make install

C、jemalloc

jemalloc(https://github.com/jemalloc/jemalloc/releases/)是一个更好的内存管理工具,使用jemalloc可以更好的优化Tengine的内存管理。

cd /mnt/wget && tar xvf jemalloc-5.2.1.tar.bz2 && cd jemalloc-5.2.1 && ./configure --prefix=/usr/local/jemalloc && make && make install

D、OpenSSL

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。,安装OpenSSL(http://www.openssl.org/source/)主要是为了让tengine支持Https的访问请求。

cd /mnt/wget && tar zxvf openssl-1.1.1g.tar.gz && cd openssl-1.1.1g && ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl --libdir=lib shared zlib-dynamic -Wl,-R,'$(LIBRPATH)' -Wl,--enable-new-dtags && make && make install(如果之前安装过,请执行 make distclean )cp /etc/pki/tls/cert.pem /usr/local/openssl/cert.pem使用新版OpenSSLmv /usr/bin/openssl /usr/bin/openssl.bakmv /usr/include/openssl /usr/include/openssl.bakln -s /usr/local/openssl/bin/openssl /usr/bin/opensslln -s /usr/local/openssl/include/openssl /usr/include/opensslln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

3、安装Tengine

在主要核心的组件安装完毕以后就可以安装Tegine了,最新版本的Tegine可从官网(http://tengine.taobao.org/)获取。在编译安装前还需要做的一件事是添加一个专门的用户来执行Tengine。当然你也可以用root(不建议)。

groupadd www && useradd -s /sbin/nologin -g www www

接下来才是进行安装:

cd /mnt/wget && tar -zxvf tengine-2.3.3.tar.gz && cd tengine-2.3.3./configure --prefix=/usr/local/nginx \--user=www \--group=www \--with-pcre=/mnt/wget/pcre-8.43 \--with-openssl=/mnt/wget/openssl-1.1.1g \--with-jemalloc=/mnt/wget/jemalloc-5.2.1 \--with-zlib=/mnt/wget/zlib-1.2.11 \--with-http_gzip_static_module \--with-http_realip_module \--with-http_stub_status_module \--with-http_ssl_module \--with-http_v2_modulemake && make install

注意配置的时候 –with-pcre 、–with-openssl、–with-jemalloc、–with-zlib的路径为源文件的路径。

4、配置Tengine,设置tengine自动启动

系统用户登录系统后启动的服务 的目录 /usr/lib/systemd/system如需要开机没有登陆情况下就能运行的程序在系统目录内/lib/systemd/system

我希望系统开机就启动目录,所以我把文件放在系统目录内。

cd /lib/systemd/systemvi nginx.service

[Unit]Description=The nginx HTTP and reverse proxy serverAfter=syslog.target network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -tExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target

修改文件权限 chmod 745 nginx.service 设置为开机启动 systemctl enable nginx.service启动nginx服务 systemctl start nginx.service设置开机自启动 systemctl enable nginx.service停止开机自启动 systemctl disable nginx.service查看服务当前状态 systemctl status nginx.service重新启动服务 systemctl restart nginx.service查看所有已启动的服务 systemctl list-units --type=service

打开nscd服务,缓存dns,提高RDS响应systemctl start nscd.servicesystemctl enable nscd.service

vi /etc/hosts //注释掉下面一行#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6echo 'export OPENSSL_ROOT_DIR=/usr/local/opensslexport OPENSSL_LIBRARIES=/usr/local/openssl/libexport OPENSSL_CFLAGS=/usr/local/openssl/lib/pkgconfigexport OPENSSL_LIBS=/usr/local/openssl/libexport OPENSSL_INCLUDE_DIR=/usr/local/openssl/includeexport OPENSSL_SSL_LIBRARIES=/usr/local/openssl/lib/libssl.soexport OPENSSL_CRYPTO_LIBRARIES=/usr/local/openssl/lib/libcrypto.soPATH=$PATH:/usr/local/openssl/bin:/usr/local/php7/bin:/usr/local/mysql/libunset MAILCHECK' >> /etc/profileecho 'include ld.so.conf.d/*.conf/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64/usr/local/openssl/lib/usr/local/mysql/lib' > /etc/ld.so.conf && ldconfig

姊妹篇:

编译安装PHP7: https://www.cnblogs.com/doseoer/p/5350944.html编译安装PHP8: https://www.cnblogs.com/doseoer/p/14050037.html编译安装Redis6:https://www.cnblogs.com/doseoer/p/9975022.html编译安装MySQL5.7.25:https://www.cnblogs.com/doseoer/p/13995204.html

日志:

Tengine-Nginx: /usr/local/nginx/logs/error.log notice;PHP-fpm: /var/log/php-fpm/error.logPHP: /var/log/php/php-error.log

评论区

共 0 条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

【随机内容】

返回顶部