手机版
你好,游客 登录 注册
背景:
阅读新闻

PHP 5.4.10 + Nginx 1.0.15 + PostgreSQL 9.1.3 源码编译自动化部署第三版

[日期:2012-04-15] 来源:Linux社区  作者:qzier_go [字体:大 中 小]

旧版在这里

PHP 5.3.10 + Nginx 1.0.12 + PostgreSQL 9.1.2 源码编译自动化部署第一版 http://www.linuxidc.com/Linux/2012-02/54589.htm

PHP 5.4.10 + Nginx 1.0.12 + PostgreSQL 9.1.3 源码编译自动化部署第二版 http://www.linuxidc.com/Linux/2012-03/55827.htm

此次加入启动脚本,php 加入了 gd,mbstring,curl,ssl,mhash,mcrypt 等等 ,nginx 升级到 1.0.15,从版本开始直接移入google仓库 ...

http://code.google.com/p/lnpp/source/browse/lnpp-0.05.sh

http://code.google.com/p/lnpp/source/browse/lnpp_start-0.05

Desc:
lnmpp=linux + nginx + php + postgresql

Detail:
PHP_VERSION=php-5.4.0
PG_VERSION=postgresql-9.1.3
NGINX_VERSION=nginx-1.0.15

Usage:
#sh lnpp.sh
#./lnpp_start {start|stop|reload}

