openshift鎼寤簄ginx+php5.2+zend+mysql鏈嶅姟鍣ㄦ暀绋

2013 年 12 月 4 日1,1120

銆銆杩戞棩鐢宠蜂簡openshift鐨刾aas绌洪棿锛屽緢闇告皵鐨勬敮鎸乶绉嶈瑷锛岃嚦浜庣敤涓嶇敤寰椾笂灏辨槸涓よ翠簡锛岀┖闂寸敵璇风殑鏁欑▼涓嶅湪鏈鏂囦箣鍒楋紝鏈夊叴瓒g殑鍚屽織鍙浠ュ啀鏈绔欑◢鍚庢斁鍑虹殑鍙︿竴绡囨枃绔犱腑缁欏嚭璇︾粏浠嬬粛锛屾湰鏂囨槸寤虹珛鍦ㄤ綘宸茬粡鍙栧緱openshift璐﹀彿浠ュ強绌洪棿鏉冮檺鐨勫熀纭涓婏紝骞朵笖宸茬粡瀹屾垚openshift绠$悊杞浠剁殑涓嬭浇鍜屽畨瑁咃紝濂戒簡锛屽簾璇濅笉澶氳达紝濂芥垙寮鍦恒

銆銆鏈鏂囧叾瀹為泦鍚堜簡鑻ュ共鍏充簬寤虹珛openshift鐨勫崥鏂囷紝鍐嶉泦鍚堜簡鏈浜轰竴浜涚壒娈婄殑闇姹傦紝姣斿倆end鏀鎸侊紝鍜宲hp鐗堟湰姝ゆ′负5.2.17,5.3鐗堟湰鐨勪笉鐢ㄨㄨ虹洿鎺ヤ竴鏉″懡浠ゅ氨鍙寤虹珛锛屽湪鍛戒护鎻愮ず绗cmd绐楀彛杈撳叆:rhc app create php5.3 name锛屽叾涓璶ame涓轰綘鎯冲缓绔嬬殑搴旂敤鍚嶇О锛屼互鍚庡煙鍚嶅氨浼氫互姝ゅ紑澶达紝涔嬪悗杩涘叆web绠$悊鐣岄潰娣诲姞mysql鏁版嵁搴撱

銆銆棣栧厛鎼寤簄ginx1.2鏈嶅姟鍣锛屼互涓嬫搷浣滃潎鍦╯sh鍛戒护绐楀彛涓嬫墽琛岋細

銆銆cd $OPENSHIFT_DATA_DIR

銆銆wget http://http://www.zjjv.com///download/nginx-1.2.2.tar.gz

銆銆tar zxf nginx-1.2.2.tar.gz

銆銆wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.bz2

銆銆tar jxf pcre-8.31.tar.bz2

銆銆#寮濮嬬紪璇憂ginx

銆銆makedir nginx1.2

銆銆cd nginx-1.2.2

銆銆./configure --with-pcre=$OPENSHIFT_DATA_DIR/pcre-8.31 --prefix=$OPENSHIFT_DATA_DIR/nginx1.2

銆銆make

銆銆make install

銆銆cd $OPENSHIFT_DATA_DIR

銆銆#閰嶇疆NGINX

銆銆vim nginx1.2/conf/nginx.conf

銆銆缂栬緫涓嬬鍐呭癸細

銆銆http { …

銆銆server {

銆銆listen 127.7.192.129:8080;

銆銆server_name 127.7.192.129;

銆銆…

銆銆}

銆銆…

銆銆}

銆銆listen鍜宻erver_name鐨処P鍜岀鍙e垎鍒鐢眅cho $OPENSHIFT_DIY_IP銆乪cho $OPENSHIFT_DIY_PORT

銆銆寰楀埌

銆銆location / {

銆銆root html;

銆銆index index.php index.html index.htm;

銆銆}

銆銆瑕佹洿鏀圭綉绔欐牴鐩褰曡蜂慨鏀箁oot html(html涓虹綉绔欐牴鐩褰曡矾寰勶紝淇鏀逛负瀹為檯璺寰勫嵆鍙)锛屽苟鍦╥ndex涓娣诲姞index.php锛屾湇鍔″櫒灏变細鑷鍔ㄨ瘑鍒浠php缁撳熬鐨勪富椤碉紝涓嶇劧鏈夊彲鑳戒細鍑虹幇404閿欒锛屽叾涓環tml鐢$OPENSHIFT_REPO_DIR/diy寰楀埌;

