服务器环境: 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
