精力有限,只能暫時維護一個指令碼,於是把mysql 和 原來的lnpp統一在一起
php 5.4.10 + nginx1.0.15 + PostgreSQL 9.1.3 源碼編譯自動化部署第三版
http://blog.csdn.net/qzier_go/article/details/7462053
這次的指令碼在本人的機器上經過幾次測試,相容32位和64位的CentOS 5和6的系統,調整了一下一些第三方庫的安裝,並在安裝前會把前次編譯的資源清理乾淨,地址如下:
https://github.com/Qzi/lnmpp/blob/master/lnmpp-0.02-mysql_x86_64.sh
#!/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH# Check if user is rootif [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to install LNMPP" exit 1ficlearecho "========================================================================="echo "lnmpp install shell script for CentOS/RadHat Written by Qzi"echo "creatred in 2012/4/10"echo "last modified in 2012/7/2"echo "Email:i@qzier.com"echo "========================================================================="echo "========================================================================="echo "PHP Version: 5.4.4"echo "========================================================================="echo "========================================================================="echo "PostgreSQL Version: 9.1.4"echo "========================================================================="echo "========================================================================="echo "nginx Version: 1.2.1"echo "========================================================================="echo "========================================================================="echo "MySQL Version: 5.5.25"echo "========================================================================="echo "========================================================================="echo "CentOS Version: 6.2_x86_64"echo "========================================================================="# prepare for futurePHP_VERSION=php-5.4.4PG_VERSION=postgresql-9.1.4NGINX_VERSION=nginx-1.2.1MYSQL_VERSION=mysql-5.5.25LNMPP_SRC_ROOT=$(pwd)LNMPP_ROOT=/tmp/lnmpp/lnmpp-0.02PG_ROOT=$LNMPP_ROOT/pgsql/$PG_VERSIONPHP_ROOT=$LNMPP_ROOT/php/$PHP_VERSIONPHP_EXTRA_LIBS=$PHP_ROOT/3rdlibsNGINX_ROOT=$LNMPP_ROOT/nginx/$NGINX_VERSIONMYSQL_ROOT=$LNMPP_ROOT/mysql/$MYSQL_VERSIONif [ -d $LNMPP_ROOT ]; then echo "LNMPP will install in $LNMPP_ROOT"else echo "LNMPP is creating the directory $LNMPP_ROOT" mkdir -p $LNMPP_ROOTfi#for filename in $(rpm -aq|grep flex)#do# yum erase $filename# #yum erase $filename -y#done#for filename in $(rpm -aq|grep php)#do## yum erase $filename# yum erase $filename -y#doneecho "========================================================================="echo "install dependences"echo "========================================================================="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 readline-devel ;do yum -y install $packages; doneecho "============================check files=================================="if [ -s $PHP_VERSION.tar.gz ]; then echo "$PHP_VERSION.tar.gz [found]"else echo "Error: $PHP_VERSION.tar.gz not found!!!download now......" wget -c http://cn2.php.net/get/$PHP_VERSION.tar.gz/from/cn.php.net/mirror fiif [ -s libiconv-1.14.tar.gz ]; then echo "libiconv-1.14.tar.gz [found]"else echo "Error: libiconv-1.14.tar.gz not found!!!download now......" wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gzfiif [ -s pcre-8.21.tar.bz2 ]; then echo "pcre-8.21.tar.bz2 [found]"else echo "Error: pcre-8.21.tar.bz2 not found!!!download now......" wget http://downloads.sourceforge.net/project/pcre/pcre/8.21/pcre-8.21.tar.bz2fiif [ -s mcrypt-2.6.8.tar.gz ]; then echo "mcrypt-2.6.8.tar.gz [found]"else echo "Error: mcrypt-2.6.8.tar.gz not found!!!download now......" wget http://sourceforge.net/projects/mcrypt/files/latest/download?source=filesfiif [ -s mhash-0.9.9.9.tar.bz2 ]; then echo "mhash-0.9.9.9.tar.bz2 [found]"else echo "Error: mhash-0.9.9.9.tar.bz2 not found!!!download now......" wget http://sourceforge.net/projects/mhash/files/latest/download?source=filesfiif [ -s $PG_VERSION.tar.gz ]; then echo "$PG_VERSION.tar.gz [found]"else echo "Error: $PG_VERSION.tar.gz not found!!!download now......" wget http://ftp.postgresql.org/pub/source/v9.1.4/$PG_VERSION.tar.gz # !!!!!!!!!!!!!!!!!!!!!!!!fiif [ -s $NGINX_VERSION.tar.gz ]; then echo "$NGINX_VERSION.tar.gz [found]"else echo "Error: $NGINX_VERSION.tar.gz not found!!!download now......" wget http://nginx.org/download/$NGINX_VERSION.tar.gzfiif [ -s flex-2.5.35.tar.gz ]; then echo "flex-2.5.35.tar.gz [found]"else echo "Error: flex-2.5.35.tar.gz not found!!!download now......" wget http://sourceforge.net/projects/flex/files/flex/flex-2.5.35/flex-2.5.35.tar.gzfiif [ -s $MYSQL_VERSION.tar.gz ]; then echo "$MYSQL_VERSION.tar.gz is [found]"else echo "Error: $MYSQL_VERSION.tar.gz not found!!!download now......" wget -c http://downloads.mysql.com/archives/mysql-5.5/$MYSQL_VERSION.tar.gzfiif [ -s cmake-2.8.7.tar.gz ]; then echo "cmake-2.8.7.tar.gz is [found]"else echo "Error: cmake-2.8.7.tar.gz not found!!!download now......" wget -c http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz fiif [ -s libmcrypt-2.5.8.tar.gz ]; then echo "libmcrypt-2.5.8.tar.gz is [found]"else echo "Error: libmcrypt-2.5.8.tar.gz not found!!!download now......" wget -c http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gzfiif [ -s re2c-0.13.5.tar.gz ]; then echo "re2c-0.13.5.tar.gz is [found]"else echo "Error: re2c-0.13.5.tar.gz not found!!!download now......" wget -c http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gzfi# centos 6##repoforge's rpm#wget http://pkgs.repoforge.org/libmcrypt/libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm#wget http://pkgs.repoforge.org/libmcrypt/libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpm#rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt#rpm -K libmcrypt*.rpm#rpm -iv libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm#rpm -iv libmcrypt-devel-2.5.7-1.2.el6.rf.x86_64.rpmecho "============================check complete=================================="echo "============================postgresql install=================================="#install flexcd $LNMPP_SRC_ROOT $(pwd)tar -zxvf flex-2.5.35.tar.gzcd flex-2.5.35make uninstallmake clean./configure -qmakemake installcd ../tar -zxvf $PG_VERSION.tar.gzif [ $(id -nu postgres) == "postgres" ]; then echo "user postgres is found ... "else echo "creating the user called 'postgres'" su - -c "useradd -M postgres"fichown -R postgres:postgres $PG_VERSIONmkdir -p $PG_ROOTmkdir -p $PG_ROOT/etc cd $LNMPP_SRC_ROOT/$PG_VERSION/make uninstallmake clean./configure --prefix=$PG_ROOT #--sysconfdir=$PG_ROOT/etcmakemake installif [ -d $PG_ROOT/data/ ]; then mv $PG_ROOT/data/ $PG_ROOT/data.bak/ mkdir -p $PG_ROOT/data/else mkdir -p $PG_ROOT/datafiif [ -d $PG_ROOT/logs/ ]; then# rm $PG_ROOT/logs/* -rf mv $PG_ROOT/logs/ $PG_ROOT/logs.bak/ mkdir -p $PG_ROOT/logs/else mkdir -p $PG_ROOT/logs/fi#touch $PG_ROOT/logs/pgsql.logchown -R postgres:postgres $PG_ROOT/datachown -R postgres:postgres $PG_ROOT/logs#usermod -G $(id -nu) postgres#gpasswd -A postgres $(id -un) # previllege for current usersu postgres -c "/tmp/lnmpp/lnmpp-0.02/pgsql/postgresql-9.1.4/bin/initdb --pgdata=/tmp/lnmpp/lnmpp-0.02/pgsql/postgresql-9.1.4/data --encoding=UNICODE --username=postgres --xlogdir=/tmp/lnmpp/lnmpp-0.02/pgsql/postgresql-9.1.4/logs/ --auth=trust && exit" # enable local trust##su postgres -c "$PG_ROOT/bin/pg_resetxlog -f $PG_ROOT/data && exit"$(pwd)echo "============================postgresql complete=================================="echo "============================mysql install=================================="cd $LNMPP_SRC_ROOTmkdir -p $LNMPP_ROOT/cmake/cmake-2.8.7tar -zxvf cmake-2.8.7.tar.gzcd cmake-2.8.7./bootstrap --prefix=$LNMPP_ROOT/cmake/cmake-2.8.7make make install cd ../if [ $(id -nu mysql) == "mysql" ]; then echo "user mysql is found ... "else echo "creating the user called 'mysql'" su - -c "useradd -M mysql -s /sbin/nologin"fimkdir -p $MYSQL_ROOT/etcmkdir -p $MYSQL_ROOT/datamkdir -p $MYSQL_ROOT/run$(pwd)tar -zxvf $MYSQL_VERSION.tar.gzcd $MYSQL_VERSIONmake uninstallmake cleanrm -f CMakeCache.txt$LNMPP_ROOT/cmake/cmake-2.8.7/bin/cmake \ -DCMAKE_INSTALL_PREFIX=$MYSQL_ROOT \ -DMYSQL_DATADIR=$MYSQL_ROOT/data \ -DSYSCONFDIR=$MYSQL_ROOT/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DMYSQL_USER=mysql \ -DMYSQL_TCP_PORT=3306 makemake installcp support-files/my-small.cnf $MYSQL_ROOT/etc/my.cnf#chmod 755 $MYSQL_ROOT/scripts/mysql_install_dbchown -R mysql:mysql $MYSQL_ROOT$MYSQL_ROOT/scripts/mysql_install_db --user=mysql --basedir=$MYSQL_ROOT --datadir=$MYSQL_ROOT/data --pid-file=$MYSQL_ROOT/run/mysqld.pid --log-error=$MYSQL_ROOT/run/mysqld.log --socket=$MYSQL_ROOT/run/mysqld.sock#chmod +x /etc/init.d/mysqld#cp support-files/mysql.server /etc/init.d/mysqldecho "============================mysql complete=================================="echo "============================php install=================================="cd $LNMPP_SRC_ROOTmkdir -p $PHP_EXTRA_LIBStar -zxf libiconv-1.14.tar.gzcd libiconv-1.14make uninstallmake clean./configuremakemake installcd ../tar -zvxf re2c-0.13.5.tar.gzcd re2c-0.13.5make uninstallmake clean./configuremakemake installcd ../tar -jxf mhash-0.9.9.9.tar.bz2cd mhash-0.9.9.9make uninstallmake clean./configuremakemake installcd ../tar -zvxf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8make uninstallmake clean./configuremakemake installcd ../tar -zxvf mcrypt-2.6.8.tar.gzcd mcrypt-2.6.8make uninstallmake clean./configure --prefix=$PHP_EXTRA_LIBS/mcrypt-2.6.8 --with-libiconv-prefix=$PHP_EXTRA_LIBS/libiconv-1.14/ --with-libmcrypt-prefix=/usr/local/libmakemake installcd ../tar -jxf pcre-8.21.tar.bz2cd pcre-8.21make uninstallmake clean./configure --prefix=$PHP_EXTRA_LIBS/pcre-8.21/makemake installcd ../mkdir -p $PHP_ROOT tar -zxvf $PHP_VERSION.tar.gz cd $PHP_VERSIONmake uninstallmake clean./configure --prefix=$PHP_ROOT --with-config-file-path=$PHP_ROOT/etc/ --with-mysql=$MYSQL_ROOT --with-pdo-mysql=$MYSQL_ROOT --with-pgsql=$PG_ROOT --with-pdo-pgsql=$PG_ROOT --with-iconv=/usr/local --with-pcre-dir=$PHP_EXTRA_LIBS/pcre-8.21 --enable-fpm --with-pear --with-gd --enable-gd-native-ttf --with-freetype-dir=/usr --with-zlib --enable-mbstring --with-curl --with-openssl --with-mhash=/usr/local --with-mcrypt=$PHP_EXTRA_LIBS/mcrypt-2.6.8make make installcp ./php.ini-production $PHP_ROOT/etc/php.inicp $PHP_ROOT/etc/php-fpm.conf.default $PHP_ROOT/etc/php-fpm.confcd ../echo "============================php complete================================="echo "============================nginx install================================="mkdir -p $NGINX_ROOTtar -zxvf $NGINX_VERSION.tar.gzcd $NGINX_VERSIONif [ $(id -nu nginx) == "nginx" ]; then echo "user nginx is found ... "else echo "creating the user called 'nginx'" su - -c "useradd -M nginx"fimake clean./configure --user=nginx --group=nginx --prefix=$NGINX_ROOT --with-http_ssl_module --with-pcre=$LNMPP_SRC_ROOT/pcre-8.21 --with-ipv6makemake installcd ../cp $NGINX_ROOT/conf/nginx.conf $NGINX_ROOT/conf/nginx.conf.bak2cat $NGINX_ROOT/conf/nginx.conf | sed -e '65,72s/^ #/ /g'| \ sed -e 's/\/scripts$fastcgi_script_name;/$document_root$fastcgi_script_name;/g' > $NGINX_ROOT/conf/nginx.conf.bakcp -f $NGINX_ROOT/conf/nginx.conf.bak $NGINX_ROOT/conf/nginx.confecho "============================nginx complete================================="echo "============================phpinfo in /nginx/html================================="#phpinfocat >$NGINX_ROOT/html/phpinfo.php<<eof<?phpphpinfo();?>eofecho "phpinfo.php is creating ..." echo "============================phpinfo.php writed================================="echo "============================starting LNMPP================================="PHP=$PHP_ROOT/sbin/php-fpmNGINX=$NGINX_ROOT/sbin/nginxPGDAEMON=$PG_ROOT/bin/postmasterPGCTL=$PG_ROOT/bin/pg_ctlPGUSER=postgresPGDATA=$PG_ROOT/dataPGLOG=$PG_ROOT/logs/pgsql.logMYSQL_ROOT=$LNMPP_ROOT/mysql/$MYSQL_VERSIONMYSQLDAEMON=$LNMPP_ROOT/mysql/$MYSQL_VERSION/bin/mysqld_safestop(){ echo ">>> stop php----------------" ps -e | grep $(basename $PHP) | { while read pid tty time cmd; do echo "killing $pid ==> $cmd" kill -9 $pid done } echo ">>> stop nginx--------------" ps -e | grep $(basename $NGINX) | { while read pid tty time cmd; do echo "killing $pid ==> $cmd" kill -9 $pid done } echo ">>> stop pgsql--------------" ps -e | grep $(basename $PGDAEMON) | { while read pid tty time cmd; do echo "killing $pid ==> $cmd" kill -9 $pid done } echo ">>> stop mysql--------------" killall mysqld sleep 7}start(){ echo ">>> start php---------------" $PHP echo ">>> php started ------------" echo ">>> start nginx-------------" $NGINX echo ">>> nginx started-----------" echo ">>> start pgsql-------------" touch $PGLOG su $PGUSER -c "$PGDAEMON -D '$PGDATA' &" >>$PGLOG 2>&1 echo ">>> pgsql started-----------" echo ">>> start mysql-------------" $MYSQLDAEMON --user=mysql --basedir=$MYSQL_ROOT --datadir=$MYSQL_ROOT/data --pid-file=$MYSQL_ROOT/run/mysqld.pid --log-error=$MYSQL_ROOT/run/mysqld.log --socket=$MYSQL_ROOT/run/mysqld.sock & echo ">>> mysql started-----------" sleep 7}stopstartps -C php-fpmps -C nginxps -C postmasterps -C mysqldps -C mysqld_safeecho "============================LNMPP started================================="exit 0
linux + php + c + 營運
QQ群:213572677