简单LAMP安装脚本

#!/bin/bash
#LAMP install script
#Create by wellpan
#安装软件放在/usr/local/src目录下,针对系统全新安装情况下

#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 "installing httpd...."
cd $IN_SRC
tar zxvf httpd-2.2.17.tar.gz >> $IN_LOG 2>&1
cd httpd-2.2.17/
./configure --prefix=$IN_DIR/apache2 --with-included-apr --enable-so --enable-deflate=shared  --enable-expires=shared --enable-rewrite=shared --enable-static-support >> $IN_LOG 2>&1
make    >> $IN_LOG 2>&1
make install    >> $IN_LOG 2>&1
$IN_DIR/apache2/bin/apachectl start

echo "installing php...."
cd $IN_SRC
tar zxvf php-5.2.16.tar.gz >> $IN_LOG 2>&1
cd php-5.2.16/
./configure --prefix=$IN_DIR/php --with-apxs2=$IN_DIR/apache2/bin/apxs --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 >> $IN_LOG 2>&1
make    >> $IN_LOG 2>&1
make install    >> $IN_LOG 2>&1
cp php.ini-production  $IN_DIR/php/lib/php.ini
echo "AddType application/x-httpd-php .php" >> $IN_DIR/apache2/conf/httpd.conf
$IN_DIR/apache2/bin/apachectl restart

相关推荐