• 欢迎访问开心洋葱网站,在线教程,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站,欢迎加入开心洋葱 QQ群
  • 为方便开心洋葱网用户,开心洋葱官网已经开启复制功能!
  • 欢迎访问开心洋葱网站,手机也能访问哦~欢迎加入开心洋葱多维思维学习平台 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏开心洋葱吧~~~~~~~~~~~~~!
  • 由于近期流量激增,小站的ECS没能经的起亲们的访问,本站依然没有盈利,如果各位看如果觉着文字不错,还请看官给小站打个赏~~~~~~~~~~~~~!

ecstore centos服务器一键安装SH脚本

ECStore 开心洋葱 2754次浏览 1个评论

ecstore centos服务器一键安装SH脚本

服务器环境: centos 、可联网、根目录data目录
ecstore_install-v1.sh

链接: https://pan.baidu.com/s/1eR56MdG 密码:

注意:本段内容须成功“回复本文”后“刷新本页”方可查看!

#!/bin/bash
#####this script is install ECSTORE ######
#####VERSION: 1.1 ########
#####DATE: 2015-7-16  ####
#####AUTH: BY shopex  ####
if [ $(id -u) != "0" ]; then
    echo "Error: You must be use root to run this script, please change root user!!!"
    exit 1
fi
echo -e "\033[40;32mPlease confirm that the server can access the Internet\033[40;37m"
#echo "Please input webdir"
readdir()
{
read -p "Please input webdir (for example:/data ):" WEBDIR

if [ ! -d $WEBDIR ]; then
        echo -e "\033[40;32m This dir is not found, please enter again\033[40;37m"
        readdir
        return 0
fi
}
readdir
echo "======================================================================================"
echo -e "\033[40;32mThe Server datadir is "$WEBDIR"\033[40;37m"
read -p "Do you confirm the information (y/n)" modify
case $modify in
	y*|Y*)
		;;		 
	n*|N*)
		readdir;;
esac
PWDPATH=$(pwd)
#Disable SeLinux
setenforce 0
if [ -s /etc/selinux/config ]; then
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
    echo -e "\033[31m selinux is disabled,if you need,you must reboot.\033[0m"
fi
#dns  config
cp /etc/resolv.conf /etc/resolv.conf.bak
cat >/etc/resolv.conf <<'EOF'
nameserver 223.5.5.5
nameserver 223.6.6.6
EOF

#Synchronization time
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

#iptables config
cat > /etc/sysconfig/iptables << 'EOF'
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,NEW,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF
iptables-restore < /etc/sysconfig/iptables
service iptables save
service iptables restart
clear
which wget &>/dev/null
if [ $? != "0" ]; then
        yum -y install wget >/dev/null 2>&1
fi
which ntpdate &>/dev/null
if [ $? != "0" ]; then
    echo "ntp need update"
    yum -y install ntpdate >/dev/null 2>&1
fi
ntpdate -u pool.ntp.org>/dev/null 2>&1
               
echo -e "\033[40;32mStep 1.Begin to modify the system configration\n\033[40;37m"
if [ -z "`grep -i 'www' /etc/security/limits.conf`" ] ;then
        cat > /etc/security/limits.conf <<'EOF'
www               soft    nofile          65534
mysql             soft    nofile          65534
www               hard    nofile          65534
mysql             hard    nofile          65534
EOF

        ulimit -u 10240
        ulimit -n 65535
fi
if [ -z "`grep -i 'mysql' /etc/security/limits.conf`" ] ;then
        cat > /etc/security/limits.conf <<'EOF'
mysql             soft    nofile          65534
mysql             hard    nofile          65534
EOF

fi


if [ -z "`grep -i tcp_timestamps /etc/sysctl.conf`" ] ;then
        echo "net.ipv4.tcp_timestamps = 1" >> /etc/sysctl.conf
fi
if [ -z "`grep -i tcp_tw_recycle /etc/sysctl.conf`" ] ;then
        echo "net.ipv4.tcp_tw_recycle = 1" >> /etc/sysctl.conf
fi
if [ -z "`grep -i tcp_tw_reuse /etc/sysctl.conf`" ] ;then
        echo "net.ipv4.tcp_tw_reuse = 1" >> /etc/sysctl.conf
fi
if [ -z "`grep -i swappiness /etc/sysctl.conf`" ] ;then
        echo "vm.swappiness = 1" >> /etc/sysctl.conf
