Aliyun Linux 編譯安裝 php7.3 tengine2.3.2 mysql8.0 redis5的過程詳解
之前寫過 CentOS 安裝 PHP,MySQL,Nginx 的相關文章,具體介紹這里就不寫了,直接上操作步驟.
安裝 Tengine1. 安裝必要的編譯環境yum updateyum install gcc gcc-c++ autoconf automake2. 安裝需要的組件 PCRE
PCRE(Perl Compatible Regular Expressions) http://www.pcre.org 是一個Perl庫,包括 perl 兼容的正則表達式庫。nginx rewrite依賴于PCRE庫,所以在安裝Tengine前一定要先安裝PCRE,最新版本的PCRE可在官網獲取。具體安裝流程為:
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 是一個強大的安全套接字層密碼庫,囊括主要的密碼算法、常用的密鑰和證書封裝管理功能及SSL協議,并提供豐富的應用程序供測試或其它目的使用。安裝OpenSSL 主要是為了讓tengine支持Https的訪問請求。具體是否安裝看需求。安裝流程為:
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 是提供資料壓縮之用的函式庫,當Tengine想啟用GZIP壓縮的時候就需要使用到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 是一個更好的內存管理工具,使用jemalloc可以更好的優化Tengine的內存管理。安裝流程為:
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可從官網 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/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
注意配置的時候 ?with-pcre 、?with-openssl、?with-jemalloc、?with-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 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
編輯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 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############################################################
配置權限及開機啟動
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內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章: