简单LNMP安装脚本

boxifeng 2011-03-02

#!/bin/bash
#LNMP install script
#Create by wellpan
#20110109

#time sys
yum install ntp -y
ntpdate 210.72.145.44
hwclock -w
yum install -y gcc gcc-c++ make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel patch libmcrypt-devel libmhash-devel ncurses-devel
IN_SRC=/usr/local/src
IN_LOG=${IN_SRC}/lmap_install.log
IN_DIR=/usr/local

#install
echo "installing mysql...."
useradd -d /dev/null -s /sbin/nologin mysql >&2 > /dev/null
cd $IN_SRC
tar -zxvf mysql-5.1.53.tar.gz  >> $IN_LOG 2>&1
cd mysql-5.1.53/
./configure --prefix=$IN_DIR/mysql --with-extra-charsets=all --enable-thread-safe-client >>$IN_LOG 2>&1
make    >> $IN_LOG 2>&1
make install    >> $IN_LOG 2>&1
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
cd $IN_DIR/mysql
$IN_DIR/mysql/bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
echo "$IN_DIR/mysql/lib/mysql" >> /etc/ld.so.conf
ldconfig
echo "export PATH=$PATH:$IN_DIR/mysql/bin" >> /etc/profile
source /etc/profile
/etc/init.d/mysqld start
$IN_DIR/mysql/bin/mysqladmin -u root password "123456"

echo "pcre installing..."
cd $IN_SRC
tar zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install

echo "installing nginx..."
useradd -d /dev/null -s /sbin/nologin www    >&2 > /dev/null
cd $IN_SRC
tar zxvf nginx-0.8.53.tar.gz
cd nginx-0.8.53
./configure --user=www --group=www --prefix=$IN_DIR/nginx --with-http_stub_status_module --with-http_ssl_module
make
make install

echo "installing php...."
cd $IN_SRC
tar zxvf php-5.2.16.tar.gz >> $IN_LOG 2>&1
gzip -cd php-5.2.16-fpm-0.5.14.diff.gz | patch -fd php-5.2.16 -p1 >> $IN_LOG 2>&1
cd php-5.2.16/
./configure --prefix=$IN_DIR/php  --with-mysql=$IN_DIR/mysql  --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-fastcgi --enable-fpm >> $IN_LOG 2>&1
make    >> $IN_LOG 2>&1
make install    >> $IN_LOG 2>&1
cp php.ini-dist  $IN_DIR/php/lib/php.ini

相关推荐