fi
if [ -z "`grep -i aio-max-nr /etc/sysctl.conf`" ] ;then
        echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
fi
yum install -y procps
sysctl -p
echo -e "\033[40;32mStep 2.Begin to install the Basic Environment\n\033[40;37m"
yum -y install make vim install gcc gcc-c++ ncurses ncurses-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre pcre-devel  zlip zlip-devel 

yum remove php* -y > /dev/null 2>&1 || true
yum remove mysql* -y > /dev/null 2>&1 || true
yum remove nginx* -y > /dev/null 2>&1 || true
echo -e "\033[40;32mStep 3.Begin to install MySQL NGINX PHP\n\033[40;37m"
cd /etc/yum.repos.d/
wget http://mirrors.shopex.cn/shopex/shopex-lnmp/shopex-lnmp.repo
yum install epel-release -y
yum -y install ngx_openresty php-fpm53 mysql51 Zend53 mysql-libs mysql56-libs-5.6.22-1.shopex.x86_64
###path#
ln -s /usr/local/php53/bin/php /usr/local/bin/php
ln -s /usr/local/mysql51/bin/mysql /usr/local/bin/mysql
ln -s /usr/local/mysql51/bin/mysqldump /usr/local/bin/mysqldump

/etc/init.d/php-fpm53 stop
/etc/init.d/nginx stop
/etc/init.d/mysql51 stop
##检测ecstore 包

ECSTORE=$(ls ecstore-*.tar.gz 2>/dev/null)
cd $PWDPATH
if [ -e  $ECSTORE ];then
			mkdir -p $WEBDIR/www
			tar -xf $PWDPATH/$ECSTORE -C $WEBDIR/www  
			 
else 
		echo "not ecstore file,Please install it yourself,and add crontab"	
fi

#####修改配置文件
sed -i  s#'root  /data/httpd'#root\ \ $WEBDIR/www/ecstore#g /usr/local/nginx/conf/vhosts/default.conf
chown -R www.www $WEBDIR/www
if [ $WEBDIR != '/data' ];then
sed -i  s#'datadir=/data'#datadir=$WEBDIR#g /usr/local/mysql51/my.cnf
sed -i  s#'datadir=/data'#datadir=$WEBDIR#g /etc/init.d/mysql51
mkdir -p $WEBDIR/mysql/
mv /data/mysql/3306 $WEBDIR/mysql/
chown -R mysql.mysql $WEBDIR/mysql
fi

QUEUE=$(find $WEBDIR/www/ecstore -name queue.sh|grep script|head -1)
if [ -e $QUEUE ];then
	CRONT=$(find $WEBDIR/www/ecstore -name crontab.php|grep script|head -1)
	test -e /var/spool/cron||mkdir -p /var/spool/cron
	cat > /var/spool/cron/root <<EOF
	* * * * * $CRONT /usr/local/bin/php >/dev/null
	* * * * * $QUEUE /usr/local/bin/php >/dev/null
EOF
fi
chkconfig nginx on
/etc/init.d/mysql51 start
/etc/init.d/nginx start
/etc/init.d/php-fpm53 start
echo -e "\033[40;32m  nginx install path :/usr/local/nginx \n\033[40;37m"
echo -e "\033[40;32m  nginx config :/usr/local/nginx/conf \n\033[40;37m"
echo -e "\033[40;32m  php install path :/usr/local/php53\n\033[40;37m"
echo -e "\033[40;32m  php config :/usr/local/php53/etc \n\033[40;37m"
echo -e "\033[40;32m  mysql install path :/usr/local/mysql51 \n\033[40;37m"
echo -e "\033[40;32m  mysql config  :/usr/local/mysql51/conf \n\033[40;37m"
echo -e "\033[40;32m  /etc/init.d/nginx start|stop|restart \n\033[40;37m"
echo -e "\033[40;32m  /etc/init.d/php-fpm53 start|stop|restart \n\033[40;37m"
echo -e "\033[40;32m  /etc/init.d/mysql51 start|stop|restart \n\033[40;37m"
echo -e "\033[40;32m  you need modify /usr/local/php53/etc/php.d/zend.ini \n\033[40;37m"
exit 0


开心洋葱 , 版权所有丨如未注明 , 均为原创丨未经授权请勿修改 , 转载请注明ecstore centos服务器一键安装SH脚本
喜欢 (0)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. 学习下,感谢!!!
    leo11282017-06-06 20:53
加载中……