自動配置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
相關文章
- Ubuntu自動啟動配置指令碼Ubuntu指令碼
- Docker配置PHP+Nginx+MySQLDockerPHPNginxMySql
- MySQL8.0的自動部署指令碼MySql指令碼
- 自動化指令碼安裝mysql shell指令碼範例指令碼MySql
- MySQL自動備份指令碼30天自動刪除MySql指令碼
- Mac下Nginx、PHP、MySQL 和 PHP-fpm安裝配置MacNginxPHPMySql
- 筆記:MAC使用brew配置nginx、php、mysql、php-fpm、redis筆記MacNginxPHPMySqlRedis
- 自動定時備份 mysql 資料庫 的 shell 指令碼MySql資料庫指令碼
- 實現MySQL表結構自動分割槽指令碼MySql指令碼
- CentOS7 nginx啟動指令碼CentOSNginx指令碼
- CentOS7上安裝並配置Nginx、PHP、MySqlCentOSNginxPHPMySql
- Centos環境自寫指令碼檢視使用php或nginx佔用記憶體CentOS指令碼PHPNginx記憶體
- specjvm自動化指令碼JVM指令碼
- 自動備份指令碼指令碼
- Centos7下配置PHP + MySQL + Nginx開發環境CentOSPHPMySqlNginx開發環境
- linux+nginx+mysql+php實用伺服器配置教程LinuxNginxMySqlPHP伺服器
- Linux配置開機自啟動執行指令碼方法有哪些?Linux指令碼
- Python——自動簽到指令碼Python指令碼
- Dockerfile---指令碼自動化Docker指令碼
- vue自動化部署指令碼Vue指令碼
- 記Ubuntu 16.04 下配置 Nginx、PHP7、MySQL環境,以及多域名配置UbuntuNginxPHPMySql
- Linux中配置開機自啟動執行指令碼的方法是什麼?Linux指令碼
- nginx去掉index.php配置NginxIndexPHP
- PHP Web 端操作 Nginx 配置PHPWebNginx
- PHP-FPM和nginx配置PHPNginx
- nginx + PHP-fpm 配置示例NginxPHP
- 介紹Nginx配置支援PHPNginxPHP
- nginx+php-fpm配置HTTPSNginxPHPHTTP
- nginx重啟指令碼Nginx指令碼
- centos 自動啟動指令碼和自啟動服務CentOS指令碼
- MYSQL Slave開機啟動指令碼MySql指令碼
- iOS —— 兩套自動打包指令碼iOS指令碼
- mydumper自動化安裝指令碼指令碼
- oracle自動冷備份指令碼Oracle指令碼
- 實現指令碼自動部署docker指令碼Docker
- MySQL指令碼MySql指令碼
- phpstudy 使用 PHP+nginx 配置 LaravelPHPNginxLaravel
- Mac 系統下 DNMP (docker+nginx+MySQL+PHP) 環境的配置及踩坑MacDockerNginxMySqlPHP
- mac下搭建nginx+php+mysqlMacNginxPHPMySql