#!/bin/bash
install_path=/usr/local/lnmpserv-1.1.5
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$install_path/deps/bin
export PATH
check_download() {
if [ -s $1 ]; then
echo "$1 [found]"
else
echo "Error: $1 not found!!!download now......"
wget -c $2
fi
}
echo "============================check files=================================="
if [ ! -d "src" ]; then
mkdir src
fi
if [ ! -d "build" ]; then
mkdir build
fi
cd src
check_download pcre-8.12.tar.gz http://ftp.exim.llorien.org/pcre/pcre-8.12.tar.gz
check_download zlib-1.2.5.tar.gz http://zlib.net/zlib-1.2.5.tar.gz
check_download openssl-1.0.0d.tar.gz http://www.openssl.org/source/openssl-1.0.0d.tar.gz
check_download nginx-1.1.13.tar.gz http://nginx.org/download/nginx-1.1.13.tar.gz
check_download libiconv-1.13.1.tar.gz http://soft.vpser.net/web/libiconv/libiconv-1.13.1.tar.gz
check_download libmcrypt-2.5.8.tar.gz http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
check_download mcrypt-2.6.8.tar.gz http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz
check_download mhash-0.9.9.9.tar.gz http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz
check_download jpegsrc.v7.tar.gz http://www.ijg.org/files/jpegsrc.v7.tar.gz
check_download libpng-1.5.7.tar.gz http://sourceforge.net/projects/libpng/files/libpng15/1.5.7/libpng-1.5.7.tar.gz/download
check_download freetype-2.4.5.tar.gz http://download.savannah.gnu.org/releases/freetype/freetype-2.4.5.tar.gz
check_download curl-7.24.0.tar.gz http://curl.haxx.se/download/curl-7.24.0.tar.gz
check_download libxml2-2.7.8.tar.gz http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz
check_download php-5.3.10.tar.gz http://www.php.net/distributions/php-5.3.10.tar.gz
check_download memcache-3.0.6.tgz http://pecl.php.net/get/memcache-3.0.6.tgz
check_download APC-3.1.9.tgz http://pecl.php.net/get/APC-3.1.9.tgz
check_download mysql-5.5.20.tar.gz http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.20.tar.gz/from/http://mysql.he.net/
echo "==============================build======================================"
cd ../build/
#:<<\EOF
###build requirement libs
tar zxvf ../src/pcre-8.12.tar.gz
cd pcre-8.12
./configure --prefix=$install_path/deps
make && make install
cd ..
tar zxvf ../src/zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure --prefix=$install_path/deps
echo "./configure --prefix=$install_path/deps"
make && make install
cd ..
tar zxvf ../src/openssl-1.0.0d.tar.gz
cd openssl-1.0.0d/
./config --prefix=$install_path/deps --openssldir=$install_path/deps/ssl
make && make install
cd ../
tar zxvf ../src/libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=$install_path/deps
make && make install
cd ../
tar zxvf ../src/libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure --prefix=$install_path/deps
make && make install
cd libltdl
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf ../src/mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure --prefix=$install_path/deps
make && make install
cd ../
ln -s /usr/local/lnmpserv/deps/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lnmpserv/deps/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lnmpserv/deps/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lnmpserv/deps/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lnmpserv/deps/bin/libmcrypt-config /usr/bin/libmcrypt-config
export LD_LIBRARY_PATH=/usr/local/lnmpserv/deps/lib/
export LDFLAGS="-L/usr/local/lnmpserv/deps/lib/ -I/usr/local/lnmpserv/deps/include/"
export CFLAGS="-I/usr/local/lnmpserv/deps/include/"
tar zxvf ../src/mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure --prefix=$install_path/deps --with-libmcrypt-prefix=/usr/local/lnmpserv/deps/
make && make install
cd ../
tar zxvf ../src/libxml2-2.7.8.tar.gz
cd libxml2-2.7.8/
./configure --prefix=$install_path/deps
make && make install
cd ../
下载这两个文件到src目录下
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.4.3.tar.gz
tar zxvf ../src/cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
gmake
gmake install
cd ../
tar zxvf ../src/bison-2.4.3.tar.gz
cd bison-2.4.3
./configure
make
make install
cd ../
tar zxvf ../src/curl-7.24.0.tar.gz
cd curl-7.24.0/
./configure --prefix=$install_path/deps --with-ssl=$install_path/deps --disable-file --without-pic --disable-shared
make && make install
cd ../
tar zxvf ../src/jpegsrc.v7.tar.gz
cd jpeg-7/
./configure --prefix=$install_path/deps --enable-static --enable-shared
ln -s `which libtool` libtool
make && make install
cd ../
tar zxvf ../src/libpng-1.5.7.tar.gz
cd libpng-1.5.7/
./configure --prefix=$install_path/deps --with-zlib-prefix=$install_path/deps
make && make install
cd ../
tar zxvf ../src/freetype-2.4.5.tar.gz
cd freetype-2.4.5/
./configure --prefix=$install_path/deps
make && make install
cd ../
###build nginx
tar zxvf ../src/nginx-1.1.13.tar.gz
cd nginx-1.1.13
./configure --user=www --group=www --prefix=$install_path/nginx \
--with-http_stub_status_module --with-http_ssl_module --with-openssl=../openssl-1.0.0d \
--with-pcre=../pcre-8.12 --with-zlib=../zlib-1.2.5
make && make install
cd ../
#
#build php
#
tar zxvf ../src/php-5.3.10.tar.gz
cd php-5.3.10
./configure --prefix=$install_path/php \
--with-config-file-path=$install_path/php/etc \
--with-config-file-scan-dir=$install_path/php/etc/php.d \
--exec-prefix=$install_path/php \
--sysconfdir=$install_path/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-freetype-dir=$install_path/deps \
--with-jpeg-dir=$install_path/deps \
--with-png-dir=$install_path/deps \
--with-zlib-dir=$install_path/deps \
--with-libxml-dir=$install_path/deps \
--with-openssl=$install_path/deps \
--with-curl=$install_path/deps \
--with-mcrypt=$install_path/deps \
--with-iconv-dir=$install_path/deps \
--with-mhash=$install_path/deps \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--without-pdo-sqlite \
--with-mysql-sock=/tmp/mysql.sock \
--enable-xml \
--enable-ftp \
--enable-shmop \
--enable-sysvsem \
--enable-bcmath \
--enable-mbstring \
--enable-sockets \
--enable-zip \
--enable-soap \
--with-xmlrpc
ln -s /usr/local/lib/libltdl.so.3 /usr/lib/libltdl.so.3
出现了cp: cannot stat `ext/phar/phar.phar': No such file or directory
于是我又: cd ext/phar/
ls -l
结果发现没有phar.phar 这个文件!!于是我怀疑是phar.php ,
cp ./phar.php ./phar.phar
make ZEND_EXTRA_LIBS='-liconv' && make install
cd ../
yum install
zlib
-devel
tar zxvf ../src/memcache-3.0.6.tgz
cd memcache-3.0.6/
$install_path/php/bin/phpize
./configure --with-php-config=$install_path/php/bin/php-config
make && make install
cd ../
tar zxvf ../src/APC-3.1.9.tgz
cd APC-3.1.9/
$install_path/php/bin/phpize
./configure --with-php-config=$install_path/php/bin/php-config
make && make install
cd ../
yum install ncurses-devel
cd ../
echo "==============================config======================================"
cp ./config/nginx.conf $install_path/nginx/conf/
mkdir $install_path/nginx/htdocs
groupadd www
useradd -s /sbin/nologin -M -g www www
chown -R www.www $install_path/nginx/htdocs
cp -r ./config/php* $install_path/php/etc/
sed -i "s/#INSTALL_PATH#/$install_path/g" $install_path/php/etc/php.ini
if [ ! -d "$install_path/scripts" ]; then
mkdir $install_path/scripts
fi
cp -r ./scripts/* $install_path/scripts/
rm -rf build/*
注释:
install_path=/usr/local/lnmpserv-1.1.5
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$install_path/deps/bin
export PATH
功能说明:设置或显示环境变量。
语 法:export [-fnp][变量名称]=[变量设置值]
补充说明:在shell中执行程序时,shell会提供一组环境变量。export可新增,修改或删除环境变量,供后续执行的程序使用。export的效力仅及于该此登陆操作。
参 数:
-f 代表[变量名称]中为函数名称。
-n 删除指定的变量。变量实际上并未删除,只是不会输出到后续指令的执行环境中。
-p 列出所有的shell赋予程序的环境变量。
wget的使用形式是: wget [参数列表] URL
-c:断点续传,这也是个非常有用的设置,特别当下载比较大的文件的时候,如果中途意外中断,那么连接恢复的时候会从上次没传完的地方接着传,而不是又从头开始,使用这一项需要远程服务器也支持断点续传,一般来讲,基于UNIX/Linux的Web/FTP服务器 都支持断点续传;