#!/bin/bash
#auto make install Lnmp
#by Authors Zhang 2016
#Nginx Define PATH variable
N_files=nginx-1.6.0.tar.gz
n_files_dir=nginx-1.6.0
n_prefix=/usr/local/nginx/
#mysql Define PATH variable
M_files=mysql-5.5.22.tar.gz
m_files_dir=mysql-5.5.22
m_prefix=/usr/local/mysql/
#php Define PATH variable
P_files1=libmcrypt-2.5.8.tar.gz
p_files_dir1=libmcrypt-2.5.8
p_prefix1=/usr/local/lib/
P_files2=mhash-0.9.9.9.tar.gz
p_files_dir2=mhash-0.9.9.9
p_prefix2=/usr/local/lib/
P_files3=mcrypt-2.6.8.tar.gz
p_files_dir3=mcrypt-2.6.8
p_prefix3=/usr/local/lib/
P_files4=php-5.3.28.tar.gz
p_files_dir4=php-5.3.28
p_prefix4=/usr/local/php/
####################################################
# # # #编写导航菜单
If [-Z "$"];then
ECHO-E "\033[36m Please select the following options: \033[0m"
Echo-e "\033[32m1) Compile and install nginx\033[1m"
echo "2) Compile and install MySQL"
echo "3) Compile and install PHP"
echo "4) Deploy Sky Network Movie system"
Echo-e "\033[31m use: {/bin/sh $1|2|3|4|help}\033[0m"
Exit
Fi
#auto Install Nginx
If [$1-eq 1];then
Yum-y Install Pcre-devel Zlib-devel
Useradd-m-s/sbin/nologin Nginx
TAR-ZXVF $N _files-c/usr/src/&& cd/usr/src/$N _files_dir &&/configure--prefix= $N _prefix--user=ngin X--group=nginx--with-http_stub_status_module
If [$?-eq 0];then
Make &&make Install
Echo-e "\033[32mnginx compiled and installed successfully! \033[0m "
Else
Echo-e "\033[31mnginx compilation installation Failed! \033[0m "
Exit
Fi
###### #路径优化
Ln-s $N _prefix/sbin/nginx/usr/local/sbin/
Ls-l/usr/local/sbin/nginx
If [$?-eq 0];then
ECHO-E "\033[32m path optimization complete! \033[0m "
Else
ECHO-E "\033[31m path optimization failed! \033[0m "
Fi
Fi
#auto Install Mysql
If [$1-eq 2];then
Rpm-e mysql-server MySQL--nodeps
Yum-y Install Ncurses-devel
TAR-ZXVF cmake-2.8.6.tar.gz-c/usr/src/&& cd/usr/src/cmake-2.8.6/;. /configure
If [$?-eq 0];then
Gmake &&gmake Install
Echo-e "\033[32mthe cmake Server Install successfully! (cmake compile installation complete!) \033[0m"
Else
Echo-e "\033[31mthe cmake Server Install failed,please check...\033[0m"
Exit
Fi
Useradd-m-u 27-s/sbin/nologin mysql
Cd/root
TAR-ZXVF $M _files-c/usr/src/;cd/usr/src/$M _files_dir && cmake-dcmake_install_prefix= $M _prefix-dsysconfdir =/etc-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_extra_charsets=all
If [$?-eq 0];then
Make &&make Install
Echo-e "\033[32mthe mysql $M _files_dir install successfully! (MySQL service installation is complete!) ) \033[0m "
Else
Echo-e "\033[31mthe MySQL $M _files_dir Install failed,please check...\033[0m"
Exit
Fi
Chown-r mysql:mysql/usr/local/mysql/
cd/usr/src/$M _files_dir
CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
$M _prefix/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/
cd/usr/src/$M _files_dir
Ln-s/usr/local/mysql/bin/*/usr/local/bin/
CP Support-files/mysql.server/etc/init.d/mysqld
chmod +x/etc/rc.d/init.d/mysqld
Chkconfig--add mysqld
Chkconfig mysqld on
Service Mysqld Stop
Service mysqld Start
NETSTAT-ANPT | grep 3306
ECHO-E "\033[32mmysql Service optimization completed, has opened \033[0m"
mysqladmin-u root password ' 123.com '
If [$?-eq 0];then
Echo-e "\033[32mmysql root password created successfully, password is 123.com\033[0m"
Else
Echo-e "\033[31mmysql root password creation failed! \033[0m "
Fi
Fi
#PHP Define PATH variable
If [$1-eq 3];then
TAR-ZXVF $P _files1-c/usr/src/;cd/usr/src/$P _files_dir1/&&/configure && make && make install && ln-s/$P _prefix1/libmcrypt.*/usr/lib/
cd/root/
TAR-ZXVF $P _files2-c/usr/src/;cd/usr/src/$P _files_dir2/&&/configure && make && make install && ln-s/$P _prefix2/libmhash*/usr/lib/
cd/root/
TAR-ZXVF $P _files3-c/usr/src/;cd/usr/src/$P _files_dir3/&& export ld_library_path=/$P _prefix3: $LD _library_ PATH &&./configure && make && make install
cd/root/
TAR-ZXVF $P _files4-c/usr/src/;cd/usr/src/$P _files_dir4/&&/configure--prefix= $P _prefix4--WITH-GD-- With-zlib--with-mysql= $M _prefix--with-config-file-path= $P _prefix4--enable-mbstring--enable-fpm--with-jpeg-dir= /usr/lib
If [$?-eq 0];then
Make &&make Install
Echo-e "\033[32mthe $P _files_dir4 Server Install successfully! ( PHP installation is complete! ) \033[0m "
Else
Echo-e "\033[31mthe $P _files_dir4 Server Install failed,please check...\033[0m"
Exit
Fi
cp/usr/src/$P _files_dir4/php.ini-development $PREFIX 4/php.ini
Ln-s $PREFIX 4/bin/*/usr/local/bin/
Ln-s $PREFIX 4/sbin/*/usr/local/sbin/
#创建php-fpm.conf
Useradd-m-u 40-s/sbin/nologin php
cd/usr/local/php/etc/
CP Php-fpm.conf.default php-fpm.conf
Sed-i s ' @;p id = run/[email protected] = Run/[email protected] ' php-fpm.conf
Sed-i s ' @user = [email protected] = [email protected] ' php-fpm.conf
Sed-i s ' @group = [email protected] = [email protected] ' php-fpm.conf
Sed-i s ' @pm. Max_children = [email protected]_children = [email protected] ' php-fpm.conf
Sed-i s ' @pm. start_servers = [email protected]_servers = [email protected] ' php-fpm.conf
Sed-i s ' @pm. min_spare_servers = [email protected]_spare_servers = [email protected] ' php-fpm.conf
Sed-i s ' @pm. max_spare_servers = [email protected]_spare_servers = [email protected] ' php-fpm.conf
/usr/local/sbin/php-fpm
NETSTAT-ANPT | grep php-fpm
cp/usr/src/php-5.3.28/sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm
chmod +x/etc/init.d/php-fpm
Service PHP-FPM Stop
Service PHP-FPM Start
Chkconfig--add PHP-FPM
Chkconfig PHP-FPM on
If [$?-eq 0];then
ECHO-E "\033[32MPHP-FPM process started \033[0m"
Else
Echo-e "\033[31MPHP-FPM process failed to start \033[0m"
Fi
Sed-i ' s/#charset koi8-r;/charset utf-8;/g '/usr/local/nginx/conf/nginx.conf
Sed-i s ' @index [email protected] [email protected] '/usr/local/nginx/conf/nginx.conf
Sed-i ' [email protected]#[email protected]@ '/usr/local/nginx/conf/nginx.conf
Sed-i ' [email protected]# root html;@ root html;@ '/usr/local/nginx/conf/nginx.conf
Sed-i ' [email protected]# fastcgi_pass 127.0.0.1:9000;@ fastcgi_pass 127.0.0.1:9000;@ '/usr/local/nginx/conf/ng Inx.conf
Sed-i ' [email protected]# fastcgi_index index.php;@ fastcgi_index index.php;@ '/usr/local/nginx/conf/nginx.conf
Sed-i ' [email protected]# fastcgi_param script_filename/scripts$fastcgi_script_name;@ Fastcgi_param SCRIPT_FILEN ame/scripts$fastcgi_script_name;@ '/usr/local/nginx/conf/nginx.conf
Sed-i ' [email protected]# include fastcgi_params;@ include fastcgi.conf;@ '/usr/local/nginx/conf/ngin X.conf
Sed-i ' 71s/#}/}/'/usr/local/nginx/conf/nginx.conf
Service Nginx Stop
ECHO-E "\033[31mnginx service is off \033[0m"
Service Nginx Start
ECHO-E "\033[32mnginx service has started \033[0m"
NETSTAT-ANPT | grep 80
######## #验证PHP与Nginx
ip= ' ifconfig eth0|grep "bcast" |awk ' {print $} ' |cut-d:-f2 '
Cat > $N _prefix/html/index1.php <<eof
<?php
Phpinfo ();
?>
Eof
If [$?-eq 0];then
Echo-e "\033[32mphp page is ready, please enter Firefox/http/$IP/index1.php to verify \033[0m"
Else
Echo-e "\033[31mphp page loading failed! \033[0m "
Fi
######### #验证PHP与Mysql
echo "<?php
\ $link =mysql_connect (' localhost ', ' root ', ' 123.com ');
if (\ $link) echo ' Congratulations, the database connection is successful!! ';
Mysql_close ();
?> ">/usr/local/nginx/html/index2.php
If [$?-eq 0];then
Echo-e "\033[32mmysql page is ready, please enter Firefox/http/$IP/index2.php to verify \033[0m"
Else
Echo-e "\033[31mmsql page loading failed! \033[0m "
Fi
Fi
######################################################
##### #部署天空网络电影服务
############ #设置SKYUC网站
If [$1-eq 4];then
Yum-y Install Unzip
Unzip Skyuc.v3.4.2.source.zip
Cp-r skyuc.v3.4.2.source/wwwroot//usr/local/nginx/html/skyuc
Chown-r php:php/usr/local/nginx/html/skyuc/admincp/
Chown-r php:php/usr/local/nginx/html/skyuc/data/
Chown-r php:php/usr/local/nginx/html/skyuc/upload/
Chown-r php:php/usr/local/nginx/html/skyuc/templates/
###### #创建数据库
Mysql-u root-p123.com
Fi
##########################################
#为保证安全性, the database needs to be created on its own
#create database skyucdb;
#grant all on skyucdb.* to ' admin ' @ ' localhost ' identified by ' 123.com ';
#quit
####### #安装界面: Firefox http://192.168.1.1/skyuc/install/index.php &
#重启Nginx
#killall-S QUIT nginx
#nginx
This article from the "Speed of Light Snail" blog, reproduced please contact the author!
Lnmp platform Build script