华域联盟 PHP Aliyun Linux 编译安装 php7.3 tengine2.3.2 mysql8.0 redis5的过程详解

Aliyun Linux 编译安装 php7.3 tengine2.3.2 mysql8.0 redis5的过程详解

目录

介绍

之前写过 CentOS 安装 PHP,MySQL,Nginx 的相关文章,具体介绍这里就不写了,直接上操作步骤.

安装 Tengine

1. 安装必要的编译环境

yum update
yum install gcc gcc-c++ autoconf automake

2. 安装需要的组件 PCRE

PCRE(Perl Compatible Regular Expressions) http://www.pcre.org 是一个Perl库,包括 perl 兼容的正则表达式库。nginx rewrite依赖于PCRE库,所以在安装Tengine前一定要先安装PCRE,最新版本的PCRE可在官网获取。具体安装流程为:

cd /usr/local/src
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar zxvf pcre-8.43.tar.gz
cd pcre-8.43
./configure --prefix=/usr/local/pcre
make && make install

OpenSSL

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

cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.2s.tar.gz
tar zxvf openssl-1.0.2s.tar.gz
cd openssl-1.0.2s
./config --prefix=/usr/local/openssl
make && make install

Zlib

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

cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install

jemalloc

jemalloc http://www.canonware.com/jemalloc 是一个更好的内存管理工具,使用jemalloc可以更好的优化Tengine的内存管理。安装流程为:

cd /usr/local/src
wget https://src.fedoraproject.org/lookaside/pkgs/jemalloc/jemalloc-5.2.1.tar.bz2/sha512/0bbb77564d767cef0c6fe1b97b705d368ddb360d55596945aea8c3ba5889fbce10479d85ad492c91d987caacdbbdccc706aa3688e321460069f00c05814fae02/jemalloc-5.2.1.tar.bz2
tar jxvf jemalloc-5.2.1.tar.bz2
cd jemalloc-5.2.1
./configure --prefix=/usr/local/jemalloc
make && make install

3. 安装Tengine

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

添加用户及用户组:

# 添加www组
groupadd -r www
# 创建www运行账户nginx并加入到www组,不允许www用户直接登录系统
useradd -s /sbin/nologin -g www -r www

编译安装Tengine TODO

cd /usr/local/src
wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
tar -zxvf tengine-2.2.0.tar.gz
cd tengine-2.2.0
./configure --prefix=/usr/local/nginx \
--user=www \
--group=www \
--with-pcre=/usr/local/src/pcre-8.40 \
--with-openssl=/usr/local/src/openssl-1.0.2 \
--with-jemalloc=/usr/local/src/jemalloc-3.6.0 \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_concat_module \
--with-zlib=/usr/local/src/zlib-1.2.11
make && make install

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

4. CentOS 7 配置Tengine,设置tengine开机自启

# 系统用户登录系统后启动的服务的目录
/usr/lib/systemd/system
# 如需要开机没有登陆情况下就能运行的程序在系统目录内
/usr/lib/systemd/system
# 我希望系统开机就启动目录,所以我把文件放在系统目录内。
vim /lib/systemd/system/nginx.service

[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=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

编辑Tengine操作脚本

vi /etc/rc.d/init.d/nginx #编辑启动文件添加下面内容
############################################################
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: NGINX is an HTTP(S) server, HTTP(S) reverse \
#  proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /usr/local/nginx/logs/nginx.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

make_dirs() {
 # make required directories
 user=`$nginx -V 2>&1 | grep "configure arguments:.*--user=" | sed 's/[^*]*--user=\([^ ]*\).*//g' -`
 if [ -n "$user" ]; then
 if [ -z "`grep $user /etc/passwd`" ]; then
  useradd -M -s /bin/nologin $user
 fi
 options=`$nginx -V 2>&1 | grep 'configure arguments:'`
 for opt in $options; do
  if [ `echo $opt | grep '.*-temp-path'` ]; then
  value=`echo $opt | cut -d "=" -f 2`
  if [ ! -d "$value" ]; then
   # echo "creating" $value
   mkdir -p $value && chown -R $user $value
  fi
  fi
 done
 fi
}

start() {
 [ -x $nginx ] || exit 5
 [ -f $NGINX_CONF_FILE ] || exit 6
 make_dirs
 echo -n $"Starting $prog: "
 daemon $nginx -c $NGINX_CONF_FILE
 retval=$?
 echo
 [ $retval -eq 0 ] && touch $lockfile
 return $retval
}

stop() {
 echo -n $"Stopping $prog: "
 killproc $prog -QUIT
 retval=$?
 echo
 [ $retval -eq 0 ] && rm -f $lockfile
 return $retval
}

restart() {
 configtest || return $?
 stop
 sleep 1
 start
}

reload() {
 configtest || return $?
 echo -n $"Reloading $prog: "
 killproc $nginx -HUP
 RETVAL=$?
 echo
}

force_reload() {
 restart
}

configtest() {
 $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
 status $prog
}

rh_status_q() {
 rh_status >/dev/null 2>&1
}

case "$1" in
 start)
 rh_status_q && exit 0
 $1
 ;;
 stop)
 rh_status_q || exit 0
 $1
 ;;
 restart|configtest)
 $1
 ;;
 reload)
 rh_status_q || exit 7
 $1
 ;;
 force-reload)
 force_reload
 ;;
 status)
 rh_status
 ;;
 condrestart|try-restart)
 rh_status_q || exit 0
  ;;
 *)
 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
 exit 2
esac
############################################################

配置权限及开机启动

chmod 745 /etc/rc.d/init.d/nginx # 设置权限
chkconfig nginx on # 开机启动

操作指令

# 开启服务
/etc/init.d/nginx start
# 重启服务
/etc/init.d/nginx restart
# 停止服务
/etc/init.d/nginx stop
# 查看服务状态
/etc/init.d/nginx status

到此这篇关于Aliyun Linux 编译安装 php7.3 tengine2.3.2 mysql8.0 redis5的文章就介绍到这了,更多相关Linux 编译安装 php7.3内容请搜索华域联盟以前的文章或继续浏览下面的相关文章希望大家以后多多支持华域联盟!

您可能感兴趣的文章:

本文由 华域联盟 原创撰写:华域联盟 » Aliyun Linux 编译安装 php7.3 tengine2.3.2 mysql8.0 redis5的过程详解

转载请保留出处和原文链接:https://www.cnhackhy.com/75099.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部