自動配置php、mysql、nginx的指令碼
前一段自己寫了個全自動配置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
#!/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
本文轉自wiliiwin 51CTO部落格,原文連結:http://blog.51cto.com/wiliiwin/199237
相關文章
- 解剖Nginx·自動指令碼篇(1)解析配置選項指令碼 auto/optionsNginx指令碼
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- 解剖Nginx·自動指令碼篇(4)工具型指令碼系列Nginx指令碼
- MySQL自動備份指令碼MySql指令碼
- MySQL8.0的自動部署指令碼MySql指令碼
- 精讀Nginx原始碼·自動指令碼篇(1)如何讀取配置選項?Nginx原始碼指令碼
- Docker配置PHP+Nginx+MySQLDockerPHPNginxMySql
- 精讀 Nginx·自動指令碼篇(4)工具型指令碼系列Nginx指令碼
- 解剖Nginx·自動指令碼篇(7)型別相關指令碼系列Nginx指令碼型別
- 自動化指令碼安裝mysql shell指令碼範例指令碼MySql
- 解剖Nginx·自動指令碼篇(5)編譯器相關主指令碼Nginx指令碼編譯
- LINUX 自動執行指令碼的命令配置Linux指令碼
- MySQL自動備份指令碼30天自動刪除MySql指令碼
- 解剖Nginx·自動指令碼篇(3)原始碼相關變數指令碼 auto/sourcesNginx指令碼原始碼變數
- 精讀Nginx·自動指令碼篇(5)編譯器相關主指令碼Nginx指令碼編譯
- 解剖Nginx·自動指令碼篇(2)設定初始變數指令碼 auto/initNginx指令碼變數
- shell之lnmp(nginx-1.0.5+php-fpm5.3.6+mysql)安裝指令碼LNMPNginxPHPMySql指令碼
- 使用shell生成orabbix自動化配置指令碼指令碼
- 使用php作linux自動執行指令碼PHPLinux指令碼
- 5.6 MySql主從自動切換指令碼MySql指令碼
- 精讀Nginx原始碼·自動指令碼篇(2)設定初始變數指令碼 auto/initNginx原始碼指令碼變數
- 精讀 Nginx 原始碼·自動指令碼篇(3)原始碼相關變數指令碼 auto/sourcesNginx原始碼指令碼變數
- Mac 下 Nginx、MySQL、PHP-FPM 的安裝配置MacNginxMySqlPHP
- 自動記錄MySQL慢查詢快照指令碼MySql指令碼
- Crontab自動執行指令碼Kill掉MySQL的僵死程式指令碼MySql
- Mac下Nginx、PHP、MySQL 和 PHP-fpm安裝配置MacNginxPHPMySql
- Nginx技巧——Nginx/Apache下禁止指定目錄執行PHP指令碼(轉自運維之美)NginxApachePHP指令碼運維
- 自動ftp指令碼FTP指令碼
- 自動生成Statspack的指令碼指令碼
- 解剖Nginx·自動指令碼篇(6)編譯器名稱變數指令碼 auto/cc/nameNginx指令碼編譯變數
- FreeBSD安裝配置Nginx+PHP+APC+MySQLNginxPHPMySql
- 筆記:MAC使用brew配置nginx、php、mysql、php-fpm、redis筆記MacNginxPHPMySqlRedis
- 自動定時備份 mysql 資料庫 的 shell 指令碼MySql資料庫指令碼
- 實現MySQL表結構自動分割槽指令碼MySql指令碼
- mysql5.6主主叢集自動同步指令碼MySql指令碼
- MySQL資料庫叢集自動安裝指令碼!MySql資料庫指令碼
- saltstack之nginx、php的配置NginxPHP
- 配置nginx對php的支援NginxPHP