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

吾爱主题 阅读:115 2021-10-27 14:43:00 评论:0

介绍

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

安装 Tengine

1. 安装必要的编译环境

?
1 2 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可在官网获取。具体安装流程为:

?
1 2 3 4 5 6 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的访问请求。具体是否安装看需求。安装流程为:

?
1 2 3 4 5 6 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。安装流程为:

?
1 2 3 4 5 6 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的内存管理。安装流程为:

?
1 2 3 4 5 6 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(不建议)。

添加用户及用户组:

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

编译安装Tengine TODO

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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

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

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

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 # 系统用户登录系统后启动的服务的目录 /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
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 # 修改文件权限 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操作脚本

?
1 vi /etc/rc .d /init .d /nginx #编辑启动文件添加下面内容
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ############################################################ #!/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=\([^ ]*\).*/\1/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 ############################################################

配置权限及开机启动

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

操作指令

?
1 2 3 4 5 6 7 8 # 开启服务 /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内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/hxciwangbiao/article/details/109174706

可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

【腾讯云】云服务器产品特惠热卖中
搜索
标签列表
    关注我们

    了解等多精彩内容