#######################################################################################
成都创新互联公司是一家专注于网站建设、成都做网站与策划设计,和田县网站建设哪家好?成都创新互联公司做网站,专注于网站建设十多年,网设计领域的专业建站公司;建站业务涵盖:和田县等地区。和田县做网站价格咨询:18980820575
#!bin/sh #
#AUTHOR:yuhonggang #
#TIME:2014/10/13 17:26 #
#DESCRIBE:the script is used for create the lnmp just by one touch #
#VERSION:V1.0 #
#######################################################################################
TOOLS=/home/yuhonggang/tools
APP=/application
#######INSTALL NGINX#################################################################
echo -e "\033[32;45;5m#######INSTALL NGINX###################################\033[0m"
sleep 2
if [ -d $TOOLS ];then
cd $TOOLS
else
mkdir -p $TOOLS && cd $TOOLS
fi
if [ -d $APP ];then
echo "$APP is exsit"
else
mkdir $APP && echo "$APP has ben created"
fi
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
wget http://fossies.org/linux/misc/pcre-8.36.tar.gz
yum install gcc-c++ openssl* -y
tar zxf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
if [ $? = 0 ]
then
echo "pcre install is successful"
else
echo "pcre install is fail" && exit 2
sleep 5
fi
cd $TOOLS
sleep 5
wget http://nginx.org/download/nginx-1.2.9.tar.gz
useradd nginx -s /sbin/nologin -M
tar xf nginx-1.2.9.tar.gz
cd nginx-1.2.9
./configure --user=nginx --group=nginx --prefix=$APP/nginx-1.2.9 --with-http_stub_status_module --with-http_ssl_module
make && make install
if [ $? = 0 ]
then
echo "nginx install is successful"
else
echo "nginx install is fail" && exit 2
sleep 5
fi
cd $TOOLS
ln -s $APP/nginx-1.2.9 $APP/nginx
echo "/usr/local/lib/" >> /etc/ld.so.conf
ldconfig
$APP/nginx/sbin/nginx -t
$APP/nginx/sbin/nginx
lsof -i tcp:80
if [ $? = 0 ]
then
echo "nginx install all is successful"
else
echo "nginx install all is fail" && exit 2
sleep 5
fi
cd $TOOLS
#######INSTALL MySQL################################################################
echo -e "\033[32;45;5m#######INSTALL MYSQL###################################\033[0m"
sleep 5
cd $TOOLS
sleep 3
wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
gmake && gmake install
if [ $? = 0 ]
then
echo "nginx cmake is successful"
else
echo "nginx cmake is fail" && exit 2
sleep 5
fi
cd $TOOLS
useradd mysql -s /sbin/nologin -M
yum install ncurses-devel -y
sleep 2
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.12.tar.gz
tar xf mysql-5.6.12.tar.gz
cd mysql-5.6.12
cmake . -DCMAKE_INSTALL_PREFIX=$APP/mysql-5.6.12 \
-DMYSQL_DATADIR=$APP/mysql-5.6.12/data \
-DMYSQL_UNIX_ADDR=$APP/mysql-5.6.12/tmp/mysql.sock \
-DDEFAULT_CHARSET=gbk \
-DDEFAULT_COLLATION=gbk_chinese_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
make && make install
if [ $? = 0 ]
then
echo "mysql install is successful"
else
echo "mysql install is fail" && exit 2
fi
sleep 5
ln -s $APP/mysql-5.6.12/ $APP/mysql
cp support-files/my-default.cnf /etc/my.cnf
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
sleep 2
. /etc/profile
mkdir -p $APP/mysql/data/
chown -R mysql.mysql $APP/mysql/*
chmod -R 1777 /tmp
sleep 2
$APP/mysql/scripts/mysql_install_db --basedir=$APP/mysql --datadir=$APP/mysql/data/ --user=mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
/etc/init.d/mysqld start
chkconfig mysqld on
if [ $? = 0 ]
then
echo "mysql install all is successful"
else
echo "mysql install all is fail" && exit 2
fi
sleep 5
#######INSTALL PHP##################################################################
echo -e "\033[32;45;5m#######INSTALL PHP###################################\033[0m"
sleep 5
cd $TOOLS
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel libxslt-devel -y
sleep 2
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
sleep 2
cd $TOOLS
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
sleep 2
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
sleep 2
cd $TOOLS
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
sleep 2
cd $TOOLS
rm -f /usr/lib64/libmcrypt.*
rm -f /usr/lib64/libmhash*
ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
yum install libxslt libxslt-devel -y
sleep 2
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install
sleep 2
cd $TOOLS
ln -s $APP/mysql/lib/libmysqlclient.so.18 /usr/lib
ldconfig
wget http://cn2.php.net/distributions/php-5.3.29.tar.gz
tar xf php-5.3.29.tar.gz
cd php-5.3.29
./configure --prefix=$APP/php5.3.29 --with-mysql=$APP/mysql --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp
cp ext/phar/phar.php ext/phar/phar.phar
make && make install
sleep 2
ln -s $APP/php5.3.29/ $APP/php
cd $TOOLS/php-5.3.29
cp php.ini-production $APP/php/lib/php.ini
mv $APP/php5.3.29/etc/php-fpm.conf.default $APP/php5.3.29/etc/php-fpm.conf
$APP/php/sbin/php-fpm
if [ $? = 0 ]
then
echo "php install is successful"
else
echo "php install is fail" && exit 2
fi
sleep 5
#######INSTALL PhpCacheModule#################################################################
echo -e "\033[32;45;5m#######INSTALL PhpCacheModule###################################\033[0m"
sleep 5
echo 'export LC_ALL=C' >>/etc/profile
tail -1 /etc/profile
. /etc/profile
yum install perl-devel -y
cd $TOOLS
#install eaccelerator
sleep 2
wget http://soft.kwx.gd/module/eaccelerator-0.9.6.tar.bz2
tar jxf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6
$APP/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$APP/php/bin/php-config
make && make install
[ $? -ne 0 ] && {
echo "install eaccelerator failed!"
exit 2
}
cd ../
sleep 2
#install memcache
wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5
$APP/php/bin/phpize
./configure --with-php-config=$APP/php/bin/php-config
make && make install
[ $? -ne 0 ] && {
echo "install memcache failed!"
exit 2
}
cd ../
sleep 2
#install PDO_MYSQL
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar zxf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2
$APP/php/bin/phpize
./configure --with-php-config=$APP/php/bin/php-config --with-pdo-mysql=$APP/mysql
make && make install
[ $? -ne 0 ] && {
echo "install PDO_MYSQL failed!"
exit 2
}
cd ../
#install ImageMagick
sleep 5
wget http://down1.chinaunix.net/distfiles/ImageMagick-6.5.1-0.tar.bz2
tar jxf ImageMagick-6.5.1-0.tar.bz2
cd ImageMagick-6.5.1-0
./configure
make
make install
[ $? -ne 0 ] && {
echo "install ImageMagick failed!"
exit 2
}
cd ../
sleep 2
#install imagick php
wget http://pecl.php.net/get/imagick-2.3.0.tgz
tar zxf imagick-2.3.0.tgz
cd imagick-2.3.0
$APP/php/bin/phpize
./configure --with-php-config=$APP/php/bin/php-config
make
make install
[ $? -ne 0 ] && {
echo "install imagick php failed!"
exit 2
}
cd ../
sleep 2
cd $APP/php/lib/
cp php.ini php.ini_$(date +%F)
sed -i 's#; extension_dir = "./"#extension_dir = "/application/php/lib/php/extensions/no-debug-non-zts-20090626/"#g' php.ini
cat >> $APP/php/lib/php.ini< extension = memcache.so extension = pdo_mysql.so extension = imagick.so EOF #config eaccelerator mkdir -p /tmp/eaccelerator chown -R nginx.nginx /tmp/eaccelerator cat >>$APP/php/lib/php.ini< [eaccelerator] extension = eaccelerator.so eaccelerator.shm_size="64" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="3600" eaccelerator.shm_prune_period="3600" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" EOF sleep 1 echo "=====================================" $APP/php/bin/php -v [ $? -eq 0 ] && echo "Config php cache module sucessful" || exit 2 echo "====================================="
当前标题:一键lnmp脚本&&php扩展模块安装(适用于CENTOS6.X系列)
当前链接:http://cdxtjz.com/article/johosi.html