国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Shell腳本中實現更新PHP5

2019-10-26 18:45:40
字體:
來源:轉載
供稿:網友

我很迷戀 Shell,很喜歡看著字符在黑色的 Console 界面中跳躍著,奇怪的是,我居然沒有因此成為一個 Linux/Unix 程序員,而只是個寫 CGI 程序的倒霉蛋。大家都是怎么稱呼 “PHP 程序員”的?對了——草根~ 嗯,在土里埋的太久,說不定哪天就爛掉了咯! 

可能是被 Windows 慣壞了,實在不想換個 OS,還好有 Cygwin,MinGW … 之類的東西, 適當的時候,可以拿出來裝下 B,自我安慰一下~

我總喜歡從 windows.php.net 下載最新的 snapshot,不是我想體驗最新的功能,只是強迫癥的關系-,-。我機器上的所有軟件,程序都是最新的,絕大部分都還掛著 beta 標簽,甚至有一些是直接從 SVN,Git 上面拖下來的 trunk 版本,想想真是變態。如果你每天都爬上這些網站,人肉檢查一下是不是有新的版本發布,以此滿足一下自己變態的心理,那真是要瘋掉了。

能讓機器干的事情,就不要手工去做,是吧!下面這段代碼會自動去 check 最新的 snapshot,解壓到你想要的目錄。 然后呢?建個 cron job 掛上去,就可以去找新的樂子了~

代碼中下載的是,None thead safe VC9 版本,注意替換成自己能用的版本。需要強制更新的話,加上 “–force” 參數。

最后一行使用 icacls 重置了 php5-nts 目錄下文件的權限(注意路徑的寫法,icacls 是 windows 自己的程序),因為 cygwin 會把 NTFS 的權限搞的巨惡心。
PS: 非 CGI/FCGI 安裝模式,記得關掉 Web Server。

#!/bin/bash INSTALL_PATH="/cygdrive/d/php5-nts"BUILD_TIME_FILE="/cygdrive/d/php5-nts/build-time"PACKAGE_URL="http://windows.php.net/downloads/snaps/php-5.3-nts-win32-VC9-x86-latest.zip" function uprint {  if [ "${1:0:1}" = "-" ]; then    echo $1 "# $2"  else    echo "# $1"  fi} ## If unzip available?UNZIP=`which unzip 2> /dev/null`if [ -z $UNZIP ]; then  uprint "Could not find unzip, please install."  exit 1fi ## Test if build-time file exists, if not, create itif [ ! -f $BUILD_TIME_FILE ]; then  uprint -n "Build time file does not exists, created ... "  touch $BUILD_TIME_FILE  echo -e "/e[32m[OK]/e[0m"fi ## Get current build timeCURRENT_BUILD_TIME=`cat $BUILD_TIME_FILE` ## Get latest build timeLATEST_BUILD_TIME=`curl --silent http://windows.php.net/snapshots/ | /    grep "php-5.3-nts-VC9-x86" | /    grep "VC9 x86 Non Thread Safe (" | /    grep -o "(.*)" | /    sed 's/[()]//g'` ## Any update?package=`basename $PACKAGE_URL`if [ "$CURRENT_BUILD_TIME" != "$LATEST_BUILD_TIME" ]; then  uprint -e "New version available, build time: /e[36m$LATEST_BUILD_TIME/e[0m"else   if [ "$1" != "--force" ]; then    uprint "You are using the latest snapshot version."    exit 0  else     uprint -e "/e[31mForce to update local php version./e[0m"  fifi ## Delete if file already existsls $package > /dev/null 2>&1if test $? -eq 0; then  uprint -n "Performing: rm -f /`ls $package/` ... "  rm -f `ls $package`  echo -e "/e[32m[OK]/e[0m"fi ## Get latest php5 binary packageuprint -n "Downloading latest php binary package ... "wget -q $PACKAGE_URLecho -e "/e[32m[OK]/e[0m" ## Extractingif [ -f $package ]; then  # kill php processes  for php_pid in `ps -as | grep php | awk '{print $1}'`  do     kill -9 $php_pid  done   uprint -n "Extracting ... "  unzip -o $package -x -d $INSTALL_PATH > /dev/null 2>&1  echo -e "/e[32m[OK]/e[0m"  echo $LATEST_BUILD_TIME > $BUILD_TIME_FILE   uprint -n "Cleaning up ... "  rm -f $package  echo -e "/e[32m[OK]/e[0m"fi ## Fixed cygwin permissionsicacls D:/php5-nts /reset /T > /dev/null # vim: set expandtab tabstop=4 shiftwidth=4:            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 繁昌县| 昌图县| 卓资县| 南陵县| 临汾市| 内黄县| 南丰县| 沧州市| 大石桥市| 兴安县| 墨竹工卡县| 通州区| 台州市| 那坡县| 禹城市| 山西省| 防城港市| 利津县| 河北区| 新密市| 尖扎县| 吉木萨尔县| 美姑县| 商南县| 临江市| 子洲县| 永顺县| 康平县| 徐汇区| 庄浪县| 江安县| 焦作市| 科尔| 庆城县| 株洲市| 山阳县| 普定县| 弥渡县| 志丹县| 江门市| 清远市|