前一段自己写了个全自动配置php、mysql、nginx的脚本,也是为了配置服务的方便,有些变量是根据自己的环境来配置的。
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# this program found nginx php mysql Automate
#install package path
install_dir=/home/sysadmin/tools/install_soft
#php_Compile
bianyi_php="configure --prefix=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf \
--with-zlib-dir=/usr/lib --with-png-dir=/usr/lib \
--with-freetype-dir=/usr/include/freetype2 --with-ttf \
--enable-sockets --enable-ftp --enable-mbstring \
--enable-fastcgi --enable-force-cgi-redirect"
#nginx_Compile
bianyi_nginx="configure \
--user=nobody \
--group=nobody \
--prefix=/usr/local/nginx \
--with-http_stub_status_module"
#install package name
mysql_name=mysql-5.1.22-rc-linux-i686-icc-glibc23.tar.gz
php_name=php-5.2.4.tar.bz2
pcre_name=pcre-7.2.tar.gz
nginx_name=nginx-0.5.35.tar.gz
#SFX name
mysql_SFX_name=mysql-5.1.22-rc-linux-i686-icc-glibc23
php_SFX_name=php-5.2.4
pcre_SFX_name=pcre-7.2
nginx_SFX_name=nginx-0.5.35
#nginx configuration File path
nginx_configuration=/home/sysadmin/tools/nginx/
########################################################################
install mysql
########################################################################
cd $install_dir
groupadd mysql
useradd -g mysql mysql
tar -zxvf $mysql_name
if [ -d $install_dir/$mysql_SFX_name ]
then
cp -a ./$mysql_SFX_name /usr/local/mysql
else
exit
fi
cd /usr/local/
chown -R mysql:mysql mysql
cd mysql
if [ "`scripts/mysql_install_db --user=mysql|grep OK|sed '1d'`" = "OK" ]
then
cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 3 mysql on
else
exit
fi
sed -i '/myisam_sort_buffer_size/a\\datadir = /var/lib/mysql' /etc/my.cnf
sed -i 's/3306/6036/g' /etc/my.cnf
sed -i 's/log-bin=mysql-bin/#log-bin=mysql-bin/' /etc/my.cnf
service mysql start
/usr/local/mysql/bin/mysqladmin -u root password ''
/usr/local/mysql/bin/mysqladmin -u root password '123456'
############################################################################
install php
############################################################################
cd $install_dir
tar jxvf $php_name
if [ -d $install_dir/$php_SFX_name ]
then
cd $install_dir/$php_SFX_name
$install_dir/$php_SFX_name/$bianyi_php
if [ $? -eq 0 ]
then
make
else
exit
echo fail
fi
if [ $? -eq 0 ]
then
make install
else
exit
echo fail
fi
if [ $? -eq 0 ]
then
cp php.ini-dist /usr/local/php/lib/php.ini
else
exit
echo fail
fi
else
exit
fi
cd $install_dir
unzip nginx-php-1.zip
if [ -d nginx-php ]
then
cp nginx-php/spawn-fcgi /usr/local/php/bin/
chmod 755 /usr/local/php/bin/spawn-fcgi
else
exit
fi
####################################################################################
install nginx
####################################################################################
cd $install_dir
tar zxvf $pcre_name
if [ -d $install_dir/$pcre_SFX_name ]
then
cd $pcre_SFX_name
$install_dir/$pcre_SFX_name/configure
if [ $? -eq 0 ]
then
make
else
exit
fi
if [ $? -eq 0 ]
then
make install
else
exit
fi
if [ $? -eq 0 ]
then
echo ok
else
exit
fi
else
exit
fi
cd $install_dir
tar zxvf $install_dir/$nginx_name
if [ -d $install_dir/$nginx_SFX_name ]
then
cd $nginx_SFX_name
$install_dir/$nginx_SFX_name/$bianyi_nginx
if [ $? -eq 0 ]
then
make
else
exit
fi
if [ $? -eq 0 ]
then
make install
else
exit
fi
if [ $? -eq 0 ]
then
cp $nginx_configuration/fcgi.conf /usr/local/nginx/conf/
cp $nginx_configuration/nginx /etc/init.d/
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 3 nginx on
mkdir -p /var/log/nginx
cp $nginx_configuration/nginx.conf /usr/local/nginx/conf/
else
exit
fi
else
#exit
echo fail
fi
service nginx start
阅读(2019) | 评论(0) | 转发(0) |