一键安装lnmp(2)

all(){
path=`pwd`
cd $pathecho
echo "exclude=*.i386 *.i686" >> /etc/yum.conf
rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum listyum update -y
sleep 20;
#######检查命令是否执行正常##############################
if [ $? -eq 0 ];
    then
        echo "``````Update complete``````````"
    else    
    exit 1    
    echo"```````failure```````"
fi
sleep 15;
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel
libidn libidn-devel openssl openssl-devel
openldap openldap-devel nss_ldap
openldap-clients openldap-servers yasm pcre libmcrypt libvpx tiff jpegsrc t1lib
===============================================================================
cd $path
tar zxvf cmake-2.8.11.2.tar.gz
cd cmake-2.8.11.2
./configure
make
make install
cd ..
tar zxvf mysql-5.5.18.tar.gz
cd mysql-5.5.18
yum install -y autoconf automake imake libxml2-devel expat-devel gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses-devel
mkdir -p /data/mysql-5.5.18
mkdir -p /data/mysql_log
mkdir -p /data/log-bin
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
chown -R mysql.mysql /data/mysql-5.5.18/ /data/mysql_log/ /data/log-bin/
mkdir -p /usr/local/mysql-5.5.18
chown -R mysql.mysql /usr/local/mysql-5.5.18
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.18 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql-5.5.18/data -DMYSQL_USER=mysql
make
make install
chown -R mysql:mysql /usr/local/mysql-5.5.18/
rm -rf /etc/my.cnf
cp support-files/my-small.cnf /etc/my.cnf
chown mysql:mysql /etc/my.cnf
cp $path/mysqld /etc/rc.d/init.d/mysqld
chown -R mysql:mysql /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
ln -s /usr/local/mysql-5.5.18/bin/mysql /usr/bin
/usr/local/mysql-5.5.18/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.18 --datadir=/data/mysql-5.5.18/data
chmod +x mysql_install_db
sed -i '/[mysqld]/adatadir=/usr/local/mysql-5.5.18/data/' /etc/my.cnf
/usr/local/mysql-5.5.18/scripts/mysql_install_db --basedir=/usr/local/mysql-5.5.18 --datadir=/usr/local/mysql-5.5.18/data --user=mysql
/etc/init.d/mysqld start
/usr/local/mysql-5.5.18/bin/mysqladmin -uroot  password 123qwe
####################################################################################
cd $path
tar zxvf pcre-8.20.tar.gz
cd pcre-8.20
./configure --prefix=/usr/local/pcre
make
make install
cd $path
tar zxvf openssl-1.0.0a.tar.gz
cd openssl-1.0.0a./config --prefix=/usr/local/openssl
make
make install
cd $path
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3./configure -prefix=/usr/local/zlib
make
make install
####nginx的安装
cd $path
groupadd www
useradd www -g mysql -M -s /sbin/nologin
tar zxvf nginx-1.1.7.tar.gz
cd nginx-1.1.7
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=$path/openssl-1.0.0a --with-zlib=$path/zlib-1.2.3 --with-pcre=$path/pcre-8.20
make
make install
rm -rf /usr/local/nginx/conf/nginx.conf
cp $path/nginx.conf /usr/local/nginx/conf/nginx.conf
###################################################
cd $path
tar zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0.tar.gz
./configure
make
make install
cd $path
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make
make install
cd $path
tar jxvf libvpx-1.4.0.tar.bz2
cd libvpx-1.4.0
./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
make
make install
cd $path
tar zxvf tiff-4.0.3.tar.gz
cd tiff-4.0.3
./configure --prefix=/usr/local/tiff --enable-shared
make
make instal
cd $path
tar zxvf libpng-1.5.6.tar.gz
cd libpng-1.5.6
./configure --prefix=/usr/local/libpng --enable-shared
make
make install
cd $path
tar zxvf freetype-2.4.8.tar.gz
cd freetype-2.4.8
./configure --prefix=/usr/local/freetype --enable-shared
make
make install
cd $path
tar zxvf jpegsrc.v8c.tar.gz
cd jpeg-8c
./configure --prefix=/usr/local/jpeg --enable-shared
make
make install
cd $path
tar zxvf t1lib-5.1.2.tar.gz
cd t1lib-5.1.2
./configure --prefix=/usr/local/t1lib --enable-shared
make without_doc
cp -frp /usr/lib64/libltdl.so* /usr/lib/
yum -y install libXpm
cd $path
tar zxvf php-5.5.24.tar.gz
cd php-5.5.24
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql-5.5.18 --with-mysqli=/usr/local/mysql-5.5.18/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql-5.5.18 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype
make
make install
cp $path/php.ini /usr/local/php/etc/php.ini
rm -rf /etc/php.ini
mv php-fpm.conf /usr/local/php/etc/
ln -s /usr/local/php/etc/php.ini /etc/php.ini
ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
cp $path/php-5.5.24/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig php-fpm on
}

原文地址:https://www.cnblogs.com/zclzhao/p/4936912.html