Aliyun Linux 編譯安裝 php7.3 tengine2.3.2 mysql8.0 redis5的過(guò)程詳解
之前寫(xiě)過(guò) CentOS 安裝 PHP,MySQL,Nginx 的相關(guān)文章,具體介紹這里就不寫(xiě)了,直接上操作步驟.
安裝 Tengine1. 安裝必要的編譯環(huán)境yum updateyum install gcc gcc-c++ autoconf automake2. 安裝需要的組件 PCRE
PCRE(Perl Compatible Regular Expressions) http://www.pcre.org 是一個(gè)Perl庫(kù),包括 perl 兼容的正則表達(dá)式庫(kù)。nginx rewrite依賴(lài)于PCRE庫(kù),所以在安裝Tengine前一定要先安裝PCRE,最新版本的PCRE可在官網(wǎng)獲取。具體安裝流程為:
cd /usr/local/srcwget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gztar zxvf pcre-8.43.tar.gzcd pcre-8.43./configure --prefix=/usr/local/pcremake && make install
OpenSSL
OpenSSL http://www.openssl.org/source 是一個(gè)強(qiáng)大的安全套接字層密碼庫(kù),囊括主要的密碼算法、常用的密鑰和證書(shū)封裝管理功能及SSL協(xié)議,并提供豐富的應(yīng)用程序供測(cè)試或其它目的使用。安裝OpenSSL 主要是為了讓tengine支持Https的訪問(wèn)請(qǐng)求。具體是否安裝看需求。安裝流程為:
cd /usr/local/srcwget http://www.openssl.org/source/openssl-1.0.2s.tar.gztar zxvf openssl-1.0.2s.tar.gzcd openssl-1.0.2s./config --prefix=/usr/local/opensslmake && make install
Zlib
Zlib http://www.zlib.net 是提供資料壓縮之用的函式庫(kù),當(dāng)Tengine想啟用GZIP壓縮的時(shí)候就需要使用到Zli。安裝流程為:
cd /usr/local/srcwget http://zlib.net/zlib-1.2.11.tar.gztar zxvf zlib-1.2.11.tar.gzcd zlib-1.2.11./configure --prefix=/usr/local/zlibmake && make install
jemalloc
jemalloc http://www.canonware.com/jemalloc 是一個(gè)更好的內(nèi)存管理工具,使用jemalloc可以更好的優(yōu)化Tengine的內(nèi)存管理。安裝流程為:
cd /usr/local/srcwget https://src.fedoraproject.org/lookaside/pkgs/jemalloc/jemalloc-5.2.1.tar.bz2/sha512/0bbb77564d767cef0c6fe1b97b705d368ddb360d55596945aea8c3ba5889fbce10479d85ad492c91d987caacdbbdccc706aa3688e321460069f00c05814fae02/jemalloc-5.2.1.tar.bz2tar jxvf jemalloc-5.2.1.tar.bz2cd jemalloc-5.2.1./configure --prefix=/usr/local/jemallocmake && make install3. 安裝Tengine
在主要核心的組件安裝完畢以后就可以安裝Tegine了,最新版本的Tegine可從官網(wǎng) http://tengine.taobao.org 獲取。在編譯安裝前還需要做的一件事是添加一個(gè)專(zhuān)門(mén)的用戶來(lái)執(zhí)行Tengine。當(dāng)然你也可以用root(不建議)。
添加用戶及用戶組:
# 添加www組groupadd -r www# 創(chuàng)建www運(yùn)行賬戶nginx并加入到www組,不允許www用戶直接登錄系統(tǒng)useradd -s /sbin/nologin -g www -r www
編譯安裝Tengine TODO
cd /usr/local/srcwget http://tengine.taobao.org/download/tengine-2.2.0.tar.gztar -zxvf tengine-2.2.0.tar.gzcd 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.11make && make install
注意配置的時(shí)候 ?with-pcre 、?with-openssl、?with-jemalloc、?with-zlib的路徑為源文件的路徑。
4. CentOS 7 配置Tengine,設(shè)置tengine開(kāi)機(jī)自啟# 系統(tǒng)用戶登錄系統(tǒng)后啟動(dòng)的服務(wù)的目錄/usr/lib/systemd/system# 如需要開(kāi)機(jī)沒(méi)有登陸情況下就能運(yùn)行的程序在系統(tǒng)目錄內(nèi)/usr/lib/systemd/system# 我希望系統(tǒng)開(kāi)機(jī)就啟動(dòng)目錄,所以我把文件放在系統(tǒng)目錄內(nèi)。vim /lib/systemd/system/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
# 修改文件權(quán)限chmod 745 nginx.service# 設(shè)置為開(kāi)機(jī)啟動(dòng)systemctl enable nginx.service# 其它命令# 啟動(dòng)nginx服務(wù)systemctl start nginx.service# 設(shè)置開(kāi)機(jī)自啟動(dòng)systemctl enable nginx.service# 停止開(kāi)機(jī)自啟動(dòng)systemctl disable nginx.service# 查看服務(wù)當(dāng)前狀態(tài)systemctl status nginx.service# 重新啟動(dòng)服務(wù)systemctl restart nginx.service# 查看所有已啟動(dòng)的服務(wù)systemctl list-units --type=service
編輯Tengine操作腳本
vi /etc/rc.d/init.d/nginx #編輯啟動(dòng)文件添加下面內(nèi)容
#############################################################!/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 0nginx='/usr/local/nginx/sbin/nginx'prog=$(basename $nginx)NGINX_CONF_FILE='/usr/local/nginx/conf/nginx.conf'[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginxlockfile=/var/lock/subsys/nginxmake_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 2esac############################################################
配置權(quán)限及開(kāi)機(jī)啟動(dòng)
chmod 745 /etc/rc.d/init.d/nginx # 設(shè)置權(quán)限chkconfig nginx on # 開(kāi)機(jī)啟動(dòng)
操作指令
# 開(kāi)啟服務(wù)/etc/init.d/nginx start# 重啟服務(wù)/etc/init.d/nginx restart# 停止服務(wù)/etc/init.d/nginx stop# 查看服務(wù)狀態(tài)/etc/init.d/nginx status
到此這篇關(guān)于Aliyun Linux 編譯安裝 php7.3 tengine2.3.2 mysql8.0 redis5的文章就介紹到這了,更多相關(guān)Linux 編譯安裝 php7.3內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. xml中的空格之完全解說(shuō)2. asp讀取xml文件和記數(shù)3. IE6/IE7/IE8/IE9中tbody的innerHTML不能賦值的完美解決方案4. 利用CSS制作3D動(dòng)畫(huà)5. jsp+servlet簡(jiǎn)單實(shí)現(xiàn)上傳文件功能(保存目錄改進(jìn))6. 匹配模式 - XSL教程 - 47. WML語(yǔ)言的基本情況8. 小技巧處理div內(nèi)容溢出9. jsp cookie+session實(shí)現(xiàn)簡(jiǎn)易自動(dòng)登錄10. xpath簡(jiǎn)介_(kāi)動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