銆銆瑕佸惎鐢╪ginx瀵筽hp鐨勬敮鎸佸幓鎺変互涓嬬墖娈电殑娉ㄩ噴锛屽苟

銆銆location ~ .php$ {

銆銆root $OPENSHIFT_REPO_DIR/diy;

銆銆fastcgi_pass $OPENSHIFT_DIY_IP:9000;

銆銆fastcgi_index index.php;

銆銆include fastcgi.conf;

銆銆}

銆銆$OPENSHIFT_REPO_DIR, $OPENSHIFT_DIY_IP閮借佸~鍐欒嚜宸辩殑鍏蜂綋鍊硷紝绔鍙e彿榛樿9000涔熷彲浠绘剰鎸囧畾锛屽熷ぇ鍗冲彲锛屼笉杩囪佽颁綇鍝︼紝涓嬮潰鐨勯厤缃浼氱敤鍒般

銆銆鍙﹀栧湪鍚鍔∟GINX鍓 璇穔illall ruby锛屼笉鐒朵細鍥犵鍙e崰鐢ㄨ屽け璐

銆銆棣栧厛鍦$OPENSHIFT_DATA_DIR/nginx.1.2鐩褰曚腑寤虹珛start.sh鍜宺estart.sh锛屼娇鐢ㄥ懡浠

銆銆vim start.sh #杈撳叆浠ヤ笅鍐呭瑰悗锛宔sc閿閫鍑虹紪杈戯紝杈撳叆:wq鍗冲彲淇濆瓨閫鍑(鍖呭惈鍐掑彿)銆

銆銆start.sh 鍐呭逛负

銆銆#!/bin/bash

銆銆# start nginx

銆銆killall ruby

銆銆$OPENSHIFT_DATA_DIR/nginx1.2/sbin/nginx

銆銆Start.sh寤虹珛瀹屾瘯鍚庯紝

銆銆vim restart.sh #杈撳叆浠ヤ笅鍐呭癸紝esc閿閫鍑虹紪杈戯紝杈撳叆:wq鍗冲彲淇濆瓨閫鍑(鍖呭惈鍐掑彿)銆

銆銆restart.sh 鍐呭逛负

銆銆#!/bin/bash

銆銆# restart nginx

銆銆killall ruby

銆銆killall nginx

銆銆$OPENSHIFT_DATA_DIR/nginx1.2/sbin/nginx

銆銆鍗冧竾鍒蹇樿拌祴浜坰tart.sh鍜宺estart.sh鍙鎵ц屾潈闄愶細

銆銆chmod +x start.sh restart.sh

銆銆鍦▇/app-root/repo/.openshift/action_hooks鐩褰曚腑鐨剆tart鏈灏惧姞鍏

銆銆$OPENSHIFT_DATA_DIR/nginx1.2/start.sh

銆銆鑷虫nginx鎼寤哄畬姣曪紝鍦╪ginx1.2璺寰勮緭鍏ュ懡浠restart.sh,杈撳叆涓涓涓嶅瓨鍦╱rl锛屽傛灉鐪嬪埌nginx鐨404椤甸潰璇存槑浣犳垚鍔熶簡銆

銆銆鏈鏂囬摼鎺ワ細http://http://www.zjjv.com///info/2013/11/26/9.html

銆銆涓嬮潰寮濮嬬紪璇憄hp5.2.17锛岃嚦浜5.2璇︾粏鐗堟湰闅忓悇浣嶅彇鑸嶄簡锛17鏄5.2鐨勬渶鍚庝竴涓鐗堟湰銆

銆銆wget http://http://www.zjjv.com///php5/php-5.2.17.tar.gz

銆銆wget http://http://www.zjjv.com///downloads/php-5.2.17-fpm-0.5.14.diff.gz

銆銆mkdir PHP5.2

銆銆tar zxf php-5.2.17.tar.gz

銆銆gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1

銆銆cd php-5.2.17

銆銆./configure --with-mysql=/var/lib/openshift/user/mysql --prefix=$OPENSHIFT_DATA_DIR/PHP5.2 --enable-fpm

銆銆--enable-mbstring --with-zlib --enabl