Contact:
email:i@qzier.com
qq group:213572677
google group:http://groups.google.com/group/lnpp

  1. #!/bin/bash  
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin  
  3. export PATH  
  4.   
  5. # Check if user is root  
  6. if [ $(id -u) != "0" ]; then  
  7.     echo "Error: You must be root to run this script, please use root to install lnpp"  
  8.     exit 1  
  9. fi  
  10.   
  11. clear  
  12. echo "========================================================================="  
  13. echo "lnpp install shell script for CentOS/RadHat Written by Qzi"  
  14. echo "creatred in 2012/2/13"  
  15. echo "last modified in 2012/4/13"  
  16. echo "Email:i@qzier.com"  
  17. echo "========================================================================="  
  18. echo "========================================================================="  
  19. echo "PHP Version: 5.4.0"  
  20. echo "========================================================================="  
  21. echo "========================================================================="  
  22. echo "PostgreSQL Version: 9.1.3"  
  23. echo "========================================================================="  
  24. echo "========================================================================="  
  25. echo "nginx Version: 1.0.15"  
  26. echo "========================================================================="  
  27.   
  28.   
  29. # prepare for future  
  30. PHP_VERSION=php-5.4.0  
  31. PG_VERSION=postgresql-9.1.3  
  32. NGINX_VERSION=nginx-1.0.15  
  33.   
  34. LNPP_SRC_ROOT=$(pwd)  
  35. LNPP_ROOT=/tmp/lnpp/lnpp-0.05  
  36. PG_ROOT=$LNPP_ROOT/pgsql/$PG_VERSION  
  37. PHP_ROOT=$LNPP_ROOT/php/$PHP_VERSION  
  38. PHP_EXTRA_LIBS=$PHP_ROOT/3rdlibs  
  39. NGINX_ROOT=$LNPP_ROOT/nginx/$NGINX_VERSION  
  40.   
  41.   
  42. if [ -d $LNPP_ROOT ]; then  
  43.   echo "lnpp will install in $LNPP_ROOT"  
  44.   else  
  45.   echo "lnpp is creating the directory $LNPP_ROOT"  
  46.   mkdir -p $LNPP_ROOT  
  47. fi  
  48.   
  49. for filename in $(rpm -aq|grep flex)  
  50. do  
  51.      yum erase $filename  
  52.      #yum erase $filename -y  
  53. done  
  54.   
  55. for filename in $(rpm -aq|grep php)  
  56. do  
  57.      yum erase $filename  
  58.      #yum erase $filename -y  
  59. done  
  60.   
  61. echo "========================================================================="  
  62. echo "install dependences"  
  63. echo "========================================================================="  
  64.   
  65. for packages in patch make gcc gcc-c++ gcc-g77 bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip autoconf re2c;  
  66. do yum -y install $packages; done  
  67.   
  68. echo "============================check files=================================="  
  69.   
  70. if [ -s $PHP_VERSION.tar.gz ]; then  
  71.   echo "$PHP_VERSION.tar.gz [found]"  
  72.   else  
  73.   echo "Error: $PHP_VERSION.tar.gz not found!!!download now......"  
  74. #  wget -c http://cn2.php.net/get/$PHP_VERSION.tar.gz/from/jp.php.net/mirror  
  75.   wget -c http://cn2.php.net/get/$PHP_VERSION.tar.gz/from/cn.php.net/mirror   
  76. fi  
  77.   
  78. if [ -s libiconv-1.14.tar.gz ]; then  
  79.   echo "libiconv-1.14.tar.gz [found]"  
  80.   else  
  81.   echo "Error: libiconv-1.14.tar.gz not found!!!download now......"  
  82.   wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz  
  83. fi  
  84.   
  85. if [ -s pcre-8.21.tar.bz2 ]; then  
  86.   echo "pcre-8.21.tar.bz2 [found]"  
  87.   else  
  88.   echo "Error: pcre-8.21.tar.bz2 not found!!!download now......"  
  89.   wget http://downloads.sourceforge.net/project/pcre/pcre/8.21/pcre-8.21.tar.bz2  
  90. fi  
  91.   
  92. if [ -s $PG_VERSION.tar.gz ]; then  
  93.   echo "$PG_VERSION.tar.gz [found]"  
  94.   else  
  95.   echo "Error: $PG_VERSION.tar.gz not found!!!download now......"  
  96.   wget http://ftp.postgresql.org/pub/source/v9.1.3/$PG_VERSION.tar.gz # !!!!!!!!!!!!!!!!!!!!!!!!  
  97. fi  
  98.   
  99. if [ -s $NGINX_VERSION.tar.gz ]; then  
  100.   echo "$NGINX_VERSION.tar.gz [found]"  
  101.   else  
  102.   echo "Error: $NGINX_VERSION.tar.gz not found!!!download now......"  
  103.   wget http://nginx.org/download/$NGINX_VERSION.tar.gz  
  104. fi  
  105.   
  106. if [ -s flex-2.5.35.tar.gz ]; then  
  107.   echo "flex-2.5.35.tar.gz [found]"  
  108.   else  
  109.   echo "Error: flex-2.5.35.tar.gz not found!!!download now......"  
  110.   wget http://sourceforge.net/projects/flex/files/flex/flex-2.5.35/flex-2.5.35.tar.gz  
  111. fi  
  112.   
  113. if [ -s mcrypt-2.6.8.tar.gz ]; then  
  114.   echo "mcrypt-2.6.8.tar.gz [found]"  
  115. else  
  116.   echo "Error: mcrypt-2.6.8.tar.gz not found!!!download now......"  
  117.   wget http://sourceforge.net/projects/mcrypt/files/latest/download?source=files  
  118. fi  
  119.   
  120. if [ -s mhash-0.9.9.9.tar.bz2 ]; then  
  121.   echo "mhash-0.9.9.9.tar.bz2 [found]"  
  122. else  
  123.   echo "Error: mhash-0.9.9.9.tar.bz2 not found!!!download now......"  
  124.   wget http://sourceforge.net/projects/mhash/files/latest/download?source=files  
  125. fi  
  126.   
  127. echo "============================check complete=================================="  
  128.   
  129. echo "============================postgresql install=================================="  
  130.   
  131. #install flex  
  132. tar flex-2.5.35.tar.gz  
  133. make clean  
  134. make && make install  
  135.   
  136. mkdir -p $PG_ROOT  
  137. tar -zxvf $PG_VERSION.tar.gz  
  138.   
  139. if [ $(id -nu postgres) == "postgres" ]; then  
  140.   echo "user postgres is found ... "  
  141.   else  
  142.   echo "creating the user called 'postgres'"  
  143.   su - -c "useradd -M postgres"  
  144. fi  
  145.   
  146. chown -R postgres:postgres $PG_VERSION  
  147. mkdir -p $PG_ROOT/etc   
  148. cd $PG_VERSION  
  149. make clean  
  150. ./configure --prefix=$PG_ROOT --sysconfdir=$PG_ROOT/etc  
  151. make  
  152. make install  
  153. if [ -d $PG_ROOT/data ]; then  
  154.         mv $PG_ROOT/data $PG_ROOT/data.bak  
  155.         mkdir -p $PG_ROOT/data  
  156.         else      
  157.         mkdir -p $PG_ROOT/data  
  158. fi  
  159. mkdir -p $PG_ROOT/logs  
  160. touch $PG_ROOT/logs/pgsql.log  
  161. chown postgres:postgres $PG_ROOT/data  
  162. su postgres -c "$PG_ROOT/bin/initdb -D $PG_ROOT/data && exit"  
  163.   
  164. echo "============================postgresql complete=================================="  
  165.   
  166. echo "============================php install=================================="  
  167.   
  168. cd $LNPP_SRC_ROOT  
  169. mkdir -p $PHP_EXTRA_LIBS  
  170.   
  171. tar -zxf libiconv-1.14.tar.gz  
  172. cd libiconv-1.14  
  173. make clean  
  174. ./configure --prefix=$PHP_EXTRA_LIBS/libiconv-1.14/  
  175. make  
  176. make install  
  177. ls $PHP_EXTRA_LIBS/libiconv-1.14/  
  178. cd ../  
  179.   
  180. tar -jxf mhash-0.9.9.9.tar.bz2  
  181. cd mhash-0.9.9.9  
  182. make clean  
  183. ./configure --prefix=$PHP_EXTRA_LIBS/mhash-0.9.9.9  
  184. make  
  185. make install  
  186. ls $PHP_EXTRA_LIBS/mhash-0.9.9.9  
  187. cd ../  
  188.   
  189. tar -zxvf mcrypt-2.6.8.tar.gz  
  190. cd mcrypt-2.6.8  
  191. make clean  
  192. ./configure --prefix=$PHP_EXTRA_LIBS/mcrypt-2.6.8  
  193. make  
  194. make install  
  195. cd ../  
  196.   
  197. tar -jxf pcre-8.21.tar.bz2  
  198. cd pcre-8.21  
  199. make clean  
  200. ./configure --prefix=$PHP_EXTRA_LIBS/pcre-8.21/  
  201. make  
  202. make install  
  203. cd ../  
  204.   
  205. mkdir -p $PHP_ROOT   
  206. tar -zxvf $PHP_VERSION.tar.gz   
  207. cd $PHP_VERSION  
  208. make clean  
  209.   
  210. #./configure --prefix=$PHP_ROOT --with-config-file-path=$PHP_ROOT/etc/ --with-iconv=$PHP_EXTRA_LIBS/libiconv-1.14 --with-pcre-dir=$PHP_EXTRA_LIBS/pcre-8.21 --with-pgsql=$PG_ROOT --enable-fpm --with-pear --with-gd --enable-gd-native-ttf --with-freetype --with-zlib --enable-mbstring --with-curl --with-openssl  
  211.   
  212. ./configure --prefix=$PHP_ROOT --with-config-file-path=$PHP_ROOT/etc/ --with-iconv=$PHP_EXTRA_LIBS/libiconv-1.14 --with-pcre-               dir=$PHP_EXTRA_LIBS/pcre-8.21 --with-pgsql=$PG_ROOT --with-pdo-pgsql=$PG_ROOT --with-pdo-mysql=$MYSQL_ROOT --enable-fpm --with-pear --with-gd --enable-gd-native-ttf --with-freetype --with-zlib --enable-mbstring --with-curl --with-openssl --with-mhash=$PHP_EXTRA_LIBS/mhash-0.9.9.9 --with-mcrypt=$PHP_EXTRA_LIBS/mcrypt-2.6.8  
  213.   
  214. make   
  215. ##make ZEND_EXTRA_LIBS ='-liconv'  
  216. make install  
  217. cp ./php.ini-production $PHP_ROOT/etc/php.ini  
  218. cp $PHP_ROOT/etc/php-fpm.conf.default $PHP_ROOT/etc/php-fpm.conf  
  219. cd ../  
  220.   
  221. echo "============================php complete================================="  
  222.   
  223.   
  224. echo "============================nginx install================================="  
  225.   
  226. mkdir -p $NGINX_ROOT  
  227. tar -zxvf $NGINX_VERSION.tar.gz  
  228. cd $NGINX_VERSION   
  229.    
  230. if [ $(id -nu nginx) == "nginx" ]; then  
  231.   echo "user nginx is found ... "  
  232.   else  
  233.   echo "creating the user called 'nginx'"  
  234.   su - -c "useradd -M nginx"  
  235. fi  
  236.   
  237. make clean  
  238. ./configure --user=nginx --group=nginx --prefix=$NGINX_ROOT --with-http_ssl_module --with-pcre=$LNPP_SRC_ROOT/pcre-8.21  
  239. make  
  240. make install  
  241. cd ../  
  242. cp $NGINX_ROOT/conf/nginx.conf $NGINX_ROOT/conf/nginx.conf.bak2  
  243. cat $NGINX_ROOT/conf/nginx.conf | sed -e '65,72s/^        #/        /g'| \  
  244. sed -e 's/\/scripts$fastcgi_script_name;/$document_root$fastcgi_script_name;/g'  > $NGINX_ROOT/conf/nginx.conf.bak  
  245. cp -f $NGINX_ROOT/conf/nginx.conf.bak $NGINX_ROOT/conf/nginx.conf  
  246. echo "============================nginx complete================================="  
  247. echo "============================phpinfo in /nginx/html================================="  
  248.   
  249. #phpinfo  
  250. cat >$NGINX_ROOT/html/phpinfo.php<<eof  
  251. <?php  
  252. phpinfo();  
  253. ?>  
  254. eof  
  255. echo "phpinfo.php is creating ..."   
  256. echo "============================phpinfo.php writed================================="  
  257. echo "============================starting lnpp================================="  
  258.   
  259. PHP=$PHP_ROOT/sbin/php-fpm  
  260. NGINX=$NGINX_ROOT/sbin/nginx  
  261. PGDAEMON=$PG_ROOT/bin/postmaster  
  262. PGCTL=$PG_ROOT/bin/pg_ctl  
  263. PGUSER=postgres  
  264. PGDATA=$PG_ROOT/data  
  265. PGLOG=$PG_ROOT/logs/pgsql.log  
  266.   
  267. stop()  
  268. {  
  269.     echo "-------------stop php----------------"  
  270.     ps -e | grep $(basename $PHP) | {  
  271.       while read pid tty time cmd;  
  272.       do  
  273.         echo "killing $pid ==> $cmd"  
  274.         kill -9 $pid  
  275.       done  
  276.     }  
  277.   
  278.     echo "-------------stop nginx--------------"  
  279.         ps -e | grep $(basename $NGINX) | {  
  280.       while read pid tty time cmd;  
  281.       do  
  282.         echo "killing $pid ==> $cmd"  
  283.         kill -9 $pid  
  284.       done  
  285.     }  
  286.   
  287.    # killproc $NGINX -QUIT  
  288.   
  289.     echo "-------------stop pgsql--------------"  
  290. #    su  $PGUSER -c "$PGCTL stop -D '$PGDATA' -m fast"  
  291.         ps -e | grep $(basename $PGDAEMON) | {  
  292.       while read pid tty time cmd;  
  293.       do  
  294.         echo "killing $pid ==> $cmd"  
  295.         kill -9 $pid  
  296.       done  
  297.     }  
  298.    
  299.    echo "-------------stop pgsql--------------"  
  300. }  
  301.   
  302. start()  
  303. {  
  304.         echo "-------------start php---------------"  
  305.         $PHP  
  306.         echo "-------------php started ---------------"  
  307.         echo "-------------start nginx-------------"  
  308.         $NGINX  
  309.         echo "-------------nginx started---------------"  
  310.         echo "-------------start pgsql---------------"  
  311.         su  $PGUSER -c "$PGDAEMON -D '$PGDATA' &" >>$PGLOG 2>&1  
  312.         echo "-------------pgsql started---------------"  
  313. }  
  314.   
  315. stop  
  316. start  
  317. sleep 10  
  318.   
  319.         ps -C php-fpm  
  320.         ps -C nginx  
  321.         ps -C postmaster  
  322. echo "============================lnpp started================================="  
  323. exit 0  
linux
相关资讯       Nginx 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款