码迷,mamicode.com
首页 > 其他好文 > 详细

auto_lnmp.sh

时间:2019-11-21 12:14:18      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:pen   emctl   base   lte   pes   nginx   har   efi   firewall   

#!/bin/bash
#2019年10月30日19:42:29
#by author andy
#auto install nginx
#install packages of nginx
nginx_install(){
NGX_YUM="yum install -y"
NGX_VER="nginx-1.16.0"
NGX_DIR="/usr/local/nginx"
NGX_ARGS="--prefix=${NGX_DIR} --user=www --group=www --with-http_stub_status_module --with-http_ssl_module"
$NGX_YUM pcre-devel pcre gcc-c++ openssl-devel openssl zlib-devel
$NGX_YUM wget tar gzip make
#into /root && download soft nginx
cd $HOME
if [ ! -f $NGX_VER.tar.gz ];then
wget http://nginx.org/download/$NGX_VER.tar.gz
else
echo -e "\033[31m$NGX_VER is exist,exiting....\033[0m"
exit
fi
#tar nginx tar.gz package
tar -zxf $NGX_VER.tar.gz
#alter nginx.h about version‘s info
sed -i -e ‘s/1.16.0//g‘ -e ‘s/nginx\//JWS/g‘ -e ‘s/"NGINX"/"JWS"/g‘ $NGX_VER/src/core/nginx.h
#add uesr
useradd www; usermod -s /sbin/nologin www;
#into nginx directory
cd $NGX_VER
#precompile nginx program
./configure $NGX_ARGS
#ok after than fallow ”make ; make install“
if [ $? -eq 0 ]; then
make ; make install
#start nginx service
if [ $? -eq 0 ];then
/usr/local/nginx/sbin/nginx
netstat -tnlp | grep nginx
fi
else
echo "precompile nginx has some problem "
exit
fi
#stop firewall and selinux
if [ $? -eq 0 ];then
systemctl stop firewalld
setenforce 0
else
echo "Please see error logs,have some trobles"
exit
fi
netstat -tnlp | grep nginx
}
$i
#into /root && download soft mysql
mysql_install(){
#yum package of mysql
yum install -y cmake ncurses-devel ncurses libaio bison git gcc-c++
cd $HOME
if [ ! -f mysql-5.5.60.tar.gz ];then
wget http://mirrors.cn99.com/mysql/Downloads/MySQL-5.5/mysql-5.5.60.tar.gz
tar -zxf mysql-5.5.60.tar.gz
cd mysql-5.5.60
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0
make ; make install
cd /usr/local/mysql55
\cp support-files/my-large.cnf /etc/my.cnf
\cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
mkdir -p /data/mysql
useradd mysql
/usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
ln -s /usr/local/mysql55/bin/* /usr/bin/
service mysqld restart
netstat -tnlp | grep mysql
else
echo -e "\033[31m mysql-5.5.60.tar.gz is exist,exiting....\033[0m"
exit
fi
}

$i
#into /root && download soft php
php_install(){
cd $HOME
yum install -y libxml2 libxml2-devel
if [ ! -f php-5.6.28.tar.bz2 ]; then
wget http://mirrors.sohu.com/php/php-5.6.28.tar.bz2
tar jxf php-5.6.28.tar.bz2
cd php-5.6.28
./configure --prefix=/usr/local/php56 --with-config-file-path=/usr/local/php56/etc --with-mysql=/usr/local/mysql55 --enable-fpm
make ; make install
systemctl restart php-fpm
netstat -tnlp | grep php
else
echo -e "\033[31mSorry,php-5.6.28.tar.bz2 already install .exiting....\033[0m"
exit 2
fi
}
$i
lnpm_install(){
cd php-5.6.28
if [ ! -f /usr/local/php56/etc/php.ini -a /usr/local/php56/etc/php-fpm.conf -a /etc/init.d/php-fpm ]; then
#copy initialization file to master program
cp php.ini-development /usr/local/php56/etc/php.ini
#copy and chenge master default of configure
cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
#make startup script
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#change its permission
chmod o+x /etc/init.d/php-fpm
#startup php-fpm && check its port
/etc/init.d/php-fpm start
netstat -tnlp | grep php-fpm
echo "
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
}" >/usr/local/nginx/conf/nginx.conf

echo "
<?php
phpinfo();
?>">/usr/local/nginx/html/index.php
/usr/local/nginx/sbin/nginx -s reload
curl 172.0.0.1/index.php
else
echo -e "\033[31mSorry,php-fpm already exist,exiting.....\033[0m"
exit 3
fi
}
$i

PS3="Please enter your select install menu:"
select i in auto_install_nginx auto_install_mysql auto_install_php auto_integrate_lnmp
do
case $i in
auto_install_nginx)
nginx_install
;;
auto_install_mysql)
mysql_install
;;
auto_install_php)
php_install
;;
auto_integrate_lnmp)
lnpm_install
exit
esac
done

auto_lnmp.sh

标签:pen   emctl   base   lte   pes   nginx   har   efi   firewall   

原文地址:https://blog.51cto.com/13689591/2451980

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!