init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_phpMyAdmin() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=`${php_install_dir}/bin/php-config --version`
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-1]$ ]]; then
|
||||
tar xzf phpMyAdmin-${phpmyadmin_oldver}-all-languages.tar.gz
|
||||
/bin/mv phpMyAdmin-${phpmyadmin_oldver}-all-languages ${wwwroot_dir}/default/phpMyAdmin
|
||||
else
|
||||
tar xzf phpMyAdmin-${phpmyadmin_ver}-all-languages.tar.gz
|
||||
/bin/mv phpMyAdmin-${phpmyadmin_ver}-all-languages ${wwwroot_dir}/default/phpMyAdmin
|
||||
fi
|
||||
/bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
|
||||
mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save}
|
||||
sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@host'\].*@host'\] = '127.0.0.1';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/phpMyAdmin
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
Vendored
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_redis_server() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
tar xzf redis-${redis_ver}.tar.gz
|
||||
pushd redis-${redis_ver} > /dev/null
|
||||
make -j ${THREAD}
|
||||
if [ -f "src/redis-server" ]; then
|
||||
mkdir -p ${redis_install_dir}/{bin,etc,var}
|
||||
/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} ${redis_install_dir}/bin/
|
||||
/bin/cp redis.conf ${redis_install_dir}/etc/
|
||||
ln -s ${redis_install_dir}/bin/* /usr/local/bin/
|
||||
sed -i 's@pidfile.*@pidfile /var/run/redis/redis.pid@' ${redis_install_dir}/etc/redis.conf
|
||||
sed -i "s@logfile.*@logfile ${redis_install_dir}/var/redis.log@" ${redis_install_dir}/etc/redis.conf
|
||||
sed -i "s@^dir.*@dir ${redis_install_dir}/var@" ${redis_install_dir}/etc/redis.conf
|
||||
sed -i 's@daemonize no@daemonize yes@' ${redis_install_dir}/etc/redis.conf
|
||||
sed -i "s@^# bind 127.0.0.1@bind 127.0.0.1@" ${redis_install_dir}/etc/redis.conf
|
||||
redis_maxmemory=`expr $Mem / 8`000000
|
||||
[ -z "`grep ^maxmemory ${redis_install_dir}/etc/redis.conf`" ] && sed -i "s@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory `expr $Mem / 8`000000@" ${redis_install_dir}/etc/redis.conf
|
||||
echo "${CSUCCESS}Redis-server installed successfully! ${CEND}"
|
||||
popd > /dev/null
|
||||
rm -rf redis-${redis_ver}
|
||||
id -u redis >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin redis
|
||||
chown -R redis:redis ${redis_install_dir}/{var,etc}
|
||||
|
||||
/bin/cp ../services/redis-server.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/redis@${redis_install_dir}@g" /lib/systemd/system/redis-server.service
|
||||
systemctl enable redis-server
|
||||
#[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
|
||||
#sysctl -p
|
||||
systemctl start redis-server
|
||||
else
|
||||
rm -rf ${redis_install_dir}
|
||||
echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
Install_pecl_redis() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
if [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then
|
||||
tar xzf redis-${pecl_redis_oldver}.tgz
|
||||
pushd redis-${pecl_redis_oldver} > /dev/null
|
||||
else
|
||||
tar xzf redis-${pecl_redis_ver}.tgz
|
||||
pushd redis-${pecl_redis_ver} > /dev/null
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/redis.so" ]; then
|
||||
echo 'extension=redis.so' > ${php_install_dir}/etc/php.d/05-redis.ini
|
||||
echo "${CSUCCESS}PHP Redis module installed successfully! ${CEND}"
|
||||
rm -rf redis-${pecl_redis_ver} redis-${pecl_redis_oldver}
|
||||
else
|
||||
echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_redis() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/05-redis.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/05-redis.ini
|
||||
echo; echo "${CMSG}PHP redis module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP redis module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MariaDB1011() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mysql >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
|
||||
|
||||
[ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
|
||||
mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
|
||||
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
tar zxf mariadb-${mariadb1011_ver}-linux-systemd-x86_64.tar.gz
|
||||
mv mariadb-${mariadb1011_ver}-linux-systemd-x86_64/* ${mariadb_install_dir}
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
|
||||
sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}')
|
||||
tar xzf boost_${boostVersion2}.tar.gz
|
||||
tar xzf mariadb-${mariadb1011_ver}.tar.gz
|
||||
pushd mariadb-${mariadb1011_ver}
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \
|
||||
-DMYSQL_DATADIR=${mariadb_data_dir} \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=../boost_${boostVersion2} \
|
||||
-DSYSCONFDIR=/etc \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
|
||||
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DENABLE_DTRACE=0 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ -d "${mariadb_install_dir}/support-files" ]; then
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
rm -rf mariadb-${mariadb1011_ver}-linux-systemd-x86_64
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
rm -rf mariadb-${mariadb1011_ver} boost_${boostVersion2}
|
||||
fi
|
||||
else
|
||||
rm -rf ${mariadb_install_dir}
|
||||
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
/bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld
|
||||
sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld
|
||||
sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld
|
||||
chmod +x /etc/init.d/mysqld
|
||||
[ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
|
||||
[ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
|
||||
popd
|
||||
|
||||
# my.cnf
|
||||
cat > /etc/my.cnf << EOF
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
|
||||
basedir = ${mariadb_install_dir}
|
||||
datadir = ${mariadb_data_dir}
|
||||
pid-file = ${mariadb_data_dir}/mysql.pid
|
||||
user = mysql
|
||||
bind-address = 0.0.0.0
|
||||
server-id = 1
|
||||
|
||||
init-connect = 'SET NAMES utf8mb4'
|
||||
character-set-server = utf8mb4
|
||||
|
||||
skip-name-resolve
|
||||
#skip-networking
|
||||
back_log = 300
|
||||
|
||||
max_connections = 1000
|
||||
max_connect_errors = 6000
|
||||
open_files_limit = 65535
|
||||
table_open_cache = 128
|
||||
max_allowed_packet = 500M
|
||||
binlog_cache_size = 1M
|
||||
max_heap_table_size = 8M
|
||||
tmp_table_size = 16M
|
||||
|
||||
read_buffer_size = 2M
|
||||
read_rnd_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
join_buffer_size = 8M
|
||||
key_buffer_size = 4M
|
||||
|
||||
thread_cache_size = 8
|
||||
|
||||
query_cache_type = 1
|
||||
query_cache_size = 8M
|
||||
query_cache_limit = 2M
|
||||
|
||||
ft_min_word_len = 4
|
||||
|
||||
log_bin = mysql-bin
|
||||
binlog_format = mixed
|
||||
expire_logs_days = 7
|
||||
|
||||
log_error = ${mariadb_data_dir}/mysql-error.log
|
||||
slow_query_log = 1
|
||||
long_query_time = 1
|
||||
slow_query_log_file = ${mariadb_data_dir}/mysql-slow.log
|
||||
|
||||
performance_schema = 0
|
||||
|
||||
#lower_case_table_names = 1
|
||||
|
||||
skip-external-locking
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
innodb_file_per_table = 1
|
||||
innodb_open_files = 500
|
||||
innodb_buffer_pool_size = 64M
|
||||
innodb_write_io_threads = 4
|
||||
innodb_read_io_threads = 4
|
||||
innodb_purge_threads = 1
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 2M
|
||||
innodb_log_file_size = 32M
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_lock_wait_timeout = 120
|
||||
|
||||
bulk_insert_buffer_size = 8M
|
||||
myisam_sort_buffer_size = 8M
|
||||
myisam_max_sort_file_size = 10G
|
||||
|
||||
interactive_timeout = 28800
|
||||
wait_timeout = 28800
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
max_allowed_packet = 500M
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
read_buffer = 4M
|
||||
write_buffer = 4M
|
||||
EOF
|
||||
|
||||
sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
|
||||
if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
|
||||
fi
|
||||
|
||||
${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
|
||||
|
||||
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
|
||||
chown mysql.mysql -R ${mariadb_data_dir}
|
||||
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
|
||||
service mysqld start
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mariadb_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mariadb_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
|
||||
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
|
||||
echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf
|
||||
ldconfig
|
||||
service mysqld stop
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MariaDB118() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mysql >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
|
||||
|
||||
[ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
|
||||
mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
|
||||
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
tar zxf mariadb-${mariadb118_ver}-linux-systemd-x86_64.tar.gz
|
||||
mv mariadb-${mariadb118_ver}-linux-systemd-x86_64/* ${mariadb_install_dir}
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
|
||||
sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}')
|
||||
tar xzf boost_${boostVersion2}.tar.gz
|
||||
tar xzf mariadb-${mariadb118_ver}.tar.gz
|
||||
pushd mariadb-${mariadb118_ver}
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \
|
||||
-DMYSQL_DATADIR=${mariadb_data_dir} \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=../boost_${boostVersion2} \
|
||||
-DSYSCONFDIR=/etc \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
|
||||
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DENABLE_DTRACE=0 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ -d "${mariadb_install_dir}/support-files" ]; then
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
rm -rf mariadb-${mariadb118_ver}-linux-systemd-x86_64
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
rm -rf mariadb-${mariadb118_ver} boost_${boostVersion2}
|
||||
fi
|
||||
else
|
||||
rm -rf ${mariadb_install_dir}
|
||||
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
/bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld
|
||||
sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld
|
||||
sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld
|
||||
chmod +x /etc/init.d/mysqld
|
||||
[ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
|
||||
[ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
|
||||
popd
|
||||
|
||||
# my.cnf
|
||||
cat > /etc/my.cnf << EOF
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
|
||||
basedir = ${mariadb_install_dir}
|
||||
datadir = ${mariadb_data_dir}
|
||||
pid-file = ${mariadb_data_dir}/mysql.pid
|
||||
user = mysql
|
||||
bind-address = 0.0.0.0
|
||||
server-id = 1
|
||||
|
||||
init-connect = 'SET NAMES utf8mb4'
|
||||
character-set-server = utf8mb4
|
||||
|
||||
skip-name-resolve
|
||||
#skip-networking
|
||||
back_log = 300
|
||||
|
||||
max_connections = 1000
|
||||
max_connect_errors = 6000
|
||||
open_files_limit = 65535
|
||||
table_open_cache = 128
|
||||
max_allowed_packet = 500M
|
||||
binlog_cache_size = 1M
|
||||
max_heap_table_size = 8M
|
||||
tmp_table_size = 16M
|
||||
|
||||
read_buffer_size = 2M
|
||||
read_rnd_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
join_buffer_size = 8M
|
||||
key_buffer_size = 4M
|
||||
|
||||
thread_cache_size = 8
|
||||
|
||||
query_cache_type = 1
|
||||
query_cache_size = 8M
|
||||
query_cache_limit = 2M
|
||||
|
||||
ft_min_word_len = 4
|
||||
|
||||
log_bin = mysql-bin
|
||||
binlog_format = mixed
|
||||
expire_logs_days = 7
|
||||
|
||||
log_error = ${mariadb_data_dir}/mysql-error.log
|
||||
slow_query_log = 1
|
||||
long_query_time = 1
|
||||
slow_query_log_file = ${mariadb_data_dir}/mysql-slow.log
|
||||
|
||||
performance_schema = 0
|
||||
|
||||
#lower_case_table_names = 1
|
||||
|
||||
skip-external-locking
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
innodb_file_per_table = 1
|
||||
innodb_open_files = 500
|
||||
innodb_buffer_pool_size = 64M
|
||||
innodb_write_io_threads = 4
|
||||
innodb_read_io_threads = 4
|
||||
innodb_purge_threads = 1
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 2M
|
||||
innodb_log_file_size = 32M
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_lock_wait_timeout = 120
|
||||
|
||||
bulk_insert_buffer_size = 8M
|
||||
myisam_sort_buffer_size = 8M
|
||||
myisam_max_sort_file_size = 10G
|
||||
|
||||
interactive_timeout = 28800
|
||||
wait_timeout = 28800
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
max_allowed_packet = 500M
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
read_buffer = 4M
|
||||
write_buffer = 4M
|
||||
EOF
|
||||
|
||||
sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
|
||||
if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
|
||||
fi
|
||||
|
||||
${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
|
||||
|
||||
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
|
||||
chown mysql.mysql -R ${mariadb_data_dir}
|
||||
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
|
||||
service mysqld start
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mariadb_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mariadb_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
|
||||
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
|
||||
echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf
|
||||
ldconfig
|
||||
service mysqld stop
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MariaDB123() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mysql >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
|
||||
|
||||
[ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
|
||||
mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
|
||||
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
tar zxf mariadb-${mariadb123_ver}-linux-systemd-x86_64.tar.gz
|
||||
mv mariadb-${mariadb123_ver}-linux-systemd-x86_64/* ${mariadb_install_dir}
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
|
||||
sed -i "s@/usr/local/mysql@${mariadb_install_dir}@g" ${mariadb_install_dir}/bin/mysqld_safe
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}')
|
||||
tar xzf boost_${boostVersion2}.tar.gz
|
||||
tar xzf mariadb-${mariadb123_ver}.tar.gz
|
||||
pushd mariadb-${mariadb123_ver}
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \
|
||||
-DMYSQL_DATADIR=${mariadb_data_dir} \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=../boost_${boostVersion2} \
|
||||
-DSYSCONFDIR=/etc \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
|
||||
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DENABLE_DTRACE=0 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ -d "${mariadb_install_dir}/support-files" ]; then
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
rm -rf mariadb-${mariadb123_ver}-linux-systemd-x86_64
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
rm -rf mariadb-${mariadb123_ver} boost_${boostVersion2}
|
||||
fi
|
||||
else
|
||||
rm -rf ${mariadb_install_dir}
|
||||
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
/bin/cp ${mariadb_install_dir}/support-files/mysql.server /etc/init.d/mysqld
|
||||
sed -i "s@^basedir=.*@basedir=${mariadb_install_dir}@" /etc/init.d/mysqld
|
||||
sed -i "s@^datadir=.*@datadir=${mariadb_data_dir}@" /etc/init.d/mysqld
|
||||
chmod +x /etc/init.d/mysqld
|
||||
[ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
|
||||
[ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
|
||||
popd
|
||||
|
||||
# my.cnf
|
||||
cat > /etc/my.cnf << EOF
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
|
||||
basedir = ${mariadb_install_dir}
|
||||
datadir = ${mariadb_data_dir}
|
||||
pid-file = ${mariadb_data_dir}/mysql.pid
|
||||
user = mysql
|
||||
bind-address = 0.0.0.0
|
||||
server-id = 1
|
||||
|
||||
init-connect = 'SET NAMES utf8mb4'
|
||||
character-set-server = utf8mb4
|
||||
|
||||
skip-name-resolve
|
||||
#skip-networking
|
||||
back_log = 300
|
||||
|
||||
max_connections = 1000
|
||||
max_connect_errors = 6000
|
||||
open_files_limit = 65535
|
||||
table_open_cache = 128
|
||||
max_allowed_packet = 500M
|
||||
binlog_cache_size = 1M
|
||||
max_heap_table_size = 8M
|
||||
tmp_table_size = 16M
|
||||
|
||||
read_buffer_size = 2M
|
||||
read_rnd_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
join_buffer_size = 8M
|
||||
key_buffer_size = 4M
|
||||
|
||||
thread_cache_size = 8
|
||||
|
||||
query_cache_type = 1
|
||||
query_cache_size = 8M
|
||||
query_cache_limit = 2M
|
||||
|
||||
ft_min_word_len = 4
|
||||
|
||||
log_bin = mysql-bin
|
||||
binlog_format = mixed
|
||||
expire_logs_days = 7
|
||||
|
||||
log_error = ${mariadb_data_dir}/mysql-error.log
|
||||
slow_query_log = 1
|
||||
long_query_time = 1
|
||||
slow_query_log_file = ${mariadb_data_dir}/mysql-slow.log
|
||||
|
||||
performance_schema = 0
|
||||
|
||||
#lower_case_table_names = 1
|
||||
|
||||
skip-external-locking
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
innodb_file_per_table = 1
|
||||
innodb_open_files = 500
|
||||
innodb_buffer_pool_size = 64M
|
||||
innodb_write_io_threads = 4
|
||||
innodb_read_io_threads = 4
|
||||
innodb_purge_threads = 1
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 2M
|
||||
innodb_log_file_size = 32M
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_lock_wait_timeout = 120
|
||||
|
||||
bulk_insert_buffer_size = 8M
|
||||
myisam_sort_buffer_size = 8M
|
||||
myisam_max_sort_file_size = 10G
|
||||
|
||||
interactive_timeout = 28800
|
||||
wait_timeout = 28800
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
max_allowed_packet = 500M
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
read_buffer = 4M
|
||||
write_buffer = 4M
|
||||
EOF
|
||||
|
||||
sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
|
||||
if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
|
||||
fi
|
||||
|
||||
${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
|
||||
|
||||
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
|
||||
chown mysql.mysql -R ${mariadb_data_dir}
|
||||
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
|
||||
service mysqld start
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mariadb_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mariadb_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mariadb_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mariadb.%';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
|
||||
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
|
||||
echo "${mariadb_install_dir}/lib" > /etc/ld.so.conf.d/z-mariadb.conf
|
||||
ldconfig
|
||||
service mysqld stop
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MongoDB() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mongod >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -s /sbin/nologin mongod
|
||||
mkdir -p ${mongo_data_dir};chown mongod.mongod -R ${mongo_data_dir}
|
||||
tar xzf mongodb-linux-x86_64-${mongodb_ver}.tgz
|
||||
/bin/mv mongodb-linux-x86_64-${mongodb_ver} ${mongo_install_dir}
|
||||
/bin/cp ${oneinstack_dir}/services/mongod.service /lib/systemd/system/
|
||||
sed -i "s@=/usr/local/mongodb@=${mongo_install_dir}@g" /lib/systemd/system/mongod.service
|
||||
systemctl enable mongod
|
||||
|
||||
cat > /etc/mongod.conf << EOF
|
||||
# mongod.conf
|
||||
|
||||
# for documentation of all options, see:
|
||||
# http://docs.mongodb.org/manual/reference/configuration-options/
|
||||
|
||||
# where to write logging data.
|
||||
systemLog:
|
||||
destination: file
|
||||
logAppend: true
|
||||
path: ${mongo_data_dir}/mongod.log
|
||||
|
||||
# Where and how to store data.
|
||||
storage:
|
||||
dbPath: ${mongo_data_dir}
|
||||
journal:
|
||||
enabled: true
|
||||
# engine:
|
||||
# mmapv1:
|
||||
# wiredTiger:
|
||||
|
||||
# how the process runs
|
||||
processManagement:
|
||||
fork: true # fork and run in background
|
||||
pidFilePath: /var/run/mongodb/mongod.pid
|
||||
|
||||
# network interfaces
|
||||
net:
|
||||
port: 27017
|
||||
bindIp: 0.0.0.0
|
||||
unixDomainSocket:
|
||||
enabled: false
|
||||
|
||||
#security:
|
||||
# authorization: enabled
|
||||
|
||||
#operationProfiling:
|
||||
#replication:
|
||||
#sharding:
|
||||
EOF
|
||||
systemctl start mongod
|
||||
echo ${mongo_install_dir}/bin/mongo 127.0.0.1/admin --eval \"db.createUser\(\{user:\'root\',pwd:\'$dbmongopwd\',roles:[\'userAdminAnyDatabase\']\}\)\" | bash
|
||||
sed -i 's@^#security:@security:@' /etc/mongod.conf
|
||||
sed -i 's@^# authorization:@ authorization:@' /etc/mongod.conf
|
||||
if [ -e "${mongo_install_dir}/bin/mongo" ]; then
|
||||
sed -i "s+^dbmongopwd.*+dbmongopwd='$dbmongopwd'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MongoDB installed successfully! ${CEND}"
|
||||
rm -rf mongodb-linux-x86_64-${mongodb_ver}
|
||||
else
|
||||
rm -rf ${mongo_install_dir} ${mongo_data_dir}
|
||||
echo "${CFAILURE}MongoDB install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mongo_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mongo_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mongo_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MySQL57() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mysql >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
|
||||
|
||||
[ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
|
||||
mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
|
||||
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
tar xzf mysql-${mysql57_ver}-linux-glibc2.12-x86_64.tar.gz
|
||||
mv mysql-${mysql57_ver}-linux-glibc2.12-x86_64/* ${mysql_install_dir}
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
|
||||
sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
boostVersion2=$(echo ${boost_oldver} | awk -F. '{print $1"_"$2"_"$3}')
|
||||
tar xzf boost_${boostVersion2}.tar.gz
|
||||
tar xzf mysql-${mysql57_ver}.tar.gz
|
||||
pushd mysql-${mysql57_ver}
|
||||
cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
|
||||
-DMYSQL_DATADIR=${mysql_data_dir} \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=../boost_${boostVersion2} \
|
||||
-DSYSCONFDIR=/etc \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_PARTITION_STORAGE_ENGINE=1 \
|
||||
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
|
||||
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DWITH_EMBEDDED_SERVER=1 \
|
||||
-DENABLE_DTRACE=0 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DDEFAULT_CHARSET=utf8mb4 \
|
||||
-DDEFAULT_COLLATION=utf8mb4_general_ci \
|
||||
-DEXTRA_CHARSETS=all \
|
||||
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ -d "${mysql_install_dir}/support-files" ]; then
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
rm -rf mysql-${mysql57_ver}-*-x86_64
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
rm -rf mysql-${mysql57_ver} boost_${boostVersion2}
|
||||
fi
|
||||
else
|
||||
rm -rf ${mysql_install_dir}
|
||||
echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
/bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
|
||||
sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
|
||||
sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
|
||||
chmod +x /etc/init.d/mysqld
|
||||
[ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
|
||||
[ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
|
||||
popd
|
||||
|
||||
# my.cnf
|
||||
cat > /etc/my.cnf << EOF
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
|
||||
[mysql]
|
||||
prompt="MySQL [\\d]> "
|
||||
no-auto-rehash
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
|
||||
basedir = ${mysql_install_dir}
|
||||
datadir = ${mysql_data_dir}
|
||||
pid-file = ${mysql_data_dir}/mysql.pid
|
||||
user = mysql
|
||||
bind-address = 0.0.0.0
|
||||
server-id = 1
|
||||
|
||||
init-connect = 'SET NAMES utf8mb4'
|
||||
character-set-server = utf8mb4
|
||||
|
||||
skip-name-resolve
|
||||
#skip-networking
|
||||
back_log = 300
|
||||
|
||||
max_connections = 1000
|
||||
max_connect_errors = 6000
|
||||
open_files_limit = 65535
|
||||
table_open_cache = 128
|
||||
max_allowed_packet = 500M
|
||||
binlog_cache_size = 1M
|
||||
max_heap_table_size = 8M
|
||||
tmp_table_size = 16M
|
||||
|
||||
read_buffer_size = 2M
|
||||
read_rnd_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
join_buffer_size = 8M
|
||||
key_buffer_size = 4M
|
||||
|
||||
thread_cache_size = 8
|
||||
|
||||
query_cache_type = 1
|
||||
query_cache_size = 8M
|
||||
query_cache_limit = 2M
|
||||
|
||||
ft_min_word_len = 4
|
||||
|
||||
log_bin = mysql-bin
|
||||
binlog_format = mixed
|
||||
expire_logs_days = 7
|
||||
|
||||
log_error = ${mysql_data_dir}/mysql-error.log
|
||||
slow_query_log = 1
|
||||
long_query_time = 1
|
||||
slow_query_log_file = ${mysql_data_dir}/mysql-slow.log
|
||||
|
||||
performance_schema = 0
|
||||
explicit_defaults_for_timestamp
|
||||
|
||||
#lower_case_table_names = 1
|
||||
|
||||
skip-external-locking
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
#default-storage-engine = MyISAM
|
||||
innodb_file_per_table = 1
|
||||
innodb_open_files = 500
|
||||
innodb_buffer_pool_size = 64M
|
||||
innodb_write_io_threads = 4
|
||||
innodb_read_io_threads = 4
|
||||
innodb_thread_concurrency = 0
|
||||
innodb_purge_threads = 1
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 2M
|
||||
innodb_log_file_size = 32M
|
||||
innodb_log_files_in_group = 3
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_lock_wait_timeout = 120
|
||||
|
||||
bulk_insert_buffer_size = 8M
|
||||
myisam_sort_buffer_size = 8M
|
||||
myisam_max_sort_file_size = 10G
|
||||
|
||||
interactive_timeout = 28800
|
||||
wait_timeout = 28800
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
max_allowed_packet = 500M
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
read_buffer = 4M
|
||||
write_buffer = 4M
|
||||
EOF
|
||||
|
||||
sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
|
||||
if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
|
||||
sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
|
||||
fi
|
||||
|
||||
${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
|
||||
|
||||
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
|
||||
chown mysql.mysql -R ${mysql_data_dir}
|
||||
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
|
||||
service mysqld start
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mysql_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
|
||||
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
|
||||
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
|
||||
[ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf
|
||||
echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf
|
||||
ldconfig
|
||||
service mysqld stop
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MySQL80() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u mysql >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
|
||||
|
||||
[ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
|
||||
mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
|
||||
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
tar xJf mysql-${mysql80_ver}-linux-glibc2.12-x86_64.tar.xz
|
||||
mv mysql-${mysql80_ver}-linux-glibc2.12-x86_64/* ${mysql_install_dir}
|
||||
sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}')
|
||||
tar xzf boost_${boostVersion2}.tar.gz
|
||||
tar xzf mysql-${mysql80_ver}.tar.gz
|
||||
pushd mysql-${mysql80_ver}
|
||||
[ -e "/usr/bin/cmake3" ] && CMAKE=cmake3 || CMAKE=cmake
|
||||
$CMAKE . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
|
||||
-DMYSQL_DATADIR=${mysql_data_dir} \
|
||||
-DDOWNLOAD_BOOST=1 \
|
||||
-DWITH_BOOST=../boost_${boostVersion2} \
|
||||
-DFORCE_INSOURCE_BUILD=1 \
|
||||
-DSYSCONFDIR=/etc \
|
||||
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
|
||||
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
|
||||
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
|
||||
-DWITH_MYISAM_STORAGE_ENGINE=1 \
|
||||
-DENABLED_LOCAL_INFILE=1 \
|
||||
-DFORCE_INSOURCE_BUILD=1 \
|
||||
-DCMAKE_C_COMPILER=/usr/bin/gcc \
|
||||
-DCMAKE_CXX_COMPILER=/usr/bin/g++ \
|
||||
-DDEFAULT_CHARSET=utf8mb4
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
popd
|
||||
fi
|
||||
|
||||
# backup openssl so
|
||||
#[ ! -e "${mysql_install_dir}/lib/lib_bk" ] && mkdir ${mysql_install_dir}/lib/lib_bk
|
||||
#/bin/mv ${mysql_install_dir}/lib/{libssl,libcrypto}.so* ${mysql_install_dir}/lib/lib_bk/
|
||||
|
||||
if [ -d "${mysql_install_dir}/support-files" ]; then
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../config/options.conf
|
||||
echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
|
||||
if [ "${dbinstallmethod}" == "1" ]; then
|
||||
rm -rf mysql-${mysql80_ver}-*-x86_64
|
||||
elif [ "${dbinstallmethod}" == "2" ]; then
|
||||
rm -rf mysql-${mysql80_ver} boost_${boostVersion2}
|
||||
fi
|
||||
else
|
||||
rm -rf ${mysql_install_dir}
|
||||
echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
/bin/cp ${mysql_install_dir}/support-files/mysql.server /etc/init.d/mysqld
|
||||
sed -i "s@^basedir=.*@basedir=${mysql_install_dir}@" /etc/init.d/mysqld
|
||||
sed -i "s@^datadir=.*@datadir=${mysql_data_dir}@" /etc/init.d/mysqld
|
||||
chmod +x /etc/init.d/mysqld
|
||||
[ "${PM}" == 'yum' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
|
||||
[ "${PM}" == 'apt-get' ] && update-rc.d mysqld defaults
|
||||
popd
|
||||
|
||||
# my.cnf
|
||||
cat > /etc/my.cnf << EOF
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysql]
|
||||
prompt="MySQL [\\d]> "
|
||||
no-auto-rehash
|
||||
|
||||
[mysqld]
|
||||
port = 3306
|
||||
socket = /tmp/mysql.sock
|
||||
default_authentication_plugin = mysql_native_password
|
||||
|
||||
basedir = ${mysql_install_dir}
|
||||
datadir = ${mysql_data_dir}
|
||||
pid-file = ${mysql_data_dir}/mysql.pid
|
||||
user = mysql
|
||||
bind-address = 0.0.0.0
|
||||
server-id = 1
|
||||
|
||||
init-connect = 'SET NAMES utf8mb4'
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_0900_ai_ci
|
||||
|
||||
skip-name-resolve
|
||||
#skip-networking
|
||||
back_log = 300
|
||||
|
||||
max_connections = 1000
|
||||
max_connect_errors = 6000
|
||||
open_files_limit = 65535
|
||||
table_open_cache = 128
|
||||
max_allowed_packet = 500M
|
||||
binlog_cache_size = 1M
|
||||
max_heap_table_size = 8M
|
||||
tmp_table_size = 16M
|
||||
|
||||
read_buffer_size = 2M
|
||||
read_rnd_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
join_buffer_size = 8M
|
||||
key_buffer_size = 4M
|
||||
|
||||
thread_cache_size = 8
|
||||
|
||||
ft_min_word_len = 4
|
||||
|
||||
log_bin = mysql-bin
|
||||
binlog_format = mixed
|
||||
binlog_expire_logs_seconds = 604800
|
||||
|
||||
log_error = ${mysql_data_dir}/mysql-error.log
|
||||
slow_query_log = 1
|
||||
long_query_time = 1
|
||||
slow_query_log_file = ${mysql_data_dir}/mysql-slow.log
|
||||
|
||||
performance_schema = 0
|
||||
explicit_defaults_for_timestamp
|
||||
|
||||
#lower_case_table_names = 1
|
||||
|
||||
skip-external-locking
|
||||
|
||||
default_storage_engine = InnoDB
|
||||
#default-storage-engine = MyISAM
|
||||
innodb_file_per_table = 1
|
||||
innodb_open_files = 500
|
||||
innodb_buffer_pool_size = 64M
|
||||
innodb_write_io_threads = 4
|
||||
innodb_read_io_threads = 4
|
||||
innodb_thread_concurrency = 0
|
||||
innodb_purge_threads = 1
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 2M
|
||||
innodb_log_file_size = 32M
|
||||
innodb_log_files_in_group = 3
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
innodb_lock_wait_timeout = 120
|
||||
|
||||
bulk_insert_buffer_size = 8M
|
||||
myisam_sort_buffer_size = 8M
|
||||
myisam_max_sort_file_size = 10G
|
||||
|
||||
interactive_timeout = 28800
|
||||
wait_timeout = 28800
|
||||
|
||||
[mysqldump]
|
||||
quick
|
||||
max_allowed_packet = 500M
|
||||
|
||||
[myisamchk]
|
||||
key_buffer_size = 8M
|
||||
sort_buffer_size = 8M
|
||||
read_buffer = 4M
|
||||
write_buffer = 4M
|
||||
EOF
|
||||
|
||||
sed -i "s@max_connections.*@max_connections = $((${Mem}/3))@" /etc/my.cnf
|
||||
if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 16M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
|
||||
elif [ ${Mem} -gt 3500 ]; then
|
||||
sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
|
||||
sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
|
||||
sed -i 's@^key_buffer_size.*@key_buffer_size = 256M@' /etc/my.cnf
|
||||
sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 1024M@' /etc/my.cnf
|
||||
sed -i 's@^tmp_table_size.*@tmp_table_size = 128M@' /etc/my.cnf
|
||||
sed -i 's@^table_open_cache.*@table_open_cache = 1024@' /etc/my.cnf
|
||||
fi
|
||||
|
||||
${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
|
||||
|
||||
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
|
||||
chown mysql.mysql -R ${mysql_data_dir}
|
||||
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
|
||||
service mysqld start
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${mysql_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${mysql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${mysql_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";"
|
||||
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;"
|
||||
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;"
|
||||
${mysql_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";"
|
||||
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
|
||||
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
|
||||
[ -e "${mysql_install_dir}/my.cnf" ] && rm -f ${mysql_install_dir}/my.cnf
|
||||
echo "${mysql_install_dir}/lib" > /etc/ld.so.conf.d/z-mysql.conf
|
||||
ldconfig
|
||||
service mysqld stop
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_PostgreSQL() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -u postgres >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -d ${pgsql_install_dir} -s /bin/bash postgres
|
||||
mkdir -p ${pgsql_data_dir};chown postgres.postgres -R ${pgsql_data_dir}
|
||||
tar xzf postgresql-${pgsql_ver}.tar.gz
|
||||
pushd postgresql-${pgsql_ver}
|
||||
./configure --prefix=$pgsql_install_dir
|
||||
make -j ${THREAD}
|
||||
make install
|
||||
chmod 755 ${pgsql_install_dir}
|
||||
chown -R postgres.postgres ${pgsql_install_dir}
|
||||
/bin/cp ${oneinstack_dir}/services/postgresql.service /lib/systemd/system/
|
||||
sed -i "s@=/usr/local/pgsql@=${pgsql_install_dir}@g" /lib/systemd/system/postgresql.service
|
||||
sed -i "s@PGDATA=.*@PGDATA=${pgsql_data_dir}@" /lib/systemd/system/postgresql.service
|
||||
systemctl enable postgresql
|
||||
popd
|
||||
su - postgres -c "${pgsql_install_dir}/bin/initdb -D ${pgsql_data_dir}"
|
||||
systemctl start postgresql
|
||||
sleep 5
|
||||
su - postgres -c "${pgsql_install_dir}/bin/psql -c \"alter user postgres with password '$dbpostgrespwd';\""
|
||||
sed -i 's@^host.*@#&@g' ${pgsql_data_dir}/pg_hba.conf
|
||||
sed -i 's@^local.*@#&@g' ${pgsql_data_dir}/pg_hba.conf
|
||||
echo 'local all all md5' >> ${pgsql_data_dir}/pg_hba.conf
|
||||
echo 'host all all 0.0.0.0/0 md5' >> ${pgsql_data_dir}/pg_hba.conf
|
||||
sed -i "s@^#listen_addresses.*@listen_addresses = '*'@" ${pgsql_data_dir}/postgresql.conf
|
||||
systemctl reload postgresql
|
||||
|
||||
if [ -e "${pgsql_install_dir}/bin/psql" ]; then
|
||||
sed -i "s+^dbpostgrespwd.*+dbpostgrespwd='$dbpostgrespwd'+" ../config/options.conf
|
||||
echo "${CSUCCESS}PostgreSQL installed successfully! ${CEND}"
|
||||
else
|
||||
rm -rf ${pgsql_install_dir} ${pgsql_data_dir}
|
||||
echo "${CFAILURE}PostgreSQL install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd
|
||||
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${pgsql_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${pgsql_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${pgsql_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_PureFTPd() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -g ${run_group} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && groupadd ${run_group}
|
||||
id -u ${run_user} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user}
|
||||
|
||||
tar xzf pure-ftpd-${pureftpd_ver}.tar.gz
|
||||
pushd pure-ftpd-${pureftpd_ver} > /dev/null
|
||||
[ ! -d "${pureftpd_install_dir}" ] && mkdir -p ${pureftpd_install_dir}
|
||||
./configure --prefix=${pureftpd_install_dir} CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg --with-throttling --with-uploadscript --with-language=english --with-tls
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ]; then
|
||||
/bin/cp ../services/pureftpd.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /lib/systemd/system/pureftpd.service
|
||||
systemctl enable pureftpd
|
||||
|
||||
[ ! -e "${pureftpd_install_dir}/etc" ] && mkdir ${pureftpd_install_dir}/etc
|
||||
/bin/cp ../config/pure-ftpd.conf ${pureftpd_install_dir}/etc
|
||||
sed -i "s@^PureDB.*@PureDB ${pureftpd_install_dir}/etc/pureftpd.pdb@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
|
||||
sed -i "s@^LimitRecursion.*@LimitRecursion 65535 8@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
|
||||
IPADDR=${IPADDR:-127.0.0.1}
|
||||
[ ! -d /etc/ssl/private ] && mkdir -p /etc/ssl/private
|
||||
openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048
|
||||
openssl req -x509 -days 7300 -sha256 -nodes -subj "/C=CN/ST=Shanghai/L=Shanghai/O=OneinStack/CN=${IPADDR}" -newkey rsa:2048 -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem
|
||||
chmod 600 /etc/ssl/private/pure-ftpd*.pem
|
||||
sed -i "s@^# TLS.*@&\nCertFile /etc/ssl/private/pure-ftpd.pem@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
|
||||
sed -i "s@^# TLS.*@&\nTLSCipherSuite HIGH:MEDIUM:+TLSv1:\!SSLv2:\!SSLv3@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
|
||||
sed -i "s@^# TLS.*@TLS 1@" ${pureftpd_install_dir}/etc/pure-ftpd.conf
|
||||
ulimit -s unlimited
|
||||
systemctl start pureftpd
|
||||
|
||||
# iptables Ftp
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -z "$(grep '20000:30000' /etc/sysconfig/iptables)" ]; then
|
||||
iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
|
||||
iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
|
||||
service iptables save
|
||||
ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
|
||||
ip6tables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
|
||||
service ip6tables save
|
||||
fi
|
||||
elif [ "${PM}" == 'apt-get' ]; then
|
||||
if [ -e '/etc/iptables/rules.v4' ]; then
|
||||
if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep '20000:30000' /etc/iptables/rules.v4)" ]; then
|
||||
iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
|
||||
iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
|
||||
iptables-save > /etc/iptables/rules.v4
|
||||
ip6tables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
|
||||
ip6tables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
|
||||
ip6tables-save > /etc/iptables/rules.v6
|
||||
fi
|
||||
elif [ -e '/etc/iptables.up.rules' ]; then
|
||||
if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -z "$(grep '20000:30000' /etc/iptables.up.rules)" ]; then
|
||||
iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
|
||||
iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
|
||||
iptables-save > /etc/iptables.up.rules
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${CSUCCESS}Pure-Ftp installed successfully! ${CEND}"
|
||||
rm -rf pure-ftpd-${pureftpd_ver}
|
||||
else
|
||||
rm -rf ${pureftpd_install_dir}
|
||||
echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_GraphicsMagick() {
|
||||
if [ -d "${gmagick_install_dir}" ]; then
|
||||
echo "${CWARNING}GraphicsMagick already installed! ${CEND}"
|
||||
else
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
tar xzf GraphicsMagick-${graphicsmagick_ver}.tar.gz
|
||||
pushd GraphicsMagick-${graphicsmagick_ver} > /dev/null
|
||||
./configure --prefix=${gmagick_install_dir} --enable-shared --enable-static --enable-symbol-prefix
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf GraphicsMagick-${graphicsmagick_ver}
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_GraphicsMagick() {
|
||||
if [ -d "${gmagick_install_dir}" ]; then
|
||||
rm -rf ${gmagick_install_dir}
|
||||
echo; echo "${CMSG}GraphicsMagick uninstall completed${CEND}"
|
||||
fi
|
||||
}
|
||||
|
||||
Install_pecl_gmagick() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
if [ "`${php_install_dir}/bin/php-config --version | awk -F. '{print $1}'`" == '5' ]; then
|
||||
tar xzf gmagick-${gmagick_oldver}.tgz
|
||||
pushd gmagick-${gmagick_oldver} > /dev/null
|
||||
else
|
||||
tar xzf gmagick-${gmagick_ver}.tgz
|
||||
pushd gmagick-${gmagick_ver} > /dev/null
|
||||
fi
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --with-gmagick=${gmagick_install_dir}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/gmagick.so" ]; then
|
||||
echo 'extension=gmagick.so' > ${php_install_dir}/etc/php.d/03-gmagick.ini
|
||||
echo "${CSUCCESS}PHP gmagick module installed successfully! ${CEND}"
|
||||
rm -rf gmagick-${gmagick_ver} gmagick-${gmagick_oldver}
|
||||
else
|
||||
echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_gmagick() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/03-gmagick.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/03-gmagick.ini
|
||||
echo; echo "${CMSG}PHP gmagick module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP gmagick module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_ImageMagick() {
|
||||
if [ -d "${imagick_install_dir}" ]; then
|
||||
echo "${CWARNING}ImageMagick already installed! ${CEND}"
|
||||
else
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
tar xzf ImageMagick-${imagemagick_ver}.tar.gz
|
||||
#if [ "${PM}" == 'yum' ]; then
|
||||
# yum -y install libwebp-devel
|
||||
#elif [ "${PM}" == 'apt-get' ]; then
|
||||
# yum -y install libwebp-dev
|
||||
#fi
|
||||
pushd ImageMagick-${imagemagick_ver} > /dev/null
|
||||
./configure --prefix=${imagick_install_dir} --enable-shared --enable-static
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf ImageMagick-${imagemagick_ver}
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_ImageMagick() {
|
||||
if [ -d "${imagick_install_dir}" ]; then
|
||||
rm -rf ${imagick_install_dir}
|
||||
echo; echo "${CMSG}ImageMagick uninstall completed${CEND}"
|
||||
fi
|
||||
}
|
||||
|
||||
Install_pecl_imagick() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
if [[ "${PHP_main_ver}" =~ ^5.3$ ]]; then
|
||||
tar xzf imagick-${imagick_oldver}.tgz
|
||||
pushd imagick-${imagick_oldver} > /dev/null
|
||||
else
|
||||
tar xzf imagick-${imagick_ver}.tgz
|
||||
pushd imagick-${imagick_ver} > /dev/null
|
||||
fi
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=${imagick_install_dir}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/imagick.so" ]; then
|
||||
echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/03-imagick.ini
|
||||
echo "${CSUCCESS}PHP imagick module installed successfully! ${CEND}"
|
||||
rm -rf imagick-${imagick_ver} imagick-${imagick_oldver}
|
||||
else
|
||||
echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_imagick() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/03-imagick.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/03-imagick.ini
|
||||
echo; echo "${CMSG}PHP imagick module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP imagick module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_Nodejs() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
tar xzf node-v${nodejs_ver}-linux-${SYS_ARCH_n}.tar.gz
|
||||
/bin/mv node-v${nodejs_ver}-linux-${SYS_ARCH_n} ${nodejs_install_dir}
|
||||
if [ -e "${nodejs_install_dir}/bin/node" ]; then
|
||||
cat > /etc/profile.d/nodejs.sh << EOF
|
||||
export NODE_HOME=${nodejs_install_dir}
|
||||
export PATH=\$NODE_HOME/bin:\$PATH
|
||||
EOF
|
||||
. /etc/profile
|
||||
echo "${CSUCCESS}Nodejs installed successfully! ${CEND}"
|
||||
else
|
||||
echo "${CFAILURE}Nodejs install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
Uninstall_Nodejs() {
|
||||
if [ -e "${nodejs_install_dir}" ]; then
|
||||
rm -rf ${nodejs_install_dir} /etc/profile.d/nodejs.sh
|
||||
echo "${CMSG}Nodejs uninstall completed! ${CEND}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_Python() {
|
||||
if [ -e "${python_install_dir}/bin/python" ]; then
|
||||
echo "${CWARNING}Python already installed! ${CEND}"
|
||||
else
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
[ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
|
||||
pkgList="gcc dialog augeas-libs openssl openssl-devel libffi-devel redhat-rpm-config ca-certificates"
|
||||
for Package in ${pkgList}; do
|
||||
yum -y install ${Package}
|
||||
done
|
||||
elif [ "${PM}" == 'apt-get' ]; then
|
||||
pkgList="gcc dialog libaugeas0 augeas-lenses libssl-dev libffi-dev ca-certificates"
|
||||
for Package in ${pkgList}; do
|
||||
apt-get -y install $Package
|
||||
done
|
||||
fi
|
||||
|
||||
# Install Python3
|
||||
if [ ! -e "${python_install_dir}/bin/python" -a ! -e "${python_install_dir}/bin/python3" ] ;then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/Python-${python_ver}.tgz && Download_src
|
||||
tar xzf Python-${python_ver}.tgz
|
||||
pushd Python-${python_ver} > /dev/null
|
||||
./configure --prefix=${python_install_dir}
|
||||
make && make install
|
||||
[ ! -e "${python_install_dir}/bin/python" -a -e "${python_install_dir}/bin/python3" ] && ln -s ${python_install_dir}/bin/python{3,}
|
||||
[ ! -e "${python_install_dir}/bin/pip" -a -e "${python_install_dir}/bin/pip3" ] && ln -s ${python_install_dir}/bin/pip{3,}
|
||||
popd > /dev/null
|
||||
fi
|
||||
|
||||
if [ ! -e "${python_install_dir}/bin/pip" ]; then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/setuptools-${setuptools_ver}.zip && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/pip-${pip_ver}.tar.gz && Download_src
|
||||
unzip -q setuptools-${setuptools_ver}.zip
|
||||
tar xzf pip-${pip_ver}.tar.gz
|
||||
pushd setuptools-${setuptools_ver} > /dev/null
|
||||
${python_install_dir}/bin/python setup.py install
|
||||
popd > /dev/null
|
||||
pushd pip-${pip_ver} > /dev/null
|
||||
${python_install_dir}/bin/python setup.py install
|
||||
popd > /dev/null
|
||||
fi
|
||||
|
||||
if [ ! -e "/root/.pip/pip.conf" ] ;then
|
||||
# get the IP information
|
||||
PUBLIC_IPADDR=$(../lib/py/get_public_ipaddr.py)
|
||||
IPADDR_COUNTRY=$(../lib/py/get_ipaddr_state.py ${PUBLIC_IPADDR})
|
||||
if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
|
||||
[ ! -d "/root/.pip" ] && mkdir /root/.pip
|
||||
echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "${python_install_dir}/bin/python3" ]; then
|
||||
echo "${CSUCCESS}Python ${python_ver} installed successfully! ${CEND}"
|
||||
rm -rf Python-${python_ver}
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_Python() {
|
||||
if [ -e "${python_install_dir}/bin/python" ]; then
|
||||
echo "${CMSG}Python uninstall completed${CEND}"
|
||||
rm -rf ${python_install_dir}
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_ZendGuardLoader() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
[ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
|
||||
if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ] && [ "${armplatform}" != 'y' ]; then
|
||||
case "${PHP_main_ver}" in
|
||||
5.6)
|
||||
tar xzf zend-loader-php5.6-linux-x86_64.tar.gz
|
||||
/bin/mv zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
|
||||
rm -rf zend-loader-php5.6-linux-x86_64
|
||||
;;
|
||||
5.5)
|
||||
tar xzf zend-loader-php5.5-linux-x86_64.tar.gz
|
||||
/bin/mv zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
|
||||
rm -rf zend-loader-php5.5-linux-x86_64
|
||||
;;
|
||||
5.4)
|
||||
tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
|
||||
/bin/mv ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
|
||||
rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
|
||||
;;
|
||||
5.3)
|
||||
tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
|
||||
/bin/mv ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
|
||||
rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64
|
||||
;;
|
||||
*)
|
||||
echo "${CWARNING}Your php ${PHP_detail_ver} does not support ZendGuardLoader! ${CEND}";
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
|
||||
chmod 644 ${phpExtensionDir}/ZendGuardLoader.so
|
||||
cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
|
||||
[Zend Guard Loader]
|
||||
zend_extension=${phpExtensionDir}/ZendGuardLoader.so
|
||||
zend_loader.enable=1
|
||||
zend_loader.disable_licensing=0
|
||||
zend_loader.obfuscation_level_support=3
|
||||
EOF
|
||||
echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
|
||||
fi
|
||||
else
|
||||
echo "Error! Your Apache's prefork or PHP already enable thread safety or platform ${TARGET_ARCH} does not support ZendGuardLoader! "
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_ZendGuardLoader() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini
|
||||
echo; echo "${CMSG}PHP ZendGuardLoader module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP ZendGuardLoader module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_APCU() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
if [ "`${php_install_dir}/bin/php-config --version | awk -F. '{print $1}'`" == '5' ]; then
|
||||
tar xzf apcu-${apcu_oldver}.tgz
|
||||
pushd apcu-${apcu_oldver} > /dev/null
|
||||
else
|
||||
tar xzf apcu-${apcu_ver}.tgz
|
||||
pushd apcu-${apcu_ver} > /dev/null
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
if [ -f "${phpExtensionDir}/apcu.so" ]; then
|
||||
cat > ${php_install_dir}/etc/php.d/02-apcu.ini << EOF
|
||||
[apcu]
|
||||
extension=apcu.so
|
||||
apc.enabled=1
|
||||
apc.shm_size=32M
|
||||
apc.ttl=7200
|
||||
apc.enable_cli=1
|
||||
EOF
|
||||
/bin/cp apc.php ${wwwroot_dir}/default
|
||||
popd > /dev/null
|
||||
echo "${CSUCCESS}PHP apcu module installed successfully! ${CEND}"
|
||||
rm -rf apcu-${apcu_ver} apcu-${apcu_oldver} package.xml
|
||||
else
|
||||
echo "${CFAILURE}PHP apcu module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_APCU() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/02-apcu.ini" ]; then
|
||||
rm -rf ${php_install_dir}/etc/php.d/02-apcu.ini ${wwwroot_dir}/default/apc.php
|
||||
echo; echo "${CMSG}PHP apcu module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP apcu module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_composer() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
if [ -e "/usr/local/bin/composer" ]; then
|
||||
echo "${CWARNING}PHP Composer already installed! ${CEND}"
|
||||
else
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
# get the IP information
|
||||
PUBLIC_IPADDR=$(../lib/py/get_public_ipaddr.py)
|
||||
IPADDR_COUNTRY=$(../lib/py/get_ipaddr_state.py ${PUBLIC_IPADDR})
|
||||
if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
|
||||
wget -c https://mirrors.aliyun.com/composer/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
|
||||
${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
|
||||
else
|
||||
wget -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
|
||||
fi
|
||||
chmod +x /usr/local/bin/composer
|
||||
if [ -e "/usr/local/bin/composer" ]; then
|
||||
echo; echo "${CSUCCESS}PHP Composer installed successfully! ${CEND}"
|
||||
else
|
||||
echo; echo "${CFAILURE}PHP Composer install failed, Please try again! ${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_composer() {
|
||||
if [ -e "/usr/local/bin/composer" ]; then
|
||||
rm -f /usr/local/bin/composer
|
||||
echo; echo "${CMSG}Composer uninstall completed${CEND}";
|
||||
else
|
||||
echo; echo "${CWARNING}Composer does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_eAccelerator() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
|
||||
if [ "${PHP_main_ver}" == '5.3' ]; then
|
||||
tar jxf eaccelerator-${eaccelerator_ver}.tar.bz2
|
||||
pushd eaccelerator-${eaccelerator_ver} > /dev/null
|
||||
elif [ "${PHP_main_ver}" == '5.4' ]; then
|
||||
/bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
|
||||
tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
|
||||
pushd eaccelerator-eaccelerator-42067ac > /dev/null
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then
|
||||
mkdir /var/eaccelerator_cache;chown -R ${run_user}:${run_group} /var/eaccelerator_cache
|
||||
cat > ${php_install_dir}/etc/php.d/02-eaccelerator.ini << EOF
|
||||
[eaccelerator]
|
||||
zend_extension=${phpExtensionDir}/eaccelerator.so
|
||||
eaccelerator.shm_size=64
|
||||
eaccelerator.cache_dir=/var/eaccelerator_cache
|
||||
eaccelerator.enable=1
|
||||
eaccelerator.optimizer=1
|
||||
eaccelerator.check_mtime=1
|
||||
eaccelerator.debug=0
|
||||
eaccelerator.filter=
|
||||
eaccelerator.shm_max=0
|
||||
eaccelerator.shm_ttl=0
|
||||
eaccelerator.shm_prune_period=0
|
||||
eaccelerator.shm_only=0
|
||||
eaccelerator.compress=0
|
||||
eaccelerator.compress_level=9
|
||||
eaccelerator.keys=disk_only
|
||||
eaccelerator.sessions=disk_only
|
||||
eaccelerator.content=disk_only
|
||||
EOF
|
||||
[ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf
|
||||
sysctl -p
|
||||
echo "${CSUCCESS}PHP eaccelerator module installed successfully! ${CEND}"
|
||||
rm -rf eaccelerator-${eaccelerator_ver} eaccelerator-eaccelerator-42067ac
|
||||
else
|
||||
echo "${CFAILURE}PHP eaccelerator module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support eAccelerator! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_eAccelerator() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ]; then
|
||||
rm -rf ${php_install_dir}/etc/php.d/02-eaccelerator.ini /var/eaccelerator_cache
|
||||
echo; echo "${CMSG}PHP eaccelerator module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP eaccelerator module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_ionCube() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=`${php_install_dir}/bin/php-config --version`
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
[ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
|
||||
[ -e "ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz" ] && tar xzf ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz
|
||||
if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
|
||||
/bin/mv ioncube/ioncube_loader_lin_${PHP_main_ver}_ts.so ${phpExtensionDir}
|
||||
zend_extension="${phpExtensionDir}/ioncube_loader_lin_${PHP_main_ver}_ts.so"
|
||||
else
|
||||
/bin/mv ioncube/ioncube_loader_lin_${PHP_main_ver}.so ${phpExtensionDir}
|
||||
zend_extension="${phpExtensionDir}/ioncube_loader_lin_${PHP_main_ver}.so"
|
||||
fi
|
||||
|
||||
if [ -f "${zend_extension}" ]; then
|
||||
echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/00-ioncube.ini
|
||||
echo "${CSUCCESS}PHP ionCube module installed successfully! ${CEND}"
|
||||
rm -rf ioncube
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_ionCube() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/00-ioncube.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/00-ioncube.ini
|
||||
echo; echo "${CMSG}PHP ionCube module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP ionCube module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_calendar() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/calendar > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/calendar.so" ]; then
|
||||
echo 'extension=calendar.so' > ${php_install_dir}/etc/php.d/04-calendar.ini
|
||||
echo "${CSUCCESS}PHP calendar module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP calendar module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_calendar() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-calendar.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-calendar.ini
|
||||
echo; echo "${CMSG}PHP calendar module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP calendar module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_fileinfo() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/fileinfo > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
[[ "${php_option}" =~ ^[23]$ ]] && sed -i 's@^CFLAGS = -g -O2@CFLAGS = -std=c99 -g -O2@' Makefile
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/fileinfo.so" ]; then
|
||||
echo 'extension=fileinfo.so' > ${php_install_dir}/etc/php.d/04-fileinfo.ini
|
||||
echo "${CSUCCESS}PHP fileinfo module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP fileinfo module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_fileinfo() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-fileinfo.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-fileinfo.ini
|
||||
echo; echo "${CMSG}PHP fileinfo module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP fileinfo module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_imap() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
yum -y install libc-client-devel
|
||||
[ ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
|
||||
else
|
||||
apt-get -y install libc-client2007e-dev
|
||||
fi
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/imap > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --with-kerberos --with-imap --with-imap-ssl
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/imap.so" ]; then
|
||||
echo 'extension=imap.so' > ${php_install_dir}/etc/php.d/04-imap.ini
|
||||
echo "${CSUCCESS}PHP imap module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP imap module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_imap() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-imap.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-imap.ini
|
||||
echo; echo "${CMSG}PHP imap module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP imap module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_ldap() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/ldap > /dev/null
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
yum -y install openldap-devel
|
||||
else
|
||||
apt-get -y install libldap2-dev
|
||||
ln -s /usr/lib/${ARCH}-linux-gnu/libldap.so /usr/lib/
|
||||
ln -s /usr/lib/${ARCH}-linux-gnu/liblber.so /usr/lib/
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib64
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/ldap.so" ]; then
|
||||
echo 'extension=ldap.so' > ${php_install_dir}/etc/php.d/04-ldap.ini
|
||||
echo "${CSUCCESS}PHP ldap module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP ldap module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_ldap() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-ldap.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-ldap.ini
|
||||
echo; echo "${CMSG}PHP ldap module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP ldap module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_mongodb() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
if [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^5[3-4]$ ]]; then
|
||||
src_url=https://pecl.php.net/get/mongo-${pecl_mongo_ver}.tgz && Download_src
|
||||
tar xzf mongo-${pecl_mongo_ver}.tgz
|
||||
pushd mongo-${pecl_mongo_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/mongo.so" ]; then
|
||||
echo 'extension=mongo.so' > ${php_install_dir}/etc/php.d/07-mongo.ini
|
||||
rm -rf mongo-${pecl_mongo_ver}
|
||||
echo "${CSUCCESS}PHP mongo module installed successfully! ${CEND}"
|
||||
else
|
||||
echo "${CFAILURE}PHP mongo module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
if [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^7[0-2]$ ]]; then
|
||||
src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_oldver}.tgz && Download_src
|
||||
tar xzf mongodb-${pecl_mongodb_oldver}.tgz
|
||||
pushd mongodb-${pecl_mongodb_oldver} > /dev/null
|
||||
else
|
||||
src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src
|
||||
tar xzf mongodb-${pecl_mongodb_ver}.tgz
|
||||
pushd mongodb-${pecl_mongodb_ver} > /dev/null
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/mongodb.so" ]; then
|
||||
echo 'extension=mongodb.so' > ${php_install_dir}/etc/php.d/07-mongodb.ini
|
||||
echo "${CSUCCESS}PHP mongodb module installed successfully! ${CEND}"
|
||||
rm -rf mongodb-${pecl_mongodb_oldver} mongodb-${pecl_mongodb_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP mongodb module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_mongodb() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/07-mongo.ini
|
||||
echo; echo "${CMSG}PHP mongo module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP mongo module does not exist! ${CEND}"
|
||||
fi
|
||||
if [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini
|
||||
echo; echo "${CMSG}PHP mongodb module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP mongodb module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_pgsql() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/pgsql > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
pushd php-${PHP_detail_ver}/ext/pdo_pgsql > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-pdo-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/pgsql.so" -a -f "${phpExtensionDir}/pdo_pgsql.so" ]; then
|
||||
echo 'extension=pgsql.so' > ${php_install_dir}/etc/php.d/07-pgsql.ini
|
||||
echo 'extension=pdo_pgsql.so' >> ${php_install_dir}/etc/php.d/07-pgsql.ini
|
||||
echo "${CSUCCESS}PHP pgsql module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP pgsql module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_pgsql() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini
|
||||
echo; echo "${CMSG}PHP pgsql module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP pgsql module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_phalcon() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
if [[ "${PHP_main_ver}" =~ ^7.[2-4]$|^8.0$ ]]; then
|
||||
src_url=https://pecl.php.net/get/phalcon-${phalcon_ver}.tgz && Download_src
|
||||
tar xzf phalcon-${phalcon_ver}.tgz
|
||||
pushd phalcon-${phalcon_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
echo "${CMSG}It may take a few minutes... ${CEND}"
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
elif [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-1]$ ]]; then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/cphalcon-${phalcon_oldver}.tar.gz && Download_src
|
||||
tar xzf cphalcon-${phalcon_oldver}.tar.gz
|
||||
pushd cphalcon-${phalcon_oldver}/build > /dev/null
|
||||
echo "${CMSG}It may take a few minutes... ${CEND}"
|
||||
./install --phpize ${php_install_dir}/bin/phpize --php-config ${php_install_dir}/bin/php-config --arch 64bits
|
||||
popd > /dev/null
|
||||
else
|
||||
echo "${CWARNING}Your php ${PHP_detail_ver} does not support phalcon! ${CEND}"
|
||||
fi
|
||||
if [ -f "${phpExtensionDir}/phalcon.so" ]; then
|
||||
echo 'extension=phalcon.so' > ${php_install_dir}/etc/php.d/04-phalcon.ini
|
||||
echo "${CSUCCESS}PHP phalcon module installed successfully! ${CEND}"
|
||||
rm -rf cphalcon-${phalcon_oldver} phalcon-${phalcon_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP phalcon module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_phalcon() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-phalcon.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-phalcon.ini
|
||||
echo; echo "${CMSG}PHP phalcon module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP phalcon module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_swoole() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
|
||||
src_url=https://pecl.php.net/get/swoole-1.10.5.tgz && Download_src
|
||||
tar xzf swoole-1.10.5.tgz
|
||||
pushd swoole-1.10.5 > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
|
||||
elif [[ "${PHP_main_ver}" =~ ^7.[0-1]$ ]]; then
|
||||
src_url=https://pecl.php.net/get/swoole-${swoole_oldver}.tgz && Download_src
|
||||
tar xzf swoole-${swoole_oldver}.tgz
|
||||
pushd swoole-${swoole_oldver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
|
||||
else
|
||||
src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
|
||||
tar xzf swoole-${swoole_ver}.tgz
|
||||
pushd swoole-${swoole_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir} --enable-http2 --enable-swoole-json --enable-swoole-curl
|
||||
fi
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/swoole.so" ]; then
|
||||
echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
|
||||
echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}"
|
||||
rm -rf swoole-${swoole_ver} swoole-${swoole_oldver}
|
||||
else
|
||||
echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_swoole() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/06-swoole.ini
|
||||
echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_xdebug() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^80$ ]]; then
|
||||
if [[ "${PHP_main_ver}" =~ ^7.[0-1]$ ]]; then
|
||||
src_url=https://pecl.php.net/get/xdebug-${xdebug_oldver}.tgz && Download_src
|
||||
tar xzf xdebug-${xdebug_oldver}.tgz
|
||||
pushd xdebug-${xdebug_oldver} > /dev/null
|
||||
else
|
||||
src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
|
||||
tar xzf xdebug-${xdebug_ver}.tgz
|
||||
pushd xdebug-${xdebug_ver} > /dev/null
|
||||
fi
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/xdebug.so" ]; then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
|
||||
unzip -q webgrind-master.zip
|
||||
/bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
|
||||
[ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}:${run_group} /tmp/xdebug; }
|
||||
[ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}:${run_group} /tmp/webgrind; }
|
||||
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/webgrind
|
||||
sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
|
||||
sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
|
||||
cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
|
||||
[xdebug]
|
||||
zend_extension=xdebug.so
|
||||
xdebug.trace_output_dir=/tmp/xdebug
|
||||
xdebug.profiler_output_dir = /tmp/xdebug
|
||||
xdebug.profiler_enable = On
|
||||
xdebug.profiler_enable_trigger = 1
|
||||
EOF
|
||||
echo "${CSUCCESS}PHP xdebug module installed successfully! ${CEND}"
|
||||
echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
|
||||
rm -rf xdebug-${xdebug_ver} xdebug-${xdebug_oldver}
|
||||
else
|
||||
echo "${CFAILURE}PHP xdebug module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}Your php ${PHP_detail_ver} does not support xdebug! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_xdebug() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/08-xdebug.ini" ]; then
|
||||
rm -rf ${php_install_dir}/etc/php.d/08-xdebug.ini /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
|
||||
echo; echo "${CMSG}PHP xdebug module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP xdebug module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_yaf() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.0$ ]]; then
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
src_url=https://pecl.php.net/get/yaf-${yaf_ver}.tgz && Download_src
|
||||
tar xzf yaf-${yaf_ver}.tgz
|
||||
pushd yaf-${yaf_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/yaf.so" ]; then
|
||||
echo 'extension=yaf.so' > ${php_install_dir}/etc/php.d/04-yaf.ini
|
||||
echo "${CSUCCESS}PHP yaf module installed successfully! ${CEND}"
|
||||
rm -rf yaf-${yaf_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP yaf module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}Your php ${PHP_detail_ver} does not support yaf! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_yaf() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-yaf.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-yaf.ini
|
||||
echo; echo "${CMSG}PHP yaf module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP yaf module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_pecl_yar() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.0$ ]]; then
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
src_url=https://pecl.php.net/get/yar-${yar_ver}.tgz && Download_src
|
||||
tar xzf yar-${yar_ver}.tgz
|
||||
pushd yar-${yar_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config --with-curl=${curl_install_dir}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/yar.so" ]; then
|
||||
echo 'extension=yar.so' > ${php_install_dir}/etc/php.d/04-yar.ini
|
||||
echo "${CSUCCESS}PHP yar module installed successfully! ${CEND}"
|
||||
rm -rf yar-${yar_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP yar module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}Your php ${PHP_detail_ver} does not support yar! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_pecl_yar() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-yar.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/04-yar.ini
|
||||
echo; echo "${CMSG}PHP yar module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP yar module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_SourceGuardian() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
PHP_detail_ver=`${php_install_dir}/bin/php-config --version`
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
|
||||
[ ! -e sourceguardian ] && mkdir sourceguardian
|
||||
[ -e "loaders.linux-${ARCH}.tar.gz" ] && tar xzf loaders.linux-${ARCH}.tar.gz -C sourceguardian
|
||||
|
||||
if [ -e "sourceguardian/ixed.${PHP_main_ver}.lin" ]; then
|
||||
[ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
|
||||
if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
|
||||
/bin/mv sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
|
||||
extension="ixed.${PHP_main_ver}ts.lin"
|
||||
else
|
||||
/bin/mv sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
|
||||
extension="ixed.${PHP_main_ver}.lin"
|
||||
fi
|
||||
|
||||
if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
|
||||
echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
|
||||
echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}"
|
||||
rm -rf sourceguardian
|
||||
fi
|
||||
else
|
||||
echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support SourceGuardian! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_SourceGuardian() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/02-sourceguardian.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/02-sourceguardian.ini
|
||||
echo; echo "${CMSG}PHP SourceGuardian module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP SourceGuardian module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_XCache() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
|
||||
tar xzf xcache-${xcache_ver}.tar.gz
|
||||
pushd xcache-${xcache_ver} > /dev/null
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
if [ -f "${phpExtensionDir}/xcache.so" ]; then
|
||||
/bin/cp -R htdocs ${wwwroot_dir}/default/xcache
|
||||
popd > /dev/null
|
||||
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/xcache
|
||||
touch /tmp/xcache;chown ${run_user}:${run_group} /tmp/xcache
|
||||
let xcacheCount="${CPU}+1"
|
||||
let xcacheSize="${Memory_limit}/2"
|
||||
cat > ${php_install_dir}/etc/php.d/04-xcache.ini << EOF
|
||||
[xcache-common]
|
||||
extension=xcache.so
|
||||
[xcache.admin]
|
||||
xcache.admin.enable_auth=On
|
||||
xcache.admin.user=admin
|
||||
xcache.admin.pass="${xcachepwd_md5}"
|
||||
|
||||
[xcache]
|
||||
xcache.size=${xcacheSize}M
|
||||
xcache.count=${xcacheCount}
|
||||
xcache.slots=8K
|
||||
xcache.ttl=3600
|
||||
xcache.gc_interval=300
|
||||
xcache.var_size=4M
|
||||
xcache.var_count=${xcacheCount}
|
||||
xcache.var_slots=8K
|
||||
xcache.var_ttl=0
|
||||
xcache.var_maxttl=0
|
||||
xcache.var_gc_interval=300
|
||||
xcache.test=Off
|
||||
xcache.readonly_protection=Off
|
||||
xcache.shm_scheme=mmap
|
||||
xcache.mmap_path=/tmp/xcache
|
||||
xcache.coredump_directory=
|
||||
xcache.cacher=On
|
||||
xcache.stat=On
|
||||
xcache.optimizer=Off
|
||||
|
||||
[xcache.coverager]
|
||||
; enabling this feature will impact performance
|
||||
; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value"
|
||||
; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions
|
||||
xcache.coverager = Off
|
||||
xcache.coverager_autostart = On
|
||||
xcache.coveragedump_directory = ""
|
||||
EOF
|
||||
echo "${CSUCCESS}PHP xcache module installed successfully! ${CEND}"
|
||||
rm -rf xcache-${xcache_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP xcache module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
else
|
||||
echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support XCache! ${CEND}";
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_XCache() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/04-xcache.ini" ]; then
|
||||
rm -rf ${php_install_dir}/etc/php.d/04-xcache.ini ${wwwroot_dir}/default/xcache /tmp/xcache
|
||||
echo; echo "${CMSG}PHP xcache module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP xcache module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_ZendOPcache() {
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
|
||||
PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
|
||||
PHP_main_ver=${PHP_detail_ver%.*}
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
|
||||
tar xzf zendopcache-${zendopcache_ver}.tgz
|
||||
pushd zendopcache-${zendopcache_ver} > /dev/null
|
||||
else
|
||||
src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
|
||||
tar xzf php-${PHP_detail_ver}.tar.gz
|
||||
pushd php-${PHP_detail_ver}/ext/opcache > /dev/null
|
||||
fi
|
||||
|
||||
${php_install_dir}/bin/phpize
|
||||
./configure --with-php-config=${php_install_dir}/bin/php-config
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "${phpExtensionDir}/opcache.so" ]; then
|
||||
# write opcache configs
|
||||
if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
|
||||
# For php 5.3 5.4
|
||||
cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
|
||||
[opcache]
|
||||
zend_extension=${phpExtensionDir}/opcache.so
|
||||
opcache.enable=1
|
||||
opcache.memory_consumption=${Memory_limit}
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=4000
|
||||
opcache.revalidate_freq=60
|
||||
;opcache.save_comments=0
|
||||
opcache.fast_shutdown=1
|
||||
opcache.enable_cli=1
|
||||
;opcache.optimization_level=0
|
||||
EOF
|
||||
rm -rf zendopcache-${zendopcache_ver}
|
||||
else
|
||||
# For php 5.5+
|
||||
cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
|
||||
[opcache]
|
||||
zend_extension=opcache.so
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.memory_consumption=${Memory_limit}
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=100000
|
||||
opcache.max_wasted_percentage=5
|
||||
opcache.use_cwd=1
|
||||
opcache.validate_timestamps=1
|
||||
opcache.revalidate_freq=60
|
||||
;opcache.save_comments=0
|
||||
opcache.fast_shutdown=1
|
||||
opcache.consistency_checks=0
|
||||
;opcache.optimization_level=0
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "${CSUCCESS}PHP opcache module installed successfully! ${CEND}"
|
||||
rm -rf php-${PHP_detail_ver}
|
||||
else
|
||||
echo "${CFAILURE}PHP opcache module install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
Uninstall_ZendOPcache() {
|
||||
if [ -e "${php_install_dir}/etc/php.d/02-opcache.ini" ]; then
|
||||
rm -f ${php_install_dir}/etc/php.d/02-opcache.ini
|
||||
echo; echo "${CMSG}PHP opcache module uninstall completed${CEND}"
|
||||
else
|
||||
echo; echo "${CWARNING}PHP opcache module does not exist! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_MPHP() {
|
||||
if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
|
||||
if [ -e "${php_install_dir}${mphp_ver}/bin/phpize" ]; then
|
||||
echo "${CWARNING}PHP${mphp_ver} already installed! ${CEND}"
|
||||
else
|
||||
[ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service{,_bk}
|
||||
php_install_dir=${php_install_dir}${mphp_ver}
|
||||
case "${mphp_ver}" in
|
||||
74)
|
||||
. modules/php/php-7.4.sh
|
||||
Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/runtime/install.log
|
||||
;;
|
||||
80)
|
||||
. modules/php/php-8.0.sh
|
||||
Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/runtime/install.log
|
||||
;;
|
||||
81)
|
||||
. modules/php/php-8.1.sh
|
||||
Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/runtime/install.log
|
||||
;;
|
||||
esac
|
||||
if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
|
||||
systemctl stop php-fpm
|
||||
sed -i "s@/dev/shm/php-cgi.sock@/dev/shm/php${mphp_ver}-cgi.sock@" ${php_install_dir}/etc/php-fpm.conf
|
||||
[ -e "/lib/systemd/system/php-fpm.service" ] && /bin/mv /lib/systemd/system/php-fpm.service /lib/systemd/system/php${mphp_ver}-fpm.service
|
||||
[ -e "/lib/systemd/system/php-fpm.service_bk" ] && /bin/mv /lib/systemd/system/php-fpm.service{_bk,}
|
||||
systemctl enable php${mphp_ver}-fpm
|
||||
systemctl enable php-fpm
|
||||
systemctl start php-fpm
|
||||
systemctl start php${mphp_ver}-fpm
|
||||
sed -i "s@${php_install_dir}/bin:@@" /etc/profile
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}To use the multiple PHP versions, You need to use PHP-FPM! ${CEND}"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_PHP74() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
if [ ! -e "/usr/local/lib/libiconv.la" ]; then
|
||||
tar xzf libiconv-${libiconv_ver}.tar.gz
|
||||
pushd libiconv-${libiconv_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libiconv-${libiconv_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then
|
||||
tar xzf curl-${curl_ver}.tar.gz
|
||||
pushd curl-${curl_ver} > /dev/null
|
||||
./configure --prefix=${curl_install_dir} ${php74_with_ssl}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf curl-${curl_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then
|
||||
tar xzf freetype-${freetype_ver}.tar.gz
|
||||
pushd freetype-${freetype_ver} > /dev/null
|
||||
./configure --prefix=${freetype_install_dir} --enable-freetype-config
|
||||
make -j ${THREAD} && make install
|
||||
ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/
|
||||
[ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf freetype-${freetype_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then
|
||||
tar xzf argon2-${argon2_ver}.tar.gz
|
||||
pushd argon2-${argon2_ver} > /dev/null
|
||||
make -j ${THREAD} && make install
|
||||
[ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig
|
||||
/bin/cp libargon2.pc /usr/local/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf argon2-${argon2_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libsodium.la" ]; then
|
||||
tar xzf libsodium-${libsodium_ver}.tar.gz
|
||||
pushd libsodium-${libsodium_ver} > /dev/null
|
||||
./configure --disable-dependency-tracking --enable-minimal
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libsodium-${libsodium_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libzip.la" ]; then
|
||||
tar xzf libzip-${libzip_ver}.tar.gz
|
||||
pushd libzip-${libzip_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libzip-${libzip_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then
|
||||
tar xzf mhash-${mhash_ver}.tar.gz
|
||||
pushd mhash-${mhash_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf mhash-${mhash_ver}
|
||||
fi
|
||||
|
||||
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
|
||||
ldconfig
|
||||
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
[ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
|
||||
[ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
|
||||
fi
|
||||
|
||||
id -g ${run_group} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && groupadd ${run_group}
|
||||
id -u ${run_user} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user}
|
||||
|
||||
# PHP enables the sqlite3 extension by default; its configure step fails with
|
||||
# "Package 'sqlite3' not found" when libsqlite3-dev is missing. Install it on
|
||||
# demand so a skipped/partial dependency stage cannot break the PHP build.
|
||||
if ! pkg-config --exists sqlite3 >/dev/null 2>&1; then
|
||||
echo "${CMSG}Installing libsqlite3-dev (required by PHP sqlite3 extension)...${CEND}"
|
||||
apt-get -y install libsqlite3-dev
|
||||
fi
|
||||
|
||||
tar xzf php-${php74_ver}.tar.gz
|
||||
pushd php-${php74_ver} > /dev/null
|
||||
if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c
|
||||
fi
|
||||
make clean
|
||||
# Include the self-built curl's pkgconfig dir so PHP's pkg-config based
|
||||
# ext/curl detection (PKG_CHECK_MODULES libcurl) can find libcurl.pc.
|
||||
export PKG_CONFIG_PATH=${curl_install_dir}/lib/pkgconfig/:/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
|
||||
# PHP ext/curl uses pkg-config to locate libcurl; if it still can't be found
|
||||
# (self-built curl .pc missing), fall back to the system dev package.
|
||||
if ! pkg-config --exists libcurl >/dev/null 2>&1; then
|
||||
echo "${CMSG}libcurl.pc not found, installing libcurl4-openssl-dev...${CEND}"
|
||||
apt-get -y install libcurl4-openssl-dev
|
||||
fi
|
||||
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
|
||||
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
|
||||
./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \
|
||||
--with-config-file-scan-dir=${php_install_dir}/etc/php.d \
|
||||
--with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \
|
||||
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
|
||||
--with-iconv-dir=/usr/local --with-freetype --with-jpeg --with-zlib \
|
||||
--enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
|
||||
--enable-sysvsem --enable-inline-optimization ${php74_with_curl} --enable-mbregex \
|
||||
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php74_with_openssl} \
|
||||
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
|
||||
--with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options}
|
||||
make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
|
||||
make install
|
||||
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
[ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d
|
||||
echo "${CSUCCESS}PHP installed successfully! ${CEND}"
|
||||
else
|
||||
rm -rf ${php_install_dir}
|
||||
echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
# wget -c http://pear.php.net/go-pear.phar
|
||||
# ${php_install_dir}/bin/php go-pear.phar
|
||||
|
||||
/bin/cp php.ini-production ${php_install_dir}/etc/php.ini
|
||||
|
||||
sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini
|
||||
#sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini
|
||||
[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini
|
||||
if [ "${with_old_openssl_flag}" = 'y' ]; then
|
||||
sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
fi
|
||||
|
||||
[ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
|
||||
[opcache]
|
||||
zend_extension=opcache.so
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.memory_consumption=${Memory_limit}
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=100000
|
||||
opcache.max_wasted_percentage=5
|
||||
opcache.use_cwd=1
|
||||
opcache.validate_timestamps=1
|
||||
opcache.revalidate_freq=60
|
||||
;opcache.save_comments=0
|
||||
opcache.consistency_checks=0
|
||||
;opcache.optimization_level=0
|
||||
EOF
|
||||
|
||||
# php-fpm Init Script
|
||||
/bin/cp ${oneinstack_dir}/services/php-fpm.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service
|
||||
systemctl enable php-fpm
|
||||
|
||||
cat > ${php_install_dir}/etc/php-fpm.conf <<EOF
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
; FPM Configuration ;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
; Global Options ;
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[global]
|
||||
pid = run/php-fpm.pid
|
||||
error_log = log/php-fpm.log
|
||||
log_level = warning
|
||||
|
||||
emergency_restart_threshold = 30
|
||||
emergency_restart_interval = 60s
|
||||
process_control_timeout = 5s
|
||||
daemonize = yes
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
; Pool Definitions ;
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[${run_user}]
|
||||
listen = /dev/shm/php-cgi.sock
|
||||
listen.backlog = -1
|
||||
listen.allowed_clients = 127.0.0.1
|
||||
listen.owner = ${run_user}
|
||||
listen.group = ${run_group}
|
||||
listen.mode = 0666
|
||||
user = ${run_user}
|
||||
group = ${run_group}
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 12
|
||||
pm.start_servers = 8
|
||||
pm.min_spare_servers = 6
|
||||
pm.max_spare_servers = 12
|
||||
pm.max_requests = 2048
|
||||
pm.process_idle_timeout = 10s
|
||||
request_terminate_timeout = 120
|
||||
request_slowlog_timeout = 0
|
||||
|
||||
pm.status_path = /php-fpm_status
|
||||
slowlog = var/log/slow.log
|
||||
rlimit_files = 51200
|
||||
rlimit_core = 0
|
||||
|
||||
catch_workers_output = yes
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
env[TMP] = /tmp
|
||||
env[TMPDIR] = /tmp
|
||||
env[TEMP] = /tmp
|
||||
EOF
|
||||
|
||||
if [ $Mem -le 3000 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
fi
|
||||
|
||||
systemctl start php-fpm
|
||||
|
||||
popd > /dev/null
|
||||
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php74_ver}
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_PHP80() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
if [ ! -e "/usr/local/lib/libiconv.la" ]; then
|
||||
tar xzf libiconv-${libiconv_ver}.tar.gz
|
||||
pushd libiconv-${libiconv_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libiconv-${libiconv_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then
|
||||
tar xzf curl-${curl_ver}.tar.gz
|
||||
pushd curl-${curl_ver} > /dev/null
|
||||
./configure --prefix=${curl_install_dir} ${php80_with_ssl}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf curl-${curl_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then
|
||||
tar xzf freetype-${freetype_ver}.tar.gz
|
||||
pushd freetype-${freetype_ver} > /dev/null
|
||||
./configure --prefix=${freetype_install_dir} --enable-freetype-config
|
||||
make -j ${THREAD} && make install
|
||||
ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/
|
||||
[ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf freetype-${freetype_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then
|
||||
tar xzf argon2-${argon2_ver}.tar.gz
|
||||
pushd argon2-${argon2_ver} > /dev/null
|
||||
make -j ${THREAD} && make install
|
||||
[ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig
|
||||
/bin/cp libargon2.pc /usr/local/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf argon2-${argon2_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libsodium.la" ]; then
|
||||
tar xzf libsodium-${libsodium_ver}.tar.gz
|
||||
pushd libsodium-${libsodium_ver} > /dev/null
|
||||
./configure --disable-dependency-tracking --enable-minimal
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libsodium-${libsodium_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libzip.la" ]; then
|
||||
tar xzf libzip-${libzip_ver}.tar.gz
|
||||
pushd libzip-${libzip_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libzip-${libzip_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then
|
||||
tar xzf mhash-${mhash_ver}.tar.gz
|
||||
pushd mhash-${mhash_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf mhash-${mhash_ver}
|
||||
fi
|
||||
|
||||
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
|
||||
ldconfig
|
||||
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
[ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
|
||||
[ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
|
||||
fi
|
||||
|
||||
id -g ${run_group} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && groupadd ${run_group}
|
||||
id -u ${run_user} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user}
|
||||
|
||||
# PHP enables the sqlite3 extension by default; its configure step fails with
|
||||
# "Package 'sqlite3' not found" when libsqlite3-dev is missing. Install it on
|
||||
# demand so a skipped/partial dependency stage cannot break the PHP build.
|
||||
if ! pkg-config --exists sqlite3 >/dev/null 2>&1; then
|
||||
echo "${CMSG}Installing libsqlite3-dev (required by PHP sqlite3 extension)...${CEND}"
|
||||
apt-get -y install libsqlite3-dev
|
||||
fi
|
||||
|
||||
tar xzf php-${php80_ver}.tar.gz
|
||||
pushd php-${php80_ver} > /dev/null
|
||||
if [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c
|
||||
fi
|
||||
make clean
|
||||
# Include the self-built curl's pkgconfig dir so PHP's pkg-config based
|
||||
# ext/curl detection (PKG_CHECK_MODULES libcurl) can find libcurl.pc.
|
||||
export PKG_CONFIG_PATH=${curl_install_dir}/lib/pkgconfig/:/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
|
||||
# PHP ext/curl uses pkg-config to locate libcurl; if it still can't be found
|
||||
# (self-built curl .pc missing), fall back to the system dev package.
|
||||
if ! pkg-config --exists libcurl >/dev/null 2>&1; then
|
||||
echo "${CMSG}libcurl.pc not found, installing libcurl4-openssl-dev...${CEND}"
|
||||
apt-get -y install libcurl4-openssl-dev
|
||||
fi
|
||||
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
|
||||
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
|
||||
./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \
|
||||
--with-config-file-scan-dir=${php_install_dir}/etc/php.d \
|
||||
--with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \
|
||||
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
|
||||
--with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \
|
||||
--enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
|
||||
--enable-sysvsem ${php80_with_curl} --enable-mbregex \
|
||||
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php80_with_openssl} \
|
||||
--with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \
|
||||
--with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options}
|
||||
make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
|
||||
make install
|
||||
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
[ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d
|
||||
echo "${CSUCCESS}PHP installed successfully! ${CEND}"
|
||||
else
|
||||
rm -rf ${php_install_dir}
|
||||
echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
# wget -c http://pear.php.net/go-pear.phar
|
||||
# ${php_install_dir}/bin/php go-pear.phar
|
||||
|
||||
/bin/cp php.ini-production ${php_install_dir}/etc/php.ini
|
||||
|
||||
sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini
|
||||
#sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini
|
||||
[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini
|
||||
if [ "${with_old_openssl_flag}" = 'y' ]; then
|
||||
sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
fi
|
||||
|
||||
[ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
|
||||
[opcache]
|
||||
zend_extension=opcache.so
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.memory_consumption=${Memory_limit}
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=100000
|
||||
opcache.max_wasted_percentage=5
|
||||
opcache.use_cwd=1
|
||||
opcache.validate_timestamps=1
|
||||
opcache.revalidate_freq=60
|
||||
;opcache.save_comments=0
|
||||
opcache.consistency_checks=0
|
||||
;opcache.optimization_level=0
|
||||
EOF
|
||||
|
||||
# php-fpm Init Script
|
||||
/bin/cp ${oneinstack_dir}/services/php-fpm.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service
|
||||
systemctl enable php-fpm
|
||||
|
||||
cat > ${php_install_dir}/etc/php-fpm.conf <<EOF
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
; FPM Configuration ;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
; Global Options ;
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[global]
|
||||
pid = run/php-fpm.pid
|
||||
error_log = log/php-fpm.log
|
||||
log_level = warning
|
||||
|
||||
emergency_restart_threshold = 30
|
||||
emergency_restart_interval = 60s
|
||||
process_control_timeout = 5s
|
||||
daemonize = yes
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
; Pool Definitions ;
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[${run_user}]
|
||||
listen = /dev/shm/php-cgi.sock
|
||||
listen.backlog = -1
|
||||
listen.allowed_clients = 127.0.0.1
|
||||
listen.owner = ${run_user}
|
||||
listen.group = ${run_group}
|
||||
listen.mode = 0666
|
||||
user = ${run_user}
|
||||
group = ${run_group}
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 12
|
||||
pm.start_servers = 8
|
||||
pm.min_spare_servers = 6
|
||||
pm.max_spare_servers = 12
|
||||
pm.max_requests = 2048
|
||||
pm.process_idle_timeout = 10s
|
||||
request_terminate_timeout = 120
|
||||
request_slowlog_timeout = 0
|
||||
|
||||
pm.status_path = /php-fpm_status
|
||||
slowlog = var/log/slow.log
|
||||
rlimit_files = 51200
|
||||
rlimit_core = 0
|
||||
|
||||
catch_workers_output = yes
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
env[TMP] = /tmp
|
||||
env[TMPDIR] = /tmp
|
||||
env[TEMP] = /tmp
|
||||
EOF
|
||||
|
||||
if [ $Mem -le 3000 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
fi
|
||||
|
||||
systemctl start php-fpm
|
||||
|
||||
popd > /dev/null
|
||||
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php80_ver}
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_PHP81() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
if [ ! -e "/usr/local/lib/libiconv.la" ]; then
|
||||
tar xzf libiconv-${libiconv_ver}.tar.gz
|
||||
pushd libiconv-${libiconv_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libiconv-${libiconv_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${curl_install_dir}/lib/libcurl.la" ]; then
|
||||
tar xzf curl-${curl_ver}.tar.gz
|
||||
pushd curl-${curl_ver} > /dev/null
|
||||
./configure --prefix=${curl_install_dir} ${php81_with_ssl}
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf curl-${curl_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "${freetype_install_dir}/lib/libfreetype.la" ]; then
|
||||
tar xzf freetype-${freetype_ver}.tar.gz
|
||||
pushd freetype-${freetype_ver} > /dev/null
|
||||
./configure --prefix=${freetype_install_dir} --enable-freetype-config
|
||||
make -j ${THREAD} && make install
|
||||
ln -sf ${freetype_install_dir}/include/freetype2/* /usr/include/
|
||||
[ -d /usr/lib/pkgconfig ] && /bin/cp ${freetype_install_dir}/lib/pkgconfig/freetype2.pc /usr/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf freetype-${freetype_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/pkgconfig/libargon2.pc" ]; then
|
||||
tar xzf argon2-${argon2_ver}.tar.gz
|
||||
pushd argon2-${argon2_ver} > /dev/null
|
||||
make -j ${THREAD} && make install
|
||||
[ ! -d /usr/local/lib/pkgconfig ] && mkdir -p /usr/local/lib/pkgconfig
|
||||
/bin/cp libargon2.pc /usr/local/lib/pkgconfig/
|
||||
popd > /dev/null
|
||||
rm -rf argon2-${argon2_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libsodium.la" ]; then
|
||||
tar xzf libsodium-${libsodium_ver}.tar.gz
|
||||
pushd libsodium-${libsodium_ver} > /dev/null
|
||||
./configure --disable-dependency-tracking --enable-minimal
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libsodium-${libsodium_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/lib/libzip.la" ]; then
|
||||
tar xzf libzip-${libzip_ver}.tar.gz
|
||||
pushd libzip-${libzip_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf libzip-${libzip_ver}
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/local/include/mhash.h" -a ! -e "/usr/include/mhash.h" ]; then
|
||||
tar xzf mhash-${mhash_ver}.tar.gz
|
||||
pushd mhash-${mhash_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
rm -rf mhash-${mhash_ver}
|
||||
fi
|
||||
|
||||
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
|
||||
ldconfig
|
||||
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
[ ! -e "/lib64/libpcre.so.1" ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1
|
||||
[ ! -e "/usr/lib/libc-client.so" ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
|
||||
fi
|
||||
|
||||
id -g ${run_group} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && groupadd ${run_group}
|
||||
id -u ${run_user} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user}
|
||||
|
||||
# PHP enables the sqlite3 extension by default; its configure step fails with
|
||||
# "Package 'sqlite3' not found" when libsqlite3-dev is missing. Install it on
|
||||
# demand so a skipped/partial dependency stage cannot break the PHP build.
|
||||
if ! pkg-config --exists sqlite3 >/dev/null 2>&1; then
|
||||
echo "${CMSG}Installing libsqlite3-dev (required by PHP sqlite3 extension)...${CEND}"
|
||||
apt-get -y install libsqlite3-dev
|
||||
fi
|
||||
|
||||
tar xzf php-${php81_ver}.tar.gz
|
||||
pushd php-${php81_ver} > /dev/null
|
||||
make clean
|
||||
# Include the self-built curl's pkgconfig dir so PHP's pkg-config based
|
||||
# ext/curl detection (PKG_CHECK_MODULES libcurl) can find libcurl.pc.
|
||||
export PKG_CONFIG_PATH=${curl_install_dir}/lib/pkgconfig/:/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
|
||||
# PHP ext/curl uses pkg-config to locate libcurl; if it still can't be found
|
||||
# (self-built curl .pc missing), fall back to the system dev package.
|
||||
if ! pkg-config --exists libcurl >/dev/null 2>&1; then
|
||||
echo "${CMSG}libcurl.pc not found, installing libcurl4-openssl-dev...${CEND}"
|
||||
apt-get -y install libcurl4-openssl-dev
|
||||
fi
|
||||
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
|
||||
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
|
||||
./configure --prefix=${php_install_dir} --with-config-file-path=${php_install_dir}/etc \
|
||||
--with-config-file-scan-dir=${php_install_dir}/etc/php.d \
|
||||
--with-fpm-user=${run_user} --with-fpm-group=${run_group} --enable-fpm ${phpcache_arg} --disable-fileinfo \
|
||||
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
|
||||
--with-iconv=/usr/local --with-freetype --with-jpeg --with-zlib \
|
||||
--enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
|
||||
--enable-sysvsem ${php81_with_curl} --enable-mbregex \
|
||||
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php81_with_openssl} \
|
||||
--with-mhash --enable-pcntl --enable-sockets --enable-ftp --enable-intl --with-xsl \
|
||||
--with-gettext --with-zip=/usr/local --enable-soap --disable-debug ${php_modules_options}
|
||||
make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
|
||||
make install
|
||||
|
||||
if [ -e "${php_install_dir}/bin/phpize" ]; then
|
||||
[ ! -e "${php_install_dir}/etc/php.d" ] && mkdir -p ${php_install_dir}/etc/php.d
|
||||
echo "${CSUCCESS}PHP installed successfully! ${CEND}"
|
||||
else
|
||||
rm -rf ${php_install_dir}
|
||||
echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${php_install_dir}/bin:\$PATH" >> /etc/profile
|
||||
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${php_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${php_install_dir}/bin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
# wget -c http://pear.php.net/go-pear.phar
|
||||
# ${php_install_dir}/bin/php go-pear.phar
|
||||
|
||||
/bin/cp php.ini-production ${php_install_dir}/etc/php.ini
|
||||
|
||||
sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' ${php_install_dir}/etc/php.ini
|
||||
#sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^short_open_tag = Off@short_open_tag = On@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^expose_php = On@expose_php = Off@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^request_order.*@request_order = "CGP"@' ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;date.timezone.*@date.timezone = ${timezone}@" ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^post_max_size.*@post_max_size = 100M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^max_execution_time.*@max_execution_time = 600@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' ${php_install_dir}/etc/php.ini
|
||||
sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' ${php_install_dir}/etc/php.ini
|
||||
[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' ${php_install_dir}/etc/php.ini
|
||||
if [ "${with_old_openssl_flag}" = 'y' ]; then
|
||||
sed -i "s@^;curl.cainfo.*@curl.cainfo = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.cafile.*@openssl.cafile = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
sed -i "s@^;openssl.capath.*@openssl.capath = \"${openssl_install_dir}/cert.pem\"@" ${php_install_dir}/etc/php.ini
|
||||
fi
|
||||
|
||||
[ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
|
||||
[opcache]
|
||||
zend_extension=opcache.so
|
||||
opcache.enable=1
|
||||
opcache.enable_cli=1
|
||||
opcache.memory_consumption=${Memory_limit}
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=100000
|
||||
opcache.max_wasted_percentage=5
|
||||
opcache.use_cwd=1
|
||||
opcache.validate_timestamps=1
|
||||
opcache.revalidate_freq=60
|
||||
;opcache.save_comments=0
|
||||
opcache.consistency_checks=0
|
||||
;opcache.optimization_level=0
|
||||
EOF
|
||||
|
||||
# php-fpm Init Script
|
||||
/bin/cp ${oneinstack_dir}/services/php-fpm.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/php@${php_install_dir}@g" /lib/systemd/system/php-fpm.service
|
||||
systemctl enable php-fpm
|
||||
|
||||
cat > ${php_install_dir}/etc/php-fpm.conf <<EOF
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
; FPM Configuration ;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
; Global Options ;
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[global]
|
||||
pid = run/php-fpm.pid
|
||||
error_log = log/php-fpm.log
|
||||
log_level = warning
|
||||
|
||||
emergency_restart_threshold = 30
|
||||
emergency_restart_interval = 60s
|
||||
process_control_timeout = 5s
|
||||
daemonize = yes
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
; Pool Definitions ;
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
[${run_user}]
|
||||
listen = /dev/shm/php-cgi.sock
|
||||
listen.backlog = -1
|
||||
listen.allowed_clients = 127.0.0.1
|
||||
listen.owner = ${run_user}
|
||||
listen.group = ${run_group}
|
||||
listen.mode = 0666
|
||||
user = ${run_user}
|
||||
group = ${run_group}
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 12
|
||||
pm.start_servers = 8
|
||||
pm.min_spare_servers = 6
|
||||
pm.max_spare_servers = 12
|
||||
pm.max_requests = 2048
|
||||
pm.process_idle_timeout = 10s
|
||||
request_terminate_timeout = 120
|
||||
request_slowlog_timeout = 0
|
||||
|
||||
pm.status_path = /php-fpm_status
|
||||
slowlog = var/log/slow.log
|
||||
rlimit_files = 51200
|
||||
rlimit_core = 0
|
||||
|
||||
catch_workers_output = yes
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
env[TMP] = /tmp
|
||||
env[TMPDIR] = /tmp
|
||||
env[TEMP] = /tmp
|
||||
EOF
|
||||
|
||||
if [ $Mem -le 3000 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" ${php_install_dir}/etc/php-fpm.conf
|
||||
elif [ $Mem -gt 8500 ]; then
|
||||
sed -i "s@^pm.max_children.*@pm.max_children = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" ${php_install_dir}/etc/php-fpm.conf
|
||||
sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" ${php_install_dir}/etc/php-fpm.conf
|
||||
fi
|
||||
|
||||
systemctl start php-fpm
|
||||
|
||||
popd > /dev/null
|
||||
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php81_ver}
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_fail2ban() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
|
||||
tar xzf fail2ban-${fail2ban_ver}.tar.gz
|
||||
pushd fail2ban-${fail2ban_ver} > /dev/null
|
||||
sed -i 's@for i in xrange(50)@for i in range(50)@' fail2ban/__init__.py
|
||||
${python_install_dir}/bin/python setup.py install
|
||||
if [ -e /bin/systemctl ]; then
|
||||
/bin/cp build/fail2ban.service /lib/systemd/system/
|
||||
systemctl enable fail2ban
|
||||
else
|
||||
if [ "${PM}" == 'yum' ]; then
|
||||
/bin/cp files/redhat-initd /etc/services/fail2ban
|
||||
sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/services/fail2ban
|
||||
sed -i 's@Starting fail2ban.*@&\n [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/services/fail2ban
|
||||
chmod +x /etc/services/fail2ban
|
||||
chkconfig --add fail2ban
|
||||
chkconfig fail2ban on
|
||||
elif [ "${PM}" == 'apt-get' ]; then
|
||||
/bin/cp files/debian-initd /etc/services/fail2ban
|
||||
sed -i 's@2 3 4 5@3 4 5@' /etc/services/fail2ban
|
||||
sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/services/fail2ban
|
||||
chmod +x /etc/services/fail2ban
|
||||
update-rc.d fail2ban defaults
|
||||
fi
|
||||
fi
|
||||
[ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
|
||||
[ "${PM}" == 'yum' ] && LOGPATH=/var/log/secure
|
||||
[ "${PM}" == 'apt-get' ] && LOGPATH=/var/log/auth.log
|
||||
cat > /etc/fail2ban/jail.local << EOF
|
||||
[DEFAULT]
|
||||
ignoreip = 127.0.0.1/8
|
||||
bantime = 86400
|
||||
findtime = 600
|
||||
maxretry = 5
|
||||
[ssh-iptables]
|
||||
enabled = true
|
||||
filter = sshd
|
||||
action = iptables[name=SSH, port=${now_ssh_port}, protocol=tcp]
|
||||
logpath = ${LOGPATH}
|
||||
EOF
|
||||
cat > /etc/logrotate.d/fail2ban << EOF
|
||||
/var/log/fail2ban.log {
|
||||
missingok
|
||||
notifempty
|
||||
postrotate
|
||||
${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true
|
||||
endscript
|
||||
}
|
||||
EOF
|
||||
sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf
|
||||
kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
|
||||
service fail2ban start
|
||||
popd > /dev/null
|
||||
if [ -e "${python_install_dir}/bin/fail2ban-server" ]; then
|
||||
echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}"
|
||||
else
|
||||
echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
Uninstall_fail2ban() {
|
||||
service fail2ban stop
|
||||
${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
|
||||
rm -rf /etc/services/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
|
||||
echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Nginx_lua_waf() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -e "${nginx_install_dir}/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
|
||||
if [ ! -e "/usr/local/lib/libluajit-5.1.so.2.1.0" ]; then
|
||||
[ -e "/usr/local/lib/libluajit-5.1.so.2.0.5" ] && find /usr/local -name *luajit* | xargs rm -rf
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/luajit2-${luajit2_ver}.tar.gz && Download_src
|
||||
tar xzf luajit2-${luajit2_ver}.tar.gz
|
||||
pushd luajit2-${luajit2_ver}
|
||||
make && make install
|
||||
[ ! -e "/usr/local/lib/libluajit-5.1.so.2.1.0" ] && { echo "${CFAILURE}LuaJIT install failed! ${CEND}"; kill -9 $$; exit 1; }
|
||||
popd > /dev/null
|
||||
rm -rf luajit2-${luajit2_ver}
|
||||
fi
|
||||
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-resty-core-${lua_resty_core_ver}.tar.gz && Download_src
|
||||
tar xzf lua-resty-core-${lua_resty_core_ver}.tar.gz
|
||||
pushd lua-resty-core-${lua_resty_core_ver}
|
||||
make install
|
||||
popd > /dev/null
|
||||
rm -rf lua-resty-core-${lua_resty_core_ver}
|
||||
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz && Download_src
|
||||
tar xzf lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz
|
||||
pushd lua-resty-lrucache-${lua_resty_lrucache_ver}
|
||||
make install
|
||||
popd > /dev/null
|
||||
rm -rf lua-resty-lrucache-${lua_resty_lrucache_ver}
|
||||
|
||||
[ ! -h "/usr/local/share/lua/5.1" ] && { rm -rf /usr/local/share/lua/5.1 ; ln -s /usr/local/lib/lua /usr/local/share/lua/5.1; }
|
||||
if [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ]; then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-cjson-${lua_cjson_ver}.tar.gz && Download_src
|
||||
tar xzf lua-cjson-${lua_cjson_ver}.tar.gz
|
||||
pushd lua-cjson-${lua_cjson_ver}
|
||||
sed -i 's@^LUA_INCLUDE_DIR.*@&/luajit-2.1@' Makefile
|
||||
make && make install
|
||||
[ ! -e "/usr/local/lib/lua/5.1/cjson.so" ] && { echo "${CFAILURE}lua-cjson install failed! ${CEND}"; kill -9 $$; exit 1; }
|
||||
popd > /dev/null
|
||||
fi
|
||||
${nginx_install_dir}/sbin/nginx -V &> $$
|
||||
nginx_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
|
||||
rm -rf $$
|
||||
nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl11_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"`
|
||||
if [ -z "`echo ${nginx_configure_args} | grep lua-nginx-module`" ]; then
|
||||
src_url=http://nginx.org/download/nginx-${nginx_ver}.tar.gz && Download_src
|
||||
src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-nginx-module-${lua_nginx_module_ver}.tar.gz && Download_src
|
||||
tar xzf nginx-${nginx_ver}.tar.gz
|
||||
tar xzf openssl-${openssl11_ver}.tar.gz
|
||||
tar xzf pcre-${pcre_ver}.tar.gz
|
||||
tar xzf ngx_devel_kit.tar.gz
|
||||
tar xzf lua-nginx-module-${lua_nginx_module_ver}.tar.gz
|
||||
pushd nginx-${nginx_ver}
|
||||
make clean
|
||||
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
|
||||
export LUAJIT_LIB=/usr/local/lib
|
||||
export LUAJIT_INC=/usr/local/include/luajit-2.1
|
||||
./configure ${nginx_configure_args} --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-module=../lua-nginx-module-${lua_nginx_module_ver} --add-module=../ngx_devel_kit
|
||||
make -j ${THREAD}
|
||||
if [ -f "objs/nginx" ]; then
|
||||
/bin/mv ${nginx_install_dir}/sbin/nginx{,`date +%m%d`}
|
||||
/bin/cp objs/nginx ${nginx_install_dir}/sbin/nginx
|
||||
kill -USR2 `cat /var/run/nginx.pid`
|
||||
sleep 1
|
||||
kill -QUIT `cat /var/run/nginx.pid.oldbin`
|
||||
popd > /dev/null
|
||||
echo "${CSUCCESS}lua-nginx-module installed successfully! ${CEND}"
|
||||
sed -i "s@^nginx_modules_options='\(.*\)'@nginx_modules_options=\'\1 --with-ld-opt=\"-Wl,-rpath,/usr/local/lib\" --add-module=../lua-nginx-module-${lua_nginx_module_ver} --add-module=../ngx_devel_kit\'@" ../config/options.conf
|
||||
rm -rf nginx-${nginx_ver}
|
||||
else
|
||||
echo "${CFAILURE}lua-nginx-module install failed! ${CEND}"
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
|
||||
enable_lua_waf() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
. ../lib/check_dir.sh
|
||||
rm -f ngx_lua_waf.tar.gz
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/ngx_lua_waf.tar.gz && Download_src
|
||||
tar xzf ngx_lua_waf.tar.gz -C ${web_install_dir}/conf
|
||||
[ -e "${web_install_dir}/conf/resty" ] && /bin/mv ${web_install_dir}/conf/resty{,_bak}
|
||||
sed -i "s@/usr/local/nginx@${web_install_dir}@g" ${web_install_dir}/conf/waf.conf
|
||||
sed -i "s@/usr/local/nginx@${web_install_dir}@" ${web_install_dir}/conf/waf/config.lua
|
||||
sed -i "s@/data/wwwlogs@${wwwlogs_dir}@" ${web_install_dir}/conf/waf/config.lua
|
||||
[ -z "`grep 'include waf.conf;' ${web_install_dir}/conf/nginx.conf`" ] && sed -i "s@ vhost/\*.conf;@&\n include waf.conf;@" ${web_install_dir}/conf/nginx.conf
|
||||
${web_install_dir}/sbin/nginx -t
|
||||
if [ $? -eq 0 ]; then
|
||||
service nginx reload
|
||||
echo "${CSUCCESS}ngx_lua_waf enabled successfully! ${CEND}"
|
||||
chown ${run_user}:${run_group} ${wwwlogs_dir}
|
||||
else
|
||||
echo "${CFAILURE}ngx_lua_waf enable failed! ${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
disable_lua_waf() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
. ../lib/check_dir.sh
|
||||
sed -i '/include waf.conf;/d' ${web_install_dir}/conf/nginx.conf
|
||||
${web_install_dir}/sbin/nginx -t
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -rf ${web_install_dir}/conf/{waf,waf.conf}
|
||||
service nginx reload
|
||||
echo "${CSUCCESS}ngx_lua_waf disabled successfully! ${CEND}"
|
||||
else
|
||||
echo "${CFAILURE}ngx_lua_waf disable failed! ${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_DB() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -e "${db_install_dir}/bin/mysql" ] && echo "${CWARNING}MySQL/MariaDB is not installed on your system! ${CEND}" && exit 1
|
||||
[ "${armplatform}" == 'y' ] && echo "${CWARNING}The arm architecture operating system does not support upgrading MySQL/MariaDB! ${CEND}" && exit 1
|
||||
|
||||
# check db passwd
|
||||
while :; do
|
||||
${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "quit" > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
break
|
||||
else
|
||||
echo
|
||||
read -e -p "Please input the root password of database: " NEW_dbrootpwd
|
||||
${db_install_dir}/bin/mysql -uroot -p${NEW_dbrootpwd} -e "quit" >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
dbrootpwd=${NEW_dbrootpwd}
|
||||
sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ../config/options.conf
|
||||
break
|
||||
else
|
||||
echo "${CFAILURE}${DB} root password incorrect,Please enter again! ${CEND}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
OLD_db_ver_tmp=`${db_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e 'select version()\G;' | grep version | awk '{print $2}'`
|
||||
if [ -n "`${db_install_dir}/bin/mysql -V | grep -o MariaDB`" ]; then
|
||||
[ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
|
||||
DB=MariaDB
|
||||
OLD_db_ver=`echo ${OLD_db_ver_tmp} | awk -F'-' '{print $1}'`
|
||||
else
|
||||
[ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads
|
||||
DB=MySQL
|
||||
OLD_db_ver=${OLD_db_ver_tmp%%-log}
|
||||
fi
|
||||
|
||||
#backup
|
||||
echo
|
||||
echo "${CSUCCESS}Starting ${DB} backup${CEND}......"
|
||||
${db_install_dir}/bin/mysqldump -uroot -p${dbrootpwd} --opt --all-databases > DB_all_backup_$(date +"%Y%m%d").sql
|
||||
[ -f "DB_all_backup_$(date +"%Y%m%d").sql" ] && echo "${DB} backup success, Backup file: ${MSG}`pwd`/DB_all_backup_$(date +"%Y%m%d").sql${CEND}"
|
||||
|
||||
#upgrade
|
||||
echo
|
||||
echo "Current ${DB} Version: ${CMSG}${OLD_db_ver}${CEND}"
|
||||
while :; do echo
|
||||
[ "${db_flag}" != 'y' ] && read -e -p "Please input upgrade ${DB} Version(example: ${OLD_db_ver}): " NEW_db_ver
|
||||
if [ `echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'` == `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` ]; then
|
||||
if [ "${DB}" == 'MariaDB' ]; then
|
||||
DB_filename=mariadb-${NEW_db_ver}-linux-systemd-x86_64
|
||||
DB_URL=${DOWN_ADDR}/mariadb-${NEW_db_ver}/bintar-linux-systemd-x86_64/${DB_filename}.tar.gz
|
||||
elif [ "${DB}" == 'MySQL' ]; then
|
||||
DB_filename=mysql-${NEW_db_ver}-linux-glibc2.12-x86_64
|
||||
if [ `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` == '8.0' ]; then
|
||||
DB_URL=${DOWN_ADDR}/MySQL-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/${DB_filename}.tar.xz
|
||||
else
|
||||
DB_URL=${DOWN_ADDR}/MySQL-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/${DB_filename}.tar.gz
|
||||
fi
|
||||
fi
|
||||
[ ! -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ] && wget --no-check-certificate -c ${DB_URL} > /dev/null 2>&1
|
||||
if [ -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ]; then
|
||||
echo "Download [${CMSG}`ls ${DB_filename}.tar.?z 2>/dev/null`${CEND}] successfully! "
|
||||
else
|
||||
echo "${CWARNING}${DB} version does not exist! ${CEND}"
|
||||
fi
|
||||
break
|
||||
else
|
||||
echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_db_ver%.*}.xx${CEND}'"
|
||||
[ "${db_flag}" == 'y' ] && exit
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "`ls ${DB_filename}.tar.?z 2>/dev/null`" ]; then
|
||||
echo "[${CMSG}`ls ${DB_filename}.tar.?z 2>/dev/null`${CEND}] found"
|
||||
if [ "${db_flag}" != 'y' ]; then
|
||||
echo "Press Ctrl+c to cancel or Press any key to continue..."
|
||||
char=`get_char`
|
||||
fi
|
||||
if [ "${DB}" == 'MariaDB' ]; then
|
||||
tar xzf ${DB_filename}.tar.gz
|
||||
service mysqld stop
|
||||
mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
|
||||
mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
|
||||
[ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
|
||||
mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
|
||||
mv ${DB_filename}/* ${mariadb_install_dir}/
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
|
||||
${mariadb_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mariadb_install_dir} --datadir=${mariadb_data_dir}
|
||||
chown mysql.mysql -R ${mariadb_data_dir}
|
||||
service mysqld start
|
||||
${mariadb_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
|
||||
service mysqld restart
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
|
||||
${mariadb_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
|
||||
${mariadb_install_dir}/bin/mysql_upgrade -uroot -p${dbrootpwd} >/dev/null 2>&1
|
||||
[ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}${OLD_db_ver}${CEND} to ${CMSG}${NEW_db_ver}${CEND}"
|
||||
elif [ "${DB}" == 'MySQL' ]; then
|
||||
if [ `echo ${OLD_db_ver} | awk -F. '{print $1"."$2}'` == '8.0' ]; then
|
||||
tar xJf ${DB_filename}.tar.xz
|
||||
else
|
||||
tar xzf ${DB_filename}.tar.gz
|
||||
fi
|
||||
service mysqld stop
|
||||
mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
|
||||
mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
|
||||
[ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
|
||||
mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
|
||||
mv ${DB_filename}/* ${mysql_install_dir}/
|
||||
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
|
||||
sed -i "s@/usr/local/mysql@${mysql_install_dir}@g" ${mysql_install_dir}/bin/mysqld_safe
|
||||
if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then
|
||||
${mysql_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
|
||||
else
|
||||
${mysql_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysql_install_dir} --datadir=${mysql_data_dir}
|
||||
fi
|
||||
|
||||
chown mysql.mysql -R ${mysql_data_dir}
|
||||
[ -e "${mysql_install_dir}/my.cnf" ] && rm -rf ${mysql_install_dir}/my.cnf
|
||||
sed -i '/myisam_repair_threads/d' /etc/my.cnf
|
||||
service mysqld start
|
||||
${mysql_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
|
||||
service mysqld restart
|
||||
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
|
||||
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
|
||||
${mysql_install_dir}/bin/mysql_upgrade -uroot -p${dbrootpwd} >/dev/null 2>&1
|
||||
[ $? -eq 0 ] && echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}${OLD_db_ver}${CEND} to ${CMSG}${NEW_db_ver}${CEND}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_OneinStack() {
|
||||
pushd ${oneinstack_dir} > /dev/null
|
||||
Latest_OneinStack_MD5=$(curl --connect-timeout 3 -m 5 -s http://mirrors.linuxeye.com/md5sum.txt | grep oneinstack.tar.gz | awk '{print $1}')
|
||||
[ ! -e README.md ] && ois_flag=n
|
||||
if [ "${oneinstack_md5}" != "${Latest_OneinStack_MD5}" ]; then
|
||||
/bin/mv config/options.conf /tmp
|
||||
sed -i '/oneinstack_dir=/d' /tmp/config/options.conf
|
||||
[ -e /tmp/oneinstack.tar.gz ] && rm -rf /tmp/oneinstack.tar.gz
|
||||
wget -qc http://mirrors.linuxeye.com/oneinstack.tar.gz -O /tmp/oneinstack.tar.gz
|
||||
if [ -n "`echo ${oneinstack_dir} | grep lnmp`" ]; then
|
||||
tar xzf /tmp/oneinstack.tar.gz -C /tmp
|
||||
/bin/cp -R /tmp/oneinstack/* ${oneinstack_dir}/
|
||||
/bin/rm -rf /tmp/oneinstack
|
||||
else
|
||||
tar xzf /tmp/oneinstack.tar.gz -C ../
|
||||
fi
|
||||
IFS=$'\n'
|
||||
for L in `grep -vE '^#|^$' /tmp/config/options.conf`
|
||||
do
|
||||
IFS=$IFS_old
|
||||
Key="`echo ${L%%=*}`"
|
||||
Value="`echo ${L#*=}`"
|
||||
sed -i "s|^${Key}=.*|${Key}=${Value}|" ./config/options.conf
|
||||
done
|
||||
rm -rf /tmp/{oneinstack.tar.gz,config/options.conf}
|
||||
[ "${ois_flag}" == "n" ] && rm -f ss.sh LICENSE README.md
|
||||
sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./config/options.conf
|
||||
if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
|
||||
[ -n "`grep ^cgi.fix_pathinfo=0 ${php_install_dir}/etc/php.ini`" ] && sed -i 's@^cgi.fix_pathinfo.*@;&@' ${php_install_dir}/etc/php.ini
|
||||
[ -e "/usr/local/php53/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php53/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php54/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php54/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php55/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php55/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php56/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php56/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php70/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php70/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php71/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php71/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php72/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php72/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php73/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php73/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php74/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php74/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php80/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php80/etc/php.ini 2>/dev/null
|
||||
[ -e "/usr/local/php81/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php81/etc/php.ini 2>/dev/null
|
||||
fi
|
||||
[ -e "/lib/systemd/system/php-fpm.service" ] && { sed -i 's@^PrivateTmp.*@#&@g' /lib/systemd/system/php-fpm.service; systemctl daemon-reload; }
|
||||
echo
|
||||
echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}"
|
||||
echo
|
||||
else
|
||||
echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_PHP() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -e "${php_install_dir}" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1
|
||||
OLD_php_ver=`${php_install_dir}/bin/php-config --version`
|
||||
Latest_php_ver=`curl --connect-timeout 2 -m 3 -s https://www.php.net/releases/active.php | python -mjson.tool | awk '/version/{print $2}' | sed 's/"//g' | grep "${OLD_php_ver%.*}"`
|
||||
Latest_php_ver=${Latest_php_ver:-8.1.12}
|
||||
echo
|
||||
echo "Current PHP Version: ${CMSG}$OLD_php_ver${CEND}"
|
||||
while :; do echo
|
||||
[ "${php_flag}" != 'y' ] && read -e -p "Please input upgrade PHP Version(Default: $Latest_php_ver): " NEW_php_ver
|
||||
NEW_php_ver=${NEW_php_ver:-${Latest_php_ver}}
|
||||
if [ "${NEW_php_ver%.*}" == "${OLD_php_ver%.*}" ]; then
|
||||
[ ! -e "php-${NEW_php_ver}.tar.gz" ] && wget --no-check-certificate -c https://secure.php.net/distributions/php-${NEW_php_ver}.tar.gz > /dev/null 2>&1
|
||||
if [ -e "php-${NEW_php_ver}.tar.gz" ]; then
|
||||
echo "Download [${CMSG}php-${NEW_php_ver}.tar.gz${CEND}] successfully! "
|
||||
else
|
||||
echo "${CWARNING}PHP version does not exist! ${CEND}"
|
||||
fi
|
||||
break
|
||||
else
|
||||
echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_php_ver%.*}.xx${CEND}'"
|
||||
[ "${php_flag}" == 'y' ] && exit
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "php-${NEW_php_ver}.tar.gz" ]; then
|
||||
echo "[${CMSG}php-${NEW_php_ver}.tar.gz${CEND}] found"
|
||||
if [ "${php_flag}" != 'y' ]; then
|
||||
echo "Press Ctrl+c to cancel or Press any key to continue..."
|
||||
char=`get_char`
|
||||
fi
|
||||
tar xzf php-${NEW_php_ver}.tar.gz
|
||||
if [[ "${OLD_php_ver%.*}" =~ ^5.[3-6]$ ]]; then
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/fpm-race-condition.patch && Download_src
|
||||
patch -d php-${NEW_php_ver} -p0 < fpm-race-condition.patch
|
||||
fi
|
||||
pushd php-${NEW_php_ver}
|
||||
if [[ "${OLD_php_ver%.*}" =~ ^7.[1-4]$|^8.[0-1]$ ]] && [ -e ext/openssl/openssl.c ] && ! grep -Eqi '^#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c; then
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/i#ifdef RSA_SSLV23_PADDING' ext/openssl/openssl.c
|
||||
sed -i '/OPENSSL_SSLV23_PADDING/a#endif' ext/openssl/openssl.c
|
||||
fi
|
||||
make clean
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
|
||||
${php_install_dir}/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash
|
||||
make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
|
||||
echo "Stoping php-fpm..."
|
||||
service php-fpm stop
|
||||
make install
|
||||
echo "Starting php-fpm..."
|
||||
service php-fpm start
|
||||
popd > /dev/null
|
||||
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_php_ver${CEND} to ${CWARNING}${NEW_php_ver}${CEND}"
|
||||
rm -rf php-${NEW_php_ver}
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_phpMyAdmin() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -e "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1
|
||||
OLD_phpmyadmin_ver=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'`
|
||||
Latest_phpmyadmin_ver=`curl --connect-timeout 2 -m 3 -s https://www.phpmyadmin.net/files/ | awk -F'>|<' '/\/files\/[0-9]/{print $5}' | head -1`
|
||||
Latest_phpmyadmin_ver=${Latest_phpmyadmin_ver:-5.0.4}
|
||||
echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpmyadmin_ver}${CEND}"
|
||||
while :; do echo
|
||||
[ "${phpmyadmin_flag}" != 'y' ] && read -e -p "Please input upgrade phpMyAdmin Version(default: ${Latest_phpmyadmin_ver}): " NEW_phpmyadmin_ver
|
||||
NEW_phpmyadmin_ver=${NEW_phpmyadmin_ver:-${Latest_phpmyadmin_ver}}
|
||||
if [ "${NEW_phpmyadmin_ver}" != "${OLD_phpmyadmin_ver}" ]; then
|
||||
[ ! -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpmyadmin_ver}/phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz > /dev/null 2>&1
|
||||
if [ -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ]; then
|
||||
echo "Download [${CMSG}phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz${CEND}] successfully! "
|
||||
break
|
||||
else
|
||||
echo "${CWARNING}phpMyAdmin version does not exist! ${CEND}"
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}input error! Upgrade phpMyAdmin version is the same as the old version${CEND}"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz" ]; then
|
||||
echo "[${CMSG}phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz${CEND}] found"
|
||||
if [ "${phpmyadmin_flag}" != 'y' ]; then
|
||||
echo "Press Ctrl+c to cancel or Press any key to continue..."
|
||||
char=`get_char`
|
||||
fi
|
||||
tar xzf phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages.tar.gz
|
||||
rm -rf ${wwwroot_dir}/default/phpMyAdmin
|
||||
/bin/mv phpMyAdmin-${NEW_phpmyadmin_ver}-all-languages ${wwwroot_dir}/default/phpMyAdmin
|
||||
/bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
|
||||
mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save}
|
||||
sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@host'\].*@host'\] = '127.0.0.1';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
|
||||
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/phpMyAdmin
|
||||
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_phpmyadmin_ver${CEND} to ${CWARNING}$NEW_phpmyadmin_ver${CEND}"
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_Redis() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1
|
||||
OLD_redis_ver=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
|
||||
Latest_redis_ver=`curl --connect-timeout 2 -m 3 -s http://download.redis.io/redis-stable/00-RELEASENOTES | awk '/Released/{print $2}' | head -1`
|
||||
Latest_redis_ver=${Latest_redis_ver:-6.0.4}
|
||||
echo "Current Redis Version: ${CMSG}$OLD_redis_ver${CEND}"
|
||||
while :; do echo
|
||||
[ "${redis_flag}" != 'y' ] && read -e -p "Please input upgrade Redis Version(default: ${Latest_redis_ver}): " NEW_redis_ver
|
||||
NEW_redis_ver=${NEW_redis_ver:-${Latest_redis_ver}}
|
||||
if [ "$NEW_redis_ver" != "$OLD_redis_ver" ]; then
|
||||
[ ! -e "redis-$NEW_redis_ver.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_redis_ver.tar.gz > /dev/null 2>&1
|
||||
if [ -e "redis-$NEW_redis_ver.tar.gz" ]; then
|
||||
echo "Download [${CMSG}redis-$NEW_redis_ver.tar.gz${CEND}] successfully! "
|
||||
break
|
||||
else
|
||||
echo "${CWARNING}Redis version does not exist! ${CEND}"
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}input error! Upgrade Redis version is the same as the old version${CEND}"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "redis-$NEW_redis_ver.tar.gz" ]; then
|
||||
echo "[${CMSG}redis-$NEW_redis_ver.tar.gz${CEND}] found"
|
||||
if [ "${redis_flag}" != 'y' ]; then
|
||||
echo "Press Ctrl+c to cancel or Press any key to continue..."
|
||||
char=`get_char`
|
||||
fi
|
||||
tar xzf redis-$NEW_redis_ver.tar.gz
|
||||
pushd redis-$NEW_redis_ver
|
||||
make clean
|
||||
make -j ${THREAD}
|
||||
|
||||
if [ -f "src/redis-server" ]; then
|
||||
echo "Restarting Redis..."
|
||||
service redis-server stop
|
||||
/bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
|
||||
service redis-server start
|
||||
popd > /dev/null
|
||||
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_redis_ver${CEND} to ${CWARNING}$NEW_redis_ver${CEND}"
|
||||
rm -rf redis-$NEW_redis_ver
|
||||
else
|
||||
echo "${CFAILURE}Upgrade Redis failed! ${CEND}"
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Upgrade_Nginx() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
[ ! -e "${nginx_install_dir}/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
|
||||
OLD_nginx_ver_tmp=`${nginx_install_dir}/sbin/nginx -v 2>&1`
|
||||
OLD_nginx_ver=${OLD_nginx_ver_tmp##*/}
|
||||
Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES-1.22 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
|
||||
[ -z "${Latest_nginx_ver}" ] && Latest_nginx_ver=`curl --connect-timeout 2 -m 3 -s http://nginx.org/en/CHANGES | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
|
||||
echo
|
||||
echo "Current Nginx Version: ${CMSG}${OLD_nginx_ver}${CEND}"
|
||||
while :; do echo
|
||||
[ "${nginx_flag}" != 'y' ] && read -e -p "Please input upgrade Nginx Version(default: ${Latest_nginx_ver}): " NEW_nginx_ver
|
||||
NEW_nginx_ver=${NEW_nginx_ver:-${Latest_nginx_ver}}
|
||||
if [ "${NEW_nginx_ver}" != "${OLD_nginx_ver}" ]; then
|
||||
[ ! -e "nginx-${NEW_nginx_ver}.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-${NEW_nginx_ver}.tar.gz > /dev/null 2>&1
|
||||
if [ -e "nginx-${NEW_nginx_ver}.tar.gz" ]; then
|
||||
src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-nginx-module-${lua_nginx_module_ver}.tar.gz && Download_src
|
||||
tar xzf openssl-${openssl11_ver}.tar.gz
|
||||
tar xzf pcre-${pcre_ver}.tar.gz
|
||||
tar xzf ngx_devel_kit.tar.gz
|
||||
tar xzf lua-nginx-module-${lua_nginx_module_ver}.tar.gz
|
||||
echo "Download [${CMSG}nginx-${NEW_nginx_ver}.tar.gz${CEND}] successfully! "
|
||||
break
|
||||
else
|
||||
echo "${CWARNING}Nginx version does not exist! ${CEND}"
|
||||
fi
|
||||
else
|
||||
echo "${CWARNING}input error! Upgrade Nginx version is the same as the old version${CEND}"
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "nginx-${NEW_nginx_ver}.tar.gz" ]; then
|
||||
echo "[${CMSG}nginx-${NEW_nginx_ver}.tar.gz${CEND}] found"
|
||||
if [ "${nginx_flag}" != 'y' ]; then
|
||||
echo "Press Ctrl+c to cancel or Press any key to continue..."
|
||||
char=`get_char`
|
||||
fi
|
||||
${nginx_install_dir}/sbin/nginx -V &> $$
|
||||
nginx_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
|
||||
rm -rf $$
|
||||
nginx_configure_args=`echo ${nginx_configure_args_tmp} | sed "s@lua-nginx-module-\w.\w\+.\w\+ @lua-nginx-module-${lua_nginx_module_ver} @" | sed "s@lua-nginx-module @lua-nginx-module-${lua_nginx_module_ver} @" | sed "s@--with-openssl=../openssl-\w.\w.\w\+ @--with-openssl=../openssl-${openssl11_ver} @" | sed "s@--with-pcre=../pcre-\w.\w\+ @--with-pcre=../pcre-${pcre_ver} @"`
|
||||
if [ -n `echo $nginx_configure_args | grep lua-nginx-module` ]; then
|
||||
${oneinstack_dir}/upgrade.sh --oneinstack > /dev/null
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/luajit2-${luajit2_ver}.tar.gz && Download_src
|
||||
tar xzf luajit2-${luajit2_ver}.tar.gz
|
||||
pushd luajit2-${luajit2_ver}
|
||||
make && make install
|
||||
popd > /dev/null
|
||||
rm -rf luajit2-${luajit2_ver}
|
||||
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-resty-core-${lua_resty_core_ver}.tar.gz && Download_src
|
||||
tar xzf lua-resty-core-${lua_resty_core_ver}.tar.gz
|
||||
pushd lua-resty-core-${lua_resty_core_ver}
|
||||
make install
|
||||
popd > /dev/null
|
||||
rm -rf lua-resty-core-${lua_resty_core_ver}
|
||||
|
||||
src_url=http://mirrors.linuxeye.com/oneinstack/src/lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz && Download_src
|
||||
tar xzf lua-resty-lrucache-${lua_resty_lrucache_ver}.tar.gz
|
||||
pushd lua-resty-lrucache-${lua_resty_lrucache_ver}
|
||||
make install
|
||||
popd > /dev/null
|
||||
rm -rf lua-resty-lrucache-${lua_resty_lrucache_ver}
|
||||
fi
|
||||
|
||||
tar xzf nginx-${NEW_nginx_ver}.tar.gz
|
||||
pushd nginx-${NEW_nginx_ver}
|
||||
make clean
|
||||
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
|
||||
export LUAJIT_LIB=/usr/local/lib
|
||||
export LUAJIT_INC=/usr/local/include/luajit-2.1
|
||||
./configure ${nginx_configure_args}
|
||||
make -j ${THREAD}
|
||||
if [ -f "objs/nginx" ]; then
|
||||
/bin/mv ${nginx_install_dir}/sbin/nginx{,`date +%m%d`}
|
||||
/bin/cp objs/nginx ${nginx_install_dir}/sbin/nginx
|
||||
kill -USR2 `cat /var/run/nginx.pid`
|
||||
sleep 1
|
||||
kill -QUIT `cat /var/run/nginx.pid.oldbin`
|
||||
popd > /dev/null
|
||||
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_nginx_ver}${CEND} to ${CWARNING}${NEW_nginx_ver}${CEND}"
|
||||
rm -rf nginx-${NEW_nginx_ver}
|
||||
else
|
||||
echo "${CFAILURE}Upgrade Nginx failed! ${CEND}"
|
||||
fi
|
||||
fi
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_Jemalloc() {
|
||||
if [ ! -e "/usr/local/lib/libjemalloc.so" ]; then
|
||||
echo "${CMSG}>> Installing: jemalloc ${jemalloc_ver} (compiling from source)${CEND}"
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
tar xjf jemalloc-${jemalloc_ver}.tar.bz2
|
||||
pushd jemalloc-${jemalloc_ver} > /dev/null
|
||||
./configure
|
||||
make -j ${THREAD} && make install
|
||||
popd > /dev/null
|
||||
if [ -f "/usr/local/lib/libjemalloc.so" ]; then
|
||||
if [ "${Family}" == 'rhel' ]; then
|
||||
ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
|
||||
else
|
||||
ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1
|
||||
fi
|
||||
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
|
||||
ldconfig
|
||||
echo "${CSUCCESS}jemalloc module installed successfully! ${CEND}"
|
||||
rm -rf jemalloc-${jemalloc_ver}
|
||||
else
|
||||
echo "${CFAILURE}jemalloc install failed, Please contact the author! ${CEND}" && lsb_release -a
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
popd > /dev/null
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
# Author: yeho <lj2007331 AT gmail.com>
|
||||
# BLOG: https://linuxeye.com
|
||||
#
|
||||
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
|
||||
#
|
||||
# Project home page:
|
||||
# https://oneinstack.com
|
||||
# https://github.com/oneinstack/oneinstack
|
||||
|
||||
Install_Nginx() {
|
||||
pushd ${oneinstack_dir}/src > /dev/null
|
||||
id -g ${run_group} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && groupadd ${run_group}
|
||||
id -u ${run_user} >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && useradd -g ${run_group} -M -s /sbin/nologin ${run_user}
|
||||
|
||||
tar xzf pcre-${pcre_ver}.tar.gz
|
||||
tar xzf nginx-${nginx_ver}.tar.gz
|
||||
tar xzf openssl-${openssl11_ver}.tar.gz
|
||||
tar xzf nginx-rtmp-module.tar.gz
|
||||
tar xvf ngx-fancyindex-${fancyindex_ver}.tar.xz
|
||||
pushd nginx-${nginx_ver} > /dev/null
|
||||
# Modify Nginx version
|
||||
#sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "1.2"@' src/core/nginx.h
|
||||
#sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "Linuxeye/" NGINX_VERSION@' src/core/nginx.h
|
||||
#sed -i 's@Server: nginx@Server: linuxeye@' src/http/ngx_http_header_filter_module.c
|
||||
|
||||
# close debug
|
||||
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
|
||||
|
||||
[ ! -d "${nginx_install_dir}" ] && mkdir -p ${nginx_install_dir}
|
||||
./configure --prefix=${nginx_install_dir} --user=${run_user} --group=${run_group} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl11_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc' --add-module=../nginx-rtmp-module --add-module=../ngx-fancyindex-${fancyindex_ver} ${nginx_modules_options}
|
||||
make -j ${THREAD} && make install
|
||||
if [ -e "${nginx_install_dir}/conf/nginx.conf" ]; then
|
||||
popd > /dev/null
|
||||
rm -rf pcre-${pcre_ver} openssl-${openssl11_ver} nginx-${nginx_ver} nginx-rtmp-module ngx-fancyindex-${fancyindex_ver}
|
||||
echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
|
||||
else
|
||||
rm -rf ${nginx_install_dir}
|
||||
echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}"
|
||||
kill -9 $$; exit 1;
|
||||
fi
|
||||
|
||||
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${nginx_install_dir}/sbin:\$PATH" >> /etc/profile
|
||||
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${nginx_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${nginx_install_dir}/sbin:\1@" /etc/profile
|
||||
. /etc/profile
|
||||
|
||||
/bin/cp ../services/nginx.service /lib/systemd/system/
|
||||
sed -i "s@/usr/local/nginx@${nginx_install_dir}@g" /lib/systemd/system/nginx.service
|
||||
systemctl enable nginx
|
||||
|
||||
mv ${nginx_install_dir}/conf/nginx.conf{,_bk}
|
||||
/bin/cp ../templates/nginx.conf ${nginx_install_dir}/conf/nginx.conf
|
||||
[[ "${php_option}" =~ ^[1-3]$ ]] && [ -z "`grep '/php-fpm_status' ${nginx_install_dir}/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;
|
||||
location ~ /php-fpm_status {
|
||||
#fastcgi_pass remote_php_ip:9000;
|
||||
fastcgi_pass unix:/dev/shm/php-cgi.sock;
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
allow 127.0.0.1;
|
||||
deny all;
|
||||
}@" ${nginx_install_dir}/conf/nginx.conf
|
||||
cat > ${nginx_install_dir}/conf/proxy.conf << EOF
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 900;
|
||||
proxy_read_timeout 900;
|
||||
proxy_buffer_size 32k;
|
||||
proxy_buffers 4 64k;
|
||||
proxy_busy_buffers_size 128k;
|
||||
proxy_redirect off;
|
||||
proxy_hide_header Vary;
|
||||
proxy_set_header Accept-Encoding '';
|
||||
proxy_set_header Referer \$http_referer;
|
||||
proxy_set_header Cookie \$http_cookie;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
EOF
|
||||
sed -i "s@/data/wwwroot/default@${wwwroot_dir}/default@" ${nginx_install_dir}/conf/nginx.conf
|
||||
sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${nginx_install_dir}/conf/nginx.conf
|
||||
sed -i "s@^user www www@user ${run_user} ${run_group}@" ${nginx_install_dir}/conf/nginx.conf
|
||||
|
||||
# logrotate nginx log
|
||||
cat > /etc/logrotate.d/nginx << EOF
|
||||
${wwwlogs_dir}/*nginx.log {
|
||||
daily
|
||||
rotate 5
|
||||
missingok
|
||||
dateext
|
||||
compress
|
||||
notifempty
|
||||
sharedscripts
|
||||
postrotate
|
||||
[ -e /var/run/nginx.pid ] && kill -USR1 \`cat /var/run/nginx.pid\`
|
||||
endscript
|
||||
}
|
||||
EOF
|
||||
popd > /dev/null
|
||||
ldconfig
|
||||
systemctl start nginx
|
||||
}
|
||||
Reference in New Issue
Block a user