銆銆e-xml --enable-bcmath --with-curl --with-gd --enable-zip --enable-sockets --with-libdir=lib64 --with-png

銆銆-dir=/usr --with-jpeg-dir=/usr --with-config-file-path=$OPENSHIFT_DATA_DIR/PHP5.5/etc --with-pcre --enable-fastcgi

銆銆#瑕佸皢mysql涓鐨剈ser鎹㈡垚鑷宸辩殑id!缂栬瘧澶ф傞渶瑕佸崐灏忔椂宸﹀彸鏃堕棿锛屽彇鍐充簬浣犵殑缃戦

銆銆make

銆銆make install

銆銆#鍙堟槸鍗婂皬鏃 鍒颁竴涓灏忔椂涓嶇瓑 = = 锛屼笅闈㈡槸灏嗘枃浠秔hp.ini-dist鏂囦欢鎷疯礉骞堕噸鍛藉悕涓簆hp.ini鏂囦欢

銆銆cp php.ini-dist $OPENSHIFT_DATA_DIR/PHP5.2/etc/php.ini

銆銆涓嬮潰瑕侀厤缃畃hp-fpm锛屾湰鏂囬摼鎺ワ細http://http://www.zjjv.com///info/2013/11/26/9.html

銆銆vim $OPENSHIFT_DATA_DIR/PHP5.2/etc/php-fpm.conf

銆銆鏍囩緇isten_address鏄閰嶇疆fastcgi杩涚▼鐩戝惉鐨処P鍦板潃浠ュ強绔鍙o紝榛樿ゆ槸127.0.0.1:9000銆

銆銆$OPENSHIFT_DIY_IP:9000 锛$OPENSHIFT_DIY_IP瑕佸~鑷宸辩殑鍏蜂綋鍊硷紝绔鍙h佽窡鍦╪ginx涓閰嶇疆php鐨勭鍙d竴鑷淬

銆銆鏍囩綼llowed_clients鐢ㄤ簬璁剧疆鍏佽歌块棶FastCGI杩涚▼瑙f瀽鍣ㄧ殑IP鍦板潃銆傚傛灉涓嶅湪杩欓噷鎸囧畾IP鍦板潃锛孨ginx杞鍙戣繃鏉ョ殑PHP瑙f瀽璇锋眰灏嗘棤娉曡鎺ュ彈銆

銆銆127.0.0.1,$OPENSHIFT_IP_DIY,$OPENSHIFT_IP_DIY濉鍐欒嚜宸辩殑鍏蜂綋鍊硷紝涓瀹氳佹坊鍔犺嚜宸辩殑ip鍊硷紝涓嶇劧杩樻槸浼氭棤娉曡В鏋恜hp鑴氭湰锛屽嚭鐜404閿欒銆

銆銆骞跺湪$OPENSHIFT_DATA_DIR/nginx1.2/restart.sh涓鍔犲叆

銆銆$OPENSHIFT_DATA_DIR /PHP5.5/sbin/php-fpm restart

銆銆鎵ц restart.sh锛宯ginx+php閰嶇疆澶у姛鍛婃垚銆

銆銆鏈鍚庤佸姞鍏Zend optimizer鎵╁睍锛屼互鏀鎸佺敤Zend鍔犲瘑杩囩殑绋嬪簭锛

銆銆cd $OPENSHIFT_DATA_DIR

銆銆wget http://http://www.zjjv.com///optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

銆銆tar zxf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

銆銆cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so $OPENSHIFT_DATA_DIR/PHP5.2/ZendOptimizer.so

銆銆vi $OPENSHIFT_DATA_DIR/PHP5.2/etc/php.ini

銆銆鍦ㄦ枃浠舵湯灏炬坊鍔

銆銆[ZendOptimizer]

銆銆zend_optimizer.optimization_level=1

銆銆zend_extension="$OPENSHIFT_DATA_DIR/PHP5.5/ZendOptimizer.so"

銆銆杩欓噷鐨$OPENSHIFT_DATA_DIR瑕佸~鍐欒嚜宸卞叿浣撶殑璺寰勶紝鎵ц宯ginx1.2涓鐨剅estart.sh锛屼笂浼犳帰閽堥獙璇亃end optimizer瀹夎呮槸鍚

銆銆鎴愬姛锛屾湰鏂囨帰閽堝湴鍧http://http://www.zjjv.com///tz.php

0 0