日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

tengine php fpm,FPM打包工具制作Tengine为RPM包详解

發布時間:2024/3/26 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tengine php fpm,FPM打包工具制作Tengine为RPM包详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

1、Tengine編譯安裝

2、FPM制作Tengine為RPM包

3、總結

1、Tengine編譯安裝[root@php?~]#?cat?/etc/issue

CentOS?release?6.4?(Final)

[root@php?~]#?uname?-r

2.6.32-358.el6.x86_64

請確保系統安裝了"Development tools"和”Server Platform Development”兩個開發包組,如果沒有安裝請用yum工具安裝即可。

所需要的軟件包:[root@php?tengine]#?pwd

/root/software/tengine

[root@php?tengine]#?ls

jemalloc-3.6.0.tar.bz2????pcre-8.33.zip??tengine-2.1.0.tar.gz

jemalloc-3.6.0.tar.bz2

pcre-8.33.zip

PCRE(Perl

Compatible Regular Expressions)是一個Perl庫,包括 perl 兼容的正則表達式庫。nginx

rewrite依賴于PCRE庫,所以在安裝Tengine前一定要先安裝PCRE(http://www.pcre.org? )

tengine-2.1.0.tar.gz ?tengine主程序(http://tengine.taobao.org? )

解壓各軟件:[root@php?tengine]#?unzip?-q?pcre-8.33.zip

[root@php?tengine]#?tar?xf?jemalloc-3.6.0.tar.bz2

[root@php?tengine]#?tar?xf?tengine-2.1.0.tar.gz

[root@php?tengine]#?ls

jemalloc-3.6.0????????????????pcre-8.33??????tengine-2.1.0

jemalloc-3.6.0.tar.bz2????pcre-8.33.zip??tengine-2.1.0.tar.gz

安裝兩個依賴包:[root@php?tengine]#?cd?pcre-8.33

[root@php?pcre-8.33]#?./configure?--prefix=/usr/local/pcre8.33

[root@php?pcre-8.33]#?make?&&?make?install

[root@php?openssl-1.0.2]#?make?&&?make?install

[root@php?tengine]#?cd?jemalloc-3.6.0

[root@php?jemalloc-3.6.0]#?./configure?--prefix=/usr/local/jemalloc

[root@php?jemalloc-3.6.0]#?make?&&?make?install

上邊的這pcre與jemalloc兩個包可以不安裝,因為在tengine編譯時是引用的兩個包的源文件,并不是安裝后的目錄。

tengine編譯安裝:[root@php?jemalloc-3.6.0]#?cd?../tengine-2.1.0

[root@php?tengine-2.1.0]#?./configure?\

--prefix=/usr/local/tengine?\

--sbin-path=/usr/local/tengine/sbin/nginx?\

--conf-path=/etc/tengine/nginx.conf?\

--error-log-path=/var/log/tengine/error.log?\

--http-log-path=/var/log/tengine/access.log?\

--pid-path=/var/run/tengine.pid?\

--lock-path=/var/lock/subsys/tengine?\

--user=nginx?\

--group=nginx?\

--with-file-aio?\

--with-pcre=/root/software/tengine/pcre-8.33?\

--http-client-body-temp-path=/var/tmp/tengine/client?\

--http-proxy-temp-path=/var/tmp/tengine/proxy?\

--http-fastcgi-temp-path=/var/tmp/tengine/fastcgi?\

--http-uwsgi-temp-path=/var/tmp/tengine/uwsgi?\

--dso-path=/usr/local/tengine/modules?\

--dso-tool-path=/usr/local/tengine/modules/dso_tool?\

--with-jemalloc?\

--with-jemalloc=/root/software/tengine/jemalloc-3.6.0

#這次編譯安裝我沒有顯式的指定編譯進哪些模塊,因為在安裝好后我想看看tengine在不指定編譯進哪些模塊時默認安裝了哪些模塊。[root@php?tengine-2.1.0]#?make

[root@php?tengine-2.1.0]#?make?install

[root@php?tengine-2.1.0]#?/usr/local/tengine/sbin/nginx?-v

Tengine?version:?Tengine/2.1.0?(nginx/1.6.2)

[root@php?tengine-2.1.0]#?/usr/local/tengine/sbin/nginx?-m

#看看吧,下邊就是tengine默認時安裝了哪些模塊,常用的模塊都已經編譯進來了,所以在configure時真

的不需要指定安裝哪些模塊,如果默認模塊中沒有你需要的,那可以通過dso的方式編譯進tengine,再動態加載進tengine即可。

Tengine?version:?Tengine/2.1.0?(nginx/1.6.2)

loaded?modules:

ngx_core_module?(static)

ngx_errlog_module?(static)

ngx_conf_module?(static)

ngx_dso_module?(static)

ngx_syslog_module?(static)

ngx_events_module?(static)

ngx_event_core_module?(static)

ngx_epoll_module?(static)

ngx_procs_module?(static)

ngx_proc_core_module?(static)

ngx_openssl_module?(static)

ngx_regex_module?(static)

ngx_http_module?(static)

ngx_http_core_module?(static)

ngx_http_log_module?(static)

ngx_http_upstream_module?(static)

ngx_http_static_module?(static)

ngx_http_autoindex_module?(static)

ngx_http_index_module?(static)

ngx_http_auth_basic_module?(static)

ngx_http_access_module?(static)

ngx_http_limit_conn_module?(static)

ngx_http_limit_req_module?(static)

ngx_http_geo_module?(static)

ngx_http_map_module?(static)

ngx_http_split_clients_module?(static)

ngx_http_referer_module?(static)

ngx_http_rewrite_module?(static)

ngx_http_ssl_module?(static)

ngx_http_proxy_module?(static)

ngx_http_fastcgi_module?(static)

ngx_http_uwsgi_module?(static)

ngx_http_scgi_module?(static)

ngx_http_memcached_module?(static)

ngx_http_empty_gif_module?(static)

ngx_http_browser_module?(static)

ngx_http_user_agent_module?(static)

ngx_http_upstream_ip_hash_module?(static)

ngx_http_upstream_consistent_hash_module?(static)

ngx_http_upstream_check_module?(static)

ngx_http_upstream_least_conn_module?(static)

ngx_http_reqstat_module?(static)

ngx_http_upstream_keepalive_module?(static)

ngx_http_upstream_dynamic_module?(static)

ngx_http_stub_status_module?(static)

ngx_http_write_filter_module?(static)

ngx_http_header_filter_module?(static)

ngx_http_chunked_filter_module?(static)

ngx_http_range_header_filter_module?(static)

ngx_http_gzip_filter_module?(static)

ngx_http_postpone_filter_module?(static)

ngx_http_ssi_filter_module?(static)

ngx_http_charset_filter_module?(static)

ngx_http_userid_filter_module?(static)

ngx_http_footer_filter_module?(static)

ngx_http_trim_filter_module?(static)

ngx_http_headers_filter_module?(static)

ngx_http_upstream_session_sticky_module?(static)

ngx_http_copy_filter_module?(static)

ngx_http_range_body_filter_module?(static)

ngx_http_not_modified_filter_module?(static)

為tengine提供服務啟動腳本:[root@php?tengine-2.1.0]#?vim?/etc/rc.d/init.d/nginx

#!/bin/bash

##

#nginx?-?this?script?starts?and?stops?the?nginx?daemon

#

#?chkconfig:???-?85?15

#?description:??Tengine?is?an?HTTP(S)?server,?HTTP(S)?reverse?\

#???????????????proxy?and?IMAP/POP3?proxy?server

#?processname:?nginx

#?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/tengine/sbin/nginx"

prog=$(basename?$nginx)

nginx_config_file="/etc/tengine/nginx.conf"

lockfile=/var/lock/subsys/tengine

make_dirs()?{

#?make?required?directories

user=`$nginx?-V?2>&1?|?grep?"configure?arguments:"?|?sed?'s/[^*]*--user=\([^?]*\).*/\1/g'?-`

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

}

start()?{

[?-x?$nginx?]?||?exit?5

[?-f?$nginx_config_file?]?||?exit?6

make_dirs

echo?-n?$"Starting?$prog:?"

daemon?$nginx?-c?$nginx_config_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_config_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

[root@php?tengine-2.1.0]#?chmod?+x?/etc/rc.d/init.d/nginx

測試tengine的啟動與停止:[root@php?tengine-2.1.0]#?service?nginx?start

Starting?nginx:????????????????????????????????????????????[??OK??]

[root@php?tengine-2.1.0]#?service?nginx?stop

Stopping?nginx:????????????????????????????????????????????[??OK??]

在編譯安裝tengine時可能會遇到如下錯誤:sr/local/jemalloc-3.6.0/lib/libjemalloc.a?-lpthread

TEST_NGINX_BINARY=/root/software/tengine/tengine-2.1.0/objs/nginx?prove?-v?-I?/root/software/tengine/tengine-2.1.0/tests/nginx-tests/nginx-tests/lib?tests/nginx-tests/nginx-tests?tests/nginx-tests/cases

/bin/sh:?prove:?command?not?found

make[1]:?***?[test]?Error?127

make[1]:?Leaving?directory?`/root/software/tengine/tengine-2.1.0'

make:?***?[test]?Error?2

處理方法:[root@php?tengine-2.1.0]#?yum?provides?*bin/prove

#獲得此命令是哪個包生成的

perl-Test-Harness-3.17-136.el6.x86_64?:?Run?Perl?standard?test?scripts?with?statistics

Repo????????:?base

Matched?from:

Filename????:?/usr/bin/prove

perl-Test-Harness-3.17-136.el6_6.1.x86_64?:?Run?Perl?standard?test?scripts?with?statistics

Repo????????:?updates

Matched?from:

Filename????:?/usr/bin/prove

[root@php?tengine-2.1.0]#?yum?-y?install?perl-Test-Harness??#安裝相應的包即可

2、FPM制作Tengine為RPM包

FPM是ruby的模塊,先安裝FPM依賴的包:[root@php?tengine]#?yum?-y?install?ruby?rubygems?ruby-devel?rpm-build[root@php?tengine]#?gem?sources?-a?http://ruby.taobao.org/

[root@php?tengine]#?gem?sources?--remove?http://rubygems.org/

[root@php?tengine]#?gem?sources?-l

[root@php?tengine]#?gem?clean

安裝FPM:[root@php?tengine]#?gem?install?fpm

轉換到上邊編譯tengine的工作目錄,先做一些打包前的準備工作:[root@php?tengine-2.1.0]#?pwd

/root/software/tengine/tengine-2.1.0

創建一個安裝tengine的臨時目錄,fpm可以從這個目錄是讀取信息:

[root@php tengine-2.1.0]# mkdir /tmp/installdir

把tengine安裝到此臨時目錄中:

[root@php tengine-2.1.0]# make install DESTDIR=/tmp/installdir/

[root@php tengine-2.1.0]# cd /tmp/installdir/

查看一下目錄結構:[root@php?installdir]#?tree?-L?3

.

├──?etc

│???└──?tengine

│???????├──?browsers

│???????├──?fastcgi.conf

│???????├──?fastcgi.conf.default

│???????├──?fastcgi_params

│???????├──?fastcgi_params.default

│???????├──?koi-utf

│???????├──?koi-win

│???????├──?mime.types

│???????├──?mime.types.default

│???????├──?module_stubs

│???????├──?nginx.conf

│???????├──?nginx.conf.default

│???????├──?scgi_params

│???????├──?scgi_params.default

│???????├──?uwsgi_params

│???????├──?uwsgi_params.default

│???????└──?win-utf

├──?usr

│???└──?local

│???????└──?tengine

└──?var

├──?log

│???└──?tengine

└──?run

[root@php?installdir]#?pwd

/tmp/installdir

[root@php?installdir]#?ls

etc??usr??var

創建放置服務啟動腳本的目錄:[root@php?installdir]#?mkdir?-pv?etc/rc.d/init.d

mkdir:?created?directory?`etc/rc.d'

mkdir:?created?directory?`etc/rc.d/init.d'

[root@php?installdir]#?cp?/etc/rc.d/init.d/nginx?./etc/rc.d/init.d??#把服務啟動腳本拷貝過來

準備rpm安裝后及卸載后所需要運行的腳本:[root@php?installdir]#?mkdir?tmp;cd?tmp??#這個目錄是放置以下兩個腳本的目錄

[root@php?tmp]#?vim?install_after.sh

#!/bin/bash

#

add?user?nginx

source?/etc/rc.d/init.d/functions

getent?group?nginx?>?/dev/null?||?groupadd?-r?nginx

getent?passwd?nginx?>?/dev/null?||?useradd?-r?-g?nginx?-s?/sbin/nologin?nginx

exit?0

#此腳本是在tengine安裝好后可以檢測系統上是否有nginx組和用戶,如果沒有就創建。[root@php?tmp]#?vim?remove_after.sh

#!/bin/bash

#

source?/etc/rc.d/init.d/functions

rm?-rf?/usr/local/tengine

rm?-rf?/etc/tengine

userdel?nginx

exit?0

#此腳本是在卸載tengine時刪除在安裝時生成的各個目錄及創建的用戶

制作rpm包:[root@php?~]#??fpm?-s?dir?-t?rpm?-n?tengine?-v?2.1.0?--iteration?1.el6?-C?/tmp/installdir/?-p?/root?--description?'tengine?rpm'?--url?'tengine.taobao.org'?--post-install?/tmp/installdir/tmp/install_after.sh?--post-uninstall?/tmp/installdir/tmp/remove_after.sh

no?value?for?epoch?is?set,?defaulting?to?nil?{:level=>:warn}

no?value?for?epoch?is?set,?defaulting?to?nil?{:level=>:warn}

Created?package?{:path=>"/root/tengine-2.1.0-1.el6.x86_64.rpm"}

#fpm命令詳細參數解釋可以用"fpm?-h"查看

[root@php?~]#?ls

software??tengine-2.1.0-1.el6.x86_64.rpm

rpm文件生成后就可以拷貝到其他服務器進行測試:[root@php?~]#?scp?tengine-2.1.0-1.el6.x86_64.rpm?192.168.0.203:/root

[root@nod3?~]#?rpm?-ivh?tengine-2.1.0-1.el6.x86_64.rpm

Preparing...????????????????###########################################?[100%]

1:tengine????????????????###########################################?[100%]

[root@nod3?~]#?rpm?-qp?--scripts?tengine-2.1.0-1.el6.x86_64.rpm

#查看rpm文件中的腳本信息

postinstall?scriptlet?(using?/bin/sh):

#!/bin/bash

#

source?/etc/rc.d/init.d/functions

getent?group?nginx?>?/dev/null?||?groupadd?-r?nginx

getent?passwd?nginx?>?/dev/null?||?useradd?-r?-g?nginx?-s?/sbin/nologin?nginx

exit?0

postuninstall?scriptlet?(using?/bin/sh):

#!/bin/bash

#

source?/etc/rc.d/init.d/functions

rm?-rf?/usr/local/tengine

rm?-rf?/etc/tengine

rm?-rf?/etc/rc.d/init.d/nginx

userdel?nginx

exit?0

tengine安裝好后來驗證各個目錄及用戶是否生成:[root@nod3?~]#?id?nginx

uid=496(nginx)?gid=496(nginx)?groups=496(nginx)

[root@nod3?~]#?ls?/etc/tengine/

browsers??????????????fastcgi_params.default??mime.types.default??scgi_params???????????win-utf

fastcgi.conf??????????koi-utf?????????????????module_stubs????????scgi_params.default

fastcgi.conf.default??koi-win?????????????????nginx.conf??????????uwsgi_params

fastcgi_params????????mime.types??????????????nginx.conf.default??uwsgi_params.default

[root@nod3?~]#?ls?/usr/local/tengine/

html??include??modules??sbin??scgi_temp

[root@nod3?~]#?ls?/etc/rc.d/init.d/nginx

/etc/rc.d/init.d/nginx

啟動服務器來檢測tengine是否能正常運行:[root@nod3?~]#?service?nginx?start

Starting?nginx:????????????????????????????[??OK??]

[root@nod3?~]#?netstat?-tnlp?|?grep?nginx

tcp????????0??????0?0.0.0.0:80???????0.0.0.0:*???????????????????LISTEN??????2257/nginx

再來測試一下卸載tengine后各個目錄是否能刪除:[root@nod3?~]#?rpm?-e?tengine

[root@nod3?~]#?id?nginx

id:?nginx:?No?such?user

[root@nod3?~]#?ls?/etc/?|?grep?tengine

[root@nod3?~]#?ls?/usr/local/?|?grep?tengine

[root@nod3?~]#?ls?/etc/rc.d/init.d/?|?grep?nginx

#?軟件卸載后各個目錄都已被成功刪除了。

3、總結

FPM非常易用,有了此工具再也不用擔心rpm包的制作,在用此命令時可以把rpm包的安裝、卸載做得更加優雅,在安裝前可以做一些準備工作,安裝后可以

做一些收尾工作,在卸載前也可以做一些準備,比如檢測一下相應的服務是否停止了,在卸載軟件再做一些掃尾的工作,只要把這些定義成一個個腳本,fpm中指

定相應的選項即可輕松實現。

fpm一些常用參數如下(用fpm –help可以才看所有參數詳解)

把rpm包放到yum源中,先更新中心yum倉庫的元數據,然后再更新需要安裝該rpm包機器的yum元數據。#提供yum源服務的機器

createrepo?--update?/mirros/centos/6.3/x86_64/???更新repo數據

createrepo?/mirros/centos/6.3/x86_64/?????創建repo數據

#享受yum源服務的機器

yum?clean?all

yum?makecache

參考文章:

總結

以上是生活随笔為你收集整理的tengine php fpm,FPM打包工具制作Tengine为RPM包详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。