This commit is contained in:
chenc
2024-07-15 13:21:08 +08:00
commit 44567b7d57
149 changed files with 20915 additions and 0 deletions
+67
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+74
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+70
View File
@@ -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
}
+190
View File
@@ -0,0 +1,190 @@
#!/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_Apache() {
pushd ${oneinstack_dir}/src > /dev/null
tar xzf pcre-${pcre_ver}.tar.gz
pushd pcre-${pcre_ver} > /dev/null
./configure
make -j ${THREAD} && make install
popd > /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 httpd-${apache_ver}.tar.gz
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
# install apr-util
if [ ! -e "${apr_install_dir}/bin/apu-1-config" ]; then
tar xzf apr-util-${apr_util_ver}.tar.gz
pushd apr-util-${apr_util_ver} > /dev/null
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-util-${apr_util_ver}
fi
# install nghttp2
if [ ! -e "/usr/local/lib/libnghttp2.so" ]; then
tar xzf nghttp2-${nghttp2_ver}.tar.gz
pushd nghttp2-${nghttp2_ver} > /dev/null
./configure
make -j ${THREAD} && make install
popd > /dev/null
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig
rm -rf nghttp2-${nghttp2_ver}
fi
pushd httpd-${apache_ver} > /dev/null
LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --enable-mpms-shared=all --with-pcre --with-apr=${apr_install_dir} --with-apr-util=${apr_install_dir} --enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-remoteip --enable-expires --enable-static-support --enable-suexec --enable-mods-shared=most --enable-nonportable-atomics=yes --enable-ssl --with-ssl --enable-http2 --with-nghttp2=/usr/local
make -j ${THREAD} && make install
popd > /dev/null
unset LDFLAGS
if [ -e "${apache_install_dir}/bin/httpd" ]; then
echo "${CSUCCESS}Apache installed successfully! ${CEND}"
rm -rf httpd-${apache_ver} pcre-${pcre_ver}
else
rm -rf ${apache_install_dir}
echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${apache_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${apache_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${apache_install_dir}/bin:\1@" /etc/profile
. /etc/profile
/bin/cp ../init.d/httpd.service /lib/systemd/system/
sed -i "s@/usr/local/apache@${apache_install_dir}@g" /lib/systemd/system/httpd.service
systemctl enable httpd
sed -i "s@^User daemon@User ${run_user}@" ${apache_install_dir}/conf/httpd.conf
sed -i "s@^Group daemon@Group ${run_group}@" ${apache_install_dir}/conf/httpd.conf
if [[ ! ${nginx_option} =~ ^[1-3]$ ]] && [ ! -e "${web_install_dir}/sbin/nginx" ]; then
sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' ${apache_install_dir}/conf/httpd.conf
TMP_PORT=80
elif [[ ${nginx_option} =~ ^[1-3]$ ]] || [ -e "${web_install_dir}/sbin/nginx" ]; then
sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' ${apache_install_dir}/conf/httpd.conf
sed -i 's@^Listen.*@Listen 127.0.0.1:88@' ${apache_install_dir}/conf/httpd.conf
TMP_PORT=88
fi
sed -i "s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType application/x-httpd-php-source .phps@" ${apache_install_dir}/conf/httpd.conf
sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_proxy.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_proxy_fcgi.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_suexec.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_vhost_alias.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_rewrite.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_deflate.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_expires.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_ssl.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -ri 's@^#(LoadModule.*mod_http2.so)@\1@' ${apache_install_dir}/conf/httpd.conf
sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' ${apache_install_dir}/conf/httpd.conf
sed -i "s@^DocumentRoot.*@DocumentRoot \"${wwwroot_dir}/default\"@" ${apache_install_dir}/conf/httpd.conf
sed -i "s@^<Directory \"${apache_install_dir}/htdocs\">@<Directory \"${wwwroot_dir}/default\">@" ${apache_install_dir}/conf/httpd.conf
sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" ${apache_install_dir}/conf/httpd.conf
if [ "${apache_mpm_option}" == '2' ]; then
sed -ri 's@^(LoadModule.*mod_mpm_event.so)@#\1@' ${apache_install_dir}/conf/httpd.conf
sed -i 's@^#LoadModule mpm_prefork_module@LoadModule mpm_prefork_module@' ${apache_install_dir}/conf/httpd.conf
elif [ "${apache_mpm_option}" == '3' ]; then
sed -ri 's@^(LoadModule.*mod_mpm_event.so)@#\1@' ${apache_install_dir}/conf/httpd.conf
sed -i 's@^#LoadModule mpm_worker_module@LoadModule mpm_worker_module@' ${apache_install_dir}/conf/httpd.conf
fi
#logrotate apache log
cat > /etc/logrotate.d/apache << EOF
${wwwlogs_dir}/*apache.log {
daily
rotate 5
missingok
dateext
compress
notifempty
sharedscripts
postrotate
[ -e /var/run/httpd.pid ] && kill -USR1 \`cat /var/run/httpd.pid\`
endscript
}
EOF
mkdir ${apache_install_dir}/conf/vhost
[ "${apache_mode_option}" != '2' ] && Apache_fcgi=$(echo -e "<Files ~ (\\.user.ini|\\.htaccess|\\.git|\\.svn|\\.project|LICENSE|README.md)\$>\n Order allow,deny\n Deny from all\n </Files>\n <FilesMatch \\.php\$>\n SetHandler \"proxy:unix:/dev/shm/php-cgi.sock|fcgi://localhost\"\n </FilesMatch>")
cat > ${apache_install_dir}/conf/vhost/0.conf << EOF
<VirtualHost *:$TMP_PORT>
ServerAdmin admin@example.com
DocumentRoot "${wwwroot_dir}/default"
ServerName 127.0.0.1
ErrorLog "${wwwlogs_dir}/error_apache.log"
CustomLog "${wwwlogs_dir}/access_apache.log" common
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)\$>
Order allow,deny
Deny from all
</Files>
${Apache_fcgi}
<Directory "${wwwroot_dir}/default">
SetOutputFilter DEFLATE
Options FollowSymLinks ExecCGI
Require all granted
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
</VirtualHost>
EOF
cat >> ${apache_install_dir}/conf/httpd.conf <<EOF
<IfModule mod_headers.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
<FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
RequestHeader edit "If-None-Match" "^(.*)-gzip(.*)\$" "\$1\$2"
Header edit "ETag" "^(.*)-gzip(.*)\$" "\$1\$2"
</FilesMatch>
DeflateCompressionLevel 6
SetOutputFilter DEFLATE
</IfModule>
ProtocolsHonorOrder On
PidFile /var/run/httpd.pid
ServerTokens ProductOnly
ServerSignature Off
Include conf/vhost/*.conf
EOF
[ "${nginx_option}" == '4' -a ! -e "${web_install_dir}/sbin/nginx" ] && echo 'Protocols h2 http/1.1' >> ${apache_install_dir}/conf/httpd.conf
if [ "${nginx_option}" != '4' -o -e "${web_install_dir}/sbin/nginx" ]; then
cat > ${apache_install_dir}/conf/extra/httpd-remoteip.conf << EOF
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
EOF
sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" ${apache_install_dir}/conf/httpd.conf
sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" ${apache_install_dir}/conf/httpd.conf
fi
ldconfig
[ "${with_old_openssl_flag}" == 'y' ] && sed -i "s@^export LD_LIBRARY_PATH.*@export LD_LIBRARY_PATH=${openssl_install_dir}/lib:\$LD_LIBRARY_PATH@" ${apache_install_dir}/bin/envvars
systemctl start httpd
popd > /dev/null
}
+52
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+55
View File
@@ -0,0 +1,55 @@
#!/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_Caddy() {
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}
#unzip caddy_${caddy_ver}_linux_amd64.zip
tar xzf caddy-${caddy_ver}.tar.gz
#move caddy to /usr/local/caddy/bin
[ ! -d "${caddy_install_dir}/bin" ] && mkdir -p ${caddy_install_dir}/bin
/bin/cp caddy ${caddy_install_dir}/bin
chmod +x ${caddy_install_dir}/bin/caddy
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${caddy_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${caddy_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${caddy_install_dir}/bin:\1@" /etc/profile
. /etc/profile
#make soft link
# [ ! -L "/usr/local/bin/caddy" ] && ln -s ${caddy_install_dir}/bin/caddy /usr/local/bin/caddy
#move caddyfile to /usr/local/caddy/conf
[ ! -d "${caddy_install_dir}/conf" ] && mkdir -p ${caddy_install_dir}/conf
/bin/cp ../config/Caddyfile ${caddy_install_dir}/conf/
#move caddy.service to /lib/systemd/system
/bin/cp ../init.d/caddy.service /lib/systemd/system/
#modify caddy.service
sed -i "s@/usr/local/caddy@${caddy_install_dir}@g" /lib/systemd/system/caddy.service
#设置caddy开机启动
systemctl enable caddy
#reload systemd
systemctl daemon-reload
#start caddy service
systemctl start caddy
echo "${CSUCCESS}Caddy installed successfully! ${CEND}"
}
+19
View File
@@ -0,0 +1,19 @@
#!/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
# check MySQL dir
[ -d "${mysql_install_dir}/support-files" ] && { db_install_dir=${mysql_install_dir}; db_data_dir=${mysql_data_dir}; }
[ -d "${mariadb_install_dir}/support-files" ] && { db_install_dir=${mariadb_install_dir}; db_data_dir=${mariadb_data_dir}; }
[ -d "${percona_install_dir}/support-files" ] && { db_install_dir=${percona_install_dir}; db_data_dir=${percona_data_dir}; }
# check Nginx dir
[ -e "${nginx_install_dir}/sbin/nginx" ] && web_install_dir=${nginx_install_dir}
[ -e "${tengine_install_dir}/sbin/nginx" ] && web_install_dir=${tengine_install_dir}
[ -e "${openresty_install_dir}/nginx/sbin/nginx" ] && web_install_dir=${openresty_install_dir}/nginx
+739
View File
@@ -0,0 +1,739 @@
#!/bin/bash
# Author: Alpha Eva <kaneawk AT gmail.com>
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
checkDownload() {
pushd ${oneinstack_dir}/src > /dev/null
# icu
if ! command -v icu-config >/dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
echo "Download icu..."
src_url=${mirror_link}/oneinstack/src/icu4c-${icu4c_ver}-src.tgz && Download_src
fi
# General system utils
if [ "${with_old_openssl_flag}" == 'y' ]; then
echo "Download openSSL..."
src_url=${mirror_link}/oneinstack/src/openssl-${openssl_ver}.tar.gz && Download_src
echo "Download cacert.pem..."
src_url=https://curl.se/ca/cacert.pem && Download_src
fi
# openssl1.1
if [[ ${nginx_option} =~ ^[1-3]$ ]]; then
echo "Download openSSL1.1..."
src_url=${mirror_link}/oneinstack/src/openssl-${openssl11_ver}.tar.gz && Download_src
fi
# jemalloc
if [[ ${nginx_option} =~ ^[1-3]$ ]] || [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
echo "Download jemalloc..."
src_url=${mirror_link}/oneinstack/src/jemalloc-${jemalloc_ver}.tar.bz2 && Download_src
fi
# pcre
if [[ "${nginx_option}" =~ ^[1-3]$ ]] || [ "${apache_flag}" == 'y' ]; then
echo "Download pcre..."
src_url=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
fi
# nginx/tengine/openresty
case "${nginx_option}" in
1)
echo "Download nginx..."
src_url=${mirror_link}/oneinstack/src/nginx-${nginx_ver}.tar.gz && Download_src
;;
2)
echo "Download tengine..."
#src_url=http://tengine.taobao.org/download/tengine-${tengine_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/tengine-${tengine_ver}.tar.gz && Download_src
;;
3)
echo "Download openresty..."
src_url=${mirror_link}/oneinstack/src/openresty-${openresty_ver}.tar.gz && Download_src
;;
esac
# if nginx_option=4 download caddy
if [ "${nginx_option}" == '4' ]; then
echo "Download caddy ${caddy_ver}"
src_url=${mirror_link}/caddy/v${caddy_ver}/caddy-${caddy_ver}.tar.gz && Download_src
fi
# caddy
if [ "${caddy_flag}" == 'y' ]; then
echo "Download caddy ${caddy_ver}"
src_url=${mirror_link}/caddy/v${caddy_ver}/caddy-${caddy_ver}.tar.gz && Download_src
fi
# apache
if [ "${apache_flag}" == 'y' ]; then
echo "Download apache 2.4..."
src_url=http://archive.apache.org/dist/httpd/httpd-${apache_ver}.tar.gz && Download_src
src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src
src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_ver}.tar.gz && Download_src
src_url=${mirror_link}/apache/httpd/nghttp2-${nghttp2_ver}.tar.gz && Download_src
fi
# tomcat
case "${tomcat_option}" in
1)
echo "Download tomcat 10..."
src_url=${mirror_link}/apache/tomcat/v${tomcat10_ver}/apache-tomcat-${tomcat10_ver}.tar.gz && Download_src
;;
2)
echo "Download tomcat 9..."
src_url=${mirror_link}/apache/tomcat/v${tomcat9_ver}/apache-tomcat-${tomcat9_ver}.tar.gz && Download_src
;;
3)
echo "Download tomcat 8..."
src_url=${mirror_link}/apache/tomcat/v${tomcat8_ver}/apache-tomcat-${tomcat8_ver}.tar.gz && Download_src
;;
4)
echo "Download tomcat 7..."
src_url=${mirror_link}/apache/tomcat/v${tomcat7_ver}/apache-tomcat-${tomcat7_ver}.tar.gz && Download_src
src_url=${mirror_link}/apache/tomcat/v${tomcat7_ver}/catalina-jmx-remote.jar && Download_src
;;
esac
# jdk apr
if [[ "${jdk_option}" =~ ^[1-2]$ ]]; then
echo "Download apr..."
src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src
fi
if [[ "${db_option}" =~ ^[1-9]$|^1[0-4]$ ]]; then
if [[ "${db_option}" =~ ^[1,2,5,6,7,9]$|^10$ ]] && [ "${dbinstallmethod}" == "2" ]; then
[[ "${db_option}" =~ ^[2,5,6,7]$|^10$ ]] && boost_ver=${boost_oldver}
[[ "${db_option}" =~ ^9$ ]] && boost_ver=${boost_percona_ver}
echo "Download boost..."
[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR_BOOST=${mirror_link}/oneinstack/src || DOWN_ADDR_BOOST=https://downloads.sourceforge.net/project/boost/boost/${boost_ver}
boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}')
src_url=${DOWN_ADDR_BOOST}/boost_${boostVersion2}.tar.gz && Download_src
fi
case "${db_option}" in
1)
# MySQL 8.0
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-8.0
DOWN_ADDR_MYSQL_BK=https://mirrors.aliyun.com/mysql/MySQL-8.0
DOWN_ADDR_MYSQL_BK2=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0
else
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-8.0
DOWN_ADDR_MYSQL_BK=https://mirrors.dotsrc.org/mysql/Downloads/MySQL-8.0
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 8.0 binary package..."
FILE_NAME=mysql-${mysql80_ver}-linux-glibc2.12-x86_64.tar.xz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 8.0 source package..."
FILE_NAME=mysql-${mysql80_ver}.tar.gz
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
2)
# MySQL 5.7
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-5.7
DOWN_ADDR_MYSQL_BK=https://mirrors.aliyun.com/mysql/MySQL-5.7
DOWN_ADDR_MYSQL_BK2=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7
else
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-5.7
DOWN_ADDR_MYSQL_BK=https://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.7
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 5.7 binary package..."
FILE_NAME=mysql-${mysql57_ver}-linux-glibc2.12-x86_64.tar.gz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 5.7 source package..."
FILE_NAME=mysql-${mysql57_ver}.tar.gz
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
3)
# MySQL 5.6
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MYSQL=http://mirrors.aliyun.com/mysql/MySQL-5.6
DOWN_ADDR_MYSQL_BK=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6
DOWN_ADDR_MYSQL_BK2=https://mirrors.aliyun.com/mysql/MySQL-5.6
else
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-5.6
DOWN_ADDR_MYSQL_BK=https://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.6
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 5.6 binary package..."
FILE_NAME=mysql-${mysql56_ver}-linux-glibc2.12-x86_64.tar.gz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 5.6 source package..."
FILE_NAME=mysql-${mysql56_ver}.tar.gz
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
4)
# MySQL 5.5
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MYSQL=http://mirrors.aliyun.com/mysql/MySQL-5.5
DOWN_ADDR_MYSQL_BK=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5
DOWN_ADDR_MYSQL_BK2=https://mirrors.aliyun.com/mysql/MySQL-5.5
else
DOWN_ADDR_MYSQL=https://cdn.mysql.com/Downloads/MySQL-5.5
DOWN_ADDR_MYSQL_BK=https://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.5
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 5.5 binary package..."
FILE_NAME=mysql-${mysql55_ver}-linux-glibc2.12-x86_64.tar.gz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 5.5 source package..."
FILE_NAME=mysql-${mysql55_ver}.tar.gz
src_url=${mirror_link}/oneinstack/src/mysql-5.5-fix-arm-client_plugin.patch && Download_src
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
[5-8])
case "${db_option}" in
5)
mariadb_ver=${mariadb1011_ver}
;;
6)
mariadb_ver=${mariadb105_ver}
;;
7)
mariadb_ver=${mariadb104_ver}
;;
8)
mariadb_ver=${mariadb55_ver}
;;
esac
if [ "${dbinstallmethod}" == '1' ]; then
FILE_NAME=mariadb-${mariadb_ver}-linux-systemd-x86_64.tar.gz
FILE_TYPE=bintar-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == '2' ]; then
FILE_NAME=mariadb-${mariadb_ver}.tar.gz
FILE_TYPE=source
fi
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MARIADB=https://mirrors.xtom.com.hk/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=http://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
else
DOWN_ADDR_MARIADB=https://mirrors.xtom.com.hk/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=http://mirror.nodesdirect.com/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
fi
if [ "${db_option}" == '8' ]; then
DOWN_ADDR_MARIADB=https://archive.mariadb.org/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=${DOWN_ADDR_MARIADB}
fi
echo "Download MariaDB ${FILE_NAME} package..."
src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src
wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MARIADB}/md5sums.txt -O ${FILE_NAME}.md5
MARAIDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MARAIDB_TAR_MD5}" ] && MARAIDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MARIADB_BK}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
9)
# Percona 8.0
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download Percona 8.0 binary package..."
FILE_NAME=Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.28.tar.gz
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-${percona80_ver}/binary/tarball
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download Percona 8.0 source package..."
FILE_NAME=percona-server-${percona80_ver}.tar.gz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_PERCONA=${mirror_link}/oneinstack/src
else
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-${percona80_ver}/source/tarball
fi
fi
# start download
src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src
src_url=${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum && Download_src
# verifying download
PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum)
[ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
10)
# Precona 5.7
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download Percona 5.7 binary package..."
FILE_NAME=Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.17.tar.gz
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/binary/tarball
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download Percona 5.7 source package..."
FILE_NAME=percona-server-${percona57_ver}.tar.gz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_PERCONA=${mirror_link}/oneinstack/src
else
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona57_ver}/source/tarball
fi
fi
# start download
src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src
src_url=${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum && Download_src
# verifying download
PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum)
[ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
11)
# Precona 5.6
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download Percona 5.6 binary package..."
perconaVerStr1=$(echo ${percona56_ver} | sed "s@-@-rel@")
FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_ver}/binary/tarball
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download Percona 5.6 source package..."
FILE_NAME=percona-server-${percona56_ver}.tar.gz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_PERCONA=${mirror_link}/oneinstack/src
else
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona56_ver}/source/tarball
fi
fi
# start download
src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src
src_url=${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum && Download_src
# verifying download
PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum)
[ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
12)
# Percona 5.5
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download Percona 5.5 binary package..."
perconaVerStr1=$(echo ${percona55_ver} | sed "s@-@-rel@")
FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/binary/tarball
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download Percona 5.5 source package..."
FILE_NAME=percona-server-${percona55_ver}.tar.gz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_PERCONA=${mirror_link}/oneinstack/src
else
DOWN_ADDR_PERCONA=https://downloads.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona55_ver}/source/tarball
fi
fi
# start download
src_url=${DOWN_ADDR_PERCONA}/${FILE_NAME} && Download_src
src_url=${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum && Download_src
# verifying download
PERCONA_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5sum)
[ -z "${PERCONA_TAR_MD5}" ] && PERCONA_TAR_MD5=$(curl -s ${mirror_link}/oneinstack/src/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME}; sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
13)
FILE_NAME=postgresql-${pgsql_ver}.tar.gz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_PGSQL=https://mirrors.tuna.tsinghua.edu.cn/postgresql/source/v${pgsql_ver}
DOWN_ADDR_PGSQL_BK=https://mirrors.ustc.edu.cn/postgresql/source/v${pgsql_ver}
else
DOWN_ADDR_PGSQL=https://ftp.postgresql.org/pub/source/v${pgsql_ver}
DOWN_ADDR_PGSQL_BK=https://ftp.heanet.ie/mirrors/postgresql/source/v${pgsql_ver}
fi
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 && Download_src
PGSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${PGSQL_TAR_MD5}" ] && PGSQL_TAR_MD5=$(curl -s ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PGSQL_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PGSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
14)
# MongoDB
echo "Download MongoDB binary package..."
FILE_NAME=mongodb-linux-x86_64-${mongodb_ver}.tgz
if [ "${OUTIP_STATE}"x == "China"x ]; then
DOWN_ADDR_MongoDB=${mirror_link}/oneinstack/src
else
DOWN_ADDR_MongoDB=https://fastdl.mongodb.org/linux
fi
src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 && Download_src
MongoDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MongoDB_TAR_MD5}" ] && MongoDB_TAR_MD5=$(curl -s ${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MongoDB_TAR_MD5}" ]; do
wget -c --no-check-certificate ${DOWN_ADDR_MongoDB}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MongoDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
esac
fi
# PHP
if [[ "${php_option}" =~ ^[1-9]$|^1[0-3]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^7[0-4]$|^8[0-3]$ ]]; then
echo "PHP common..."
src_url=${mirror_link}/oneinstack/src/libiconv-${libiconv_ver}.tar.gz && Download_src
src_url=https://curl.haxx.se/download/curl-${curl_ver}.tar.gz && Download_src
src_url=https://downloads.sourceforge.net/project/mhash/mhash/${mhash_ver}/mhash-${mhash_ver}.tar.gz && Download_src
src_url=https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_ver}/libmcrypt-${libmcrypt_ver}.tar.gz && Download_src
src_url=https://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_ver}/mcrypt-${mcrypt_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/freetype-${freetype_ver}.tar.gz && Download_src
fi
if [ "${php_option}" == '1' ] || [ "${mphp_ver}" == '53' ]; then
src_url=${mirror_link}/oneinstack/src/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src
src_url=${mirror_link}/oneinstack/src/php5.3patch && Download_src
src_url=https://secure.php.net/distributions/php-${php53_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/fpm-race-condition.patch && Download_src
elif [ "${php_option}" == '2' ] || [ "${mphp_ver}" == '54' ]; then
src_url=https://secure.php.net/distributions/php-${php54_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/fpm-race-condition.patch && Download_src
elif [ "${php_option}" == '3' ] || [ "${mphp_ver}" == '55' ]; then
src_url=https://secure.php.net/distributions/php-${php55_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/fpm-race-condition.patch && Download_src
elif [ "${php_option}" == '4' ] || [ "${mphp_ver}" == '56' ]; then
src_url=https://secure.php.net/distributions/php-${php56_ver}.tar.gz && Download_src
elif [ "${php_option}" == '5' ] || [ "${mphp_ver}" == '70' ]; then
src_url=https://secure.php.net/distributions/php-${php70_ver}.tar.gz && Download_src
elif [ "${php_option}" == '6' ] || [ "${mphp_ver}" == '71' ]; then
src_url=https://secure.php.net/distributions/php-${php71_ver}.tar.gz && Download_src
elif [ "${php_option}" == '7' ] || [ "${mphp_ver}" == '72' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php72_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
elif [ "${php_option}" == '8' ] || [ "${mphp_ver}" == '73' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php73_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
elif [ "${php_option}" == '9' ] || [ "${mphp_ver}" == '74' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php74_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '10' ] || [ "${mphp_ver}" == '80' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php80_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '11' ] || [ "${mphp_ver}" == '81' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php81_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '12' ] || [ "${mphp_ver}" == '82' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php82_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_up_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '13' ] || [ "${mphp_ver}" == '83' ]; then
src_url=${mirror_link}/oneinstack/src/php-${php83_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libsodium-${libsodium_up_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/libzip-${libzip_ver}.tar.gz && Download_src
fi
# PHP OPCache
case "${phpcache_option}" in
1)
if [[ "${php_option}" =~ ^[1-2]$ ]]; then
# php 5.3 5.4
echo "Download Zend OPCache..."
src_url=https://pecl.php.net/get/zendopcache-${zendopcache_ver}.tgz && Download_src
fi
;;
2)
echo "Download apcu..."
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
src_url=https://pecl.php.net/get/apcu-${apcu_oldver}.tgz && Download_src
else
src_url=https://pecl.php.net/get/apcu-${apcu_ver}.tgz && Download_src
fi
;;
3)
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
# php 5.3 5.4 5.5 5.6
echo "Download xcache..."
src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_ver}/xcache-${xcache_ver}.tar.gz && Download_src
fi
;;
4)
# php 5.3 5.4
if [ "${php_option}" == '1' ]; then
echo "Download eaccelerator 0.9..."
src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_ver}.tar.bz2 && Download_src
elif [ "${php_option}" == '2' ]; then
echo "Download eaccelerator 1.0 dev..."
src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
fi
;;
esac
# Zend Guard Loader
if [ "${pecl_zendguardloader}" == '1' -a "${armplatform}" != 'y' ]; then
case "${php_option}" in
4)
echo "Download zend loader for php 5.6..."
src_url=${mirror_link}/oneinstack/src/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src
;;
3)
echo "Download zend loader for php 5.5..."
src_url=${mirror_link}/oneinstack/src/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src
;;
2)
echo "Download zend loader for php 5.4..."
src_url=${mirror_link}/oneinstack/src/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src
;;
1)
echo "Download zend loader for php 5.3..."
src_url=${mirror_link}/oneinstack/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src
;;
esac
fi
# ioncube
if [ "${pecl_ioncube}" == '1' ]; then
echo "Download ioncube..."
src_url=https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz && Download_src
fi
# SourceGuardian
if [ "${pecl_sourceguardian}" == '1' ]; then
echo "Download SourceGuardian..."
src_url=${mirror_link}/oneinstack/src/loaders.linux-${ARCH}.tar.gz && Download_src
fi
# imageMagick
if [ "${pecl_imagick}" == '1' ]; then
echo "Download ImageMagick..."
src_url=${mirror_link}/oneinstack/src/ImageMagick-${imagemagick_ver}.tar.gz && Download_src
echo "Download imagick..."
if [[ "${php_option}" =~ ^1$ ]]; then
src_url=https://pecl.php.net/get/imagick-${imagick_oldver}.tgz && Download_src
else
src_url=https://pecl.php.net/get/imagick-${imagick_ver}.tgz && Download_src
fi
fi
# graphicsmagick
if [ "${pecl_gmagick}" == '1' ]; then
echo "Download graphicsmagick..."
src_url=https://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${graphicsmagick_ver}/GraphicsMagick-${graphicsmagick_ver}.tar.gz && Download_src
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
echo "Download gmagick for php..."
src_url=https://pecl.php.net/get/gmagick-${gmagick_oldver}.tgz && Download_src
else
echo "Download gmagick for php 7.x..."
src_url=https://pecl.php.net/get/gmagick-${gmagick_ver}.tgz && Download_src
fi
fi
# redis-server
if [ "${redis_flag}" == 'y' ]; then
echo "Download redis-server..."
src_url=http://download.redis.io/releases/redis-${redis_ver}.tar.gz && Download_src
fi
# pecl_redis
if [ "${pecl_redis}" == '1' ]; then
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
echo "Download pecl_redis for php 5.x..."
src_url=https://pecl.php.net/get/redis-4.3.0.tgz && Download_src
elif [[ "${php_option}" =~ ^[5-6]$ ]]; then
echo "Download pecl_redis for php 7.0~7.1..."
src_url=https://pecl.php.net/get/redis-5.3.7.tgz && Download_src
else
echo "Download pecl_redis for php 7.2+..."
src_url=https://pecl.php.net/get/redis-${pecl_redis_ver}.tgz && Download_src
fi
fi
# memcached-server
if [ "${memcached_flag}" == 'y' ]; then
echo "Download memcached-server..."
[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=${mirror_link}/oneinstack/src || DOWN_ADDR=http://www.memcached.org/files
src_url=${DOWN_ADDR}/memcached-${memcached_ver}.tar.gz && Download_src
fi
# pecl_memcached
if [ "${pecl_memcached}" == '1' ]; then
echo "Download libmemcached..."
src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz && Download_src
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
echo "Download pecl_memcached for php..."
src_url=https://pecl.php.net/get/memcached-${pecl_memcached_oldver}.tgz && Download_src
else
echo "Download pecl_memcached for php 7.x..."
src_url=https://pecl.php.net/get/memcached-${pecl_memcached_ver}.tgz && Download_src
fi
fi
# memcached-server pecl_memcached pecl_memcache
if [ "${pecl_memcache}" == '1' ]; then
if [[ "${php_option}" =~ ^[1-4]$ ]]; then
echo "Download pecl_memcache for php 5.x..."
src_url=https://pecl.php.net/get/memcache-3.0.8.tgz && Download_src
elif [[ "${php_option}" =~ ^[5-9]$ ]]; then
echo "Download pecl_memcache for php 7.x..."
src_url=https://pecl.php.net/get/memcache-${pecl_memcache_oldver}.tgz && Download_src
else
echo "Download pecl_memcache for php 8.x..."
src_url=https://pecl.php.net/get/memcache-${pecl_memcache_ver}.tgz && Download_src
fi
fi
# pecl_mongodb
if [ "${pecl_mongodb}" == '1' ]; then
echo "Download pecl mongo for php..."
src_url=https://pecl.php.net/get/mongo-${pecl_mongo_ver}.tgz && Download_src
echo "Download pecl mongodb for php..."
src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src
fi
# nodejs
if [ "${nodejs_flag}" == 'y' ]; then
echo "Download Nodejs..."
[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR_NODE=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release || DOWN_ADDR_NODE=https://nodejs.org/dist
src_url=${DOWN_ADDR_NODE}/v${nodejs_ver}/node-v${nodejs_ver}-linux-${SYS_ARCH_n}.tar.gz && Download_src
fi
# pureftpd
if [ "${pureftpd_flag}" == 'y' ]; then
echo "Download pureftpd..."
src_url=https://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_ver}.tar.gz && Download_src
fi
# phpMyAdmin
if [ "${phpmyadmin_flag}" == 'y' ]; then
echo "Download phpMyAdmin..."
if [[ "${php_option}" =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]]; then
src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpmyadmin_oldver}/phpMyAdmin-${phpmyadmin_oldver}-all-languages.tar.gz && Download_src
else
src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpmyadmin_ver}/phpMyAdmin-${phpmyadmin_ver}-all-languages.tar.gz && Download_src
fi
fi
popd > /dev/null
}
+138
View File
@@ -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
if [ -e "/etc/os-release" ]; then
. /etc/os-release
else
echo "${CFAILURE}/etc/os-release does not exist! ${CEND}"
kill -9 $$; exit 1;
fi
# Get OS Version
Platform=${ID,,}
VERSION_MAIN_ID=${VERSION_ID%%.*}
ARCH=$(arch)
if [[ "${Platform}" =~ ^centos$|^rhel$|^almalinux$|^rocky$|^fedora$|^amzn$|^ol$|^alinux$|^anolis$|^tencentos$|^opencloudos$|^euleros$|^openeuler$|^kylin$|^uos$|^kylinsecos$ ]]; then
PM=yum
Family=rhel
RHEL_ver=${VERSION_MAIN_ID}
if [[ "${Platform}" =~ ^centos$ ]]; then
if [ "${VERSION_MAIN_ID}" == '6' ]; then
sed -i "s@centos/\$releasever@centos-vault/6.10@g" /etc/yum.repos.d/CentOS-Base.repo
sed -i 's@centos/RPM-GPG@centos-vault/RPM-GPG@g' /etc/yum.repos.d/CentOS-Base.repo
[ -e /etc/yum.repos.d/epel.repo ] && rm -f /etc/yum.repos.d/epel.repo
fi
elif [[ "${Platform}" =~ ^fedora$ ]]; then
Fedora_ver=${VERSION_MAIN_ID}
[ ${VERSION_MAIN_ID} -ge 19 ] && [ ${VERSION_MAIN_ID} -lt 28 ] && RHEL_ver=7
[ ${VERSION_MAIN_ID} -ge 28 ] && [ ${VERSION_MAIN_ID} -lt 34 ] && RHEL_ver=8
[ ${VERSION_MAIN_ID} -ge 34 ] && RHEL_ver=9
elif [[ "${Platform}" =~ ^amzn$|^alinux$|^tencentos$|^euleros$ ]]; then
[[ "${VERSION_MAIN_ID}" =~ ^2$ ]] && RHEL_ver=7
[[ "${VERSION_MAIN_ID}" =~ ^3$ ]] && RHEL_ver=8
elif [[ "${Platform}" =~ ^openeuler$ ]]; then
[[ "${RHEL_ver}" =~ ^20$ ]] && RHEL_ver=7
[[ "${RHEL_ver}" =~ ^2[1,2]$ ]] && RHEL_ver=8
elif [[ "${Platform}" =~ ^kylin$ ]]; then
[[ "${RHEL_ver}" =~ ^V10$ ]] && RHEL_ver=7
elif [[ "${Platform}" =~ ^uos$ ]]; then
[[ "${RHEL_ver}" =~ ^20$ ]] && RHEL_ver=8
elif [[ "${Platform}" =~ ^kylinsecos$ ]]; then
[[ "${VERSION_ID}" =~ ^3.4 ]] && RHEL_ver=7
[[ "${VERSION_ID}" =~ ^3.5 ]] && RHEL_ver=8
fi
elif [[ "${Platform}" =~ ^debian$|^deepin$|^kali$ ]]; then
PM=apt-get
Family=debian
Debian_ver=${VERSION_MAIN_ID}
if [[ "${Platform}" =~ ^deepin$ ]]; then
[[ "${Debian_ver}" =~ ^20$ ]] && Debian_ver=10
[[ "${Debian_ver}" =~ ^23$ ]] && Debian_ver=11
elif [[ "${Platform}" =~ ^kali$ ]]; then
[[ "${Debian_ver}" =~ ^202 ]] && Debian_ver=10
fi
elif [[ "${Platform}" =~ ^ubuntu$|^linuxmint$|^elementary$ ]]; then
PM=apt-get
Family=ubuntu
Ubuntu_ver=${VERSION_MAIN_ID}
if [[ "${Platform}" =~ ^linuxmint$ ]]; then
[[ "${VERSION_MAIN_ID}" =~ ^18$ ]] && Ubuntu_ver=16
[[ "${VERSION_MAIN_ID}" =~ ^19$ ]] && Ubuntu_ver=18
[[ "${VERSION_MAIN_ID}" =~ ^20$ ]] && Ubuntu_ver=20
[[ "${VERSION_MAIN_ID}" =~ ^21$ ]] && Ubuntu_ver=22
elif [[ "${Platform}" =~ ^elementary$ ]]; then
[[ "${VERSION_MAIN_ID}" =~ ^5$ ]] && Ubuntu_ver=18
[[ "${VERSION_MAIN_ID}" =~ ^6$ ]] && Ubuntu_ver=20
[[ "${VERSION_MAIN_ID}" =~ ^7$ ]] && Ubuntu_ver=22
fi
else
echo "${CFAILURE}Does not support this OS ${CEND}"
kill -9 $$; exit 1;
fi
# Check OS Version
if [ ${RHEL_ver} -lt 7 >/dev/null 2>&1 ] || [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 16 >/dev/null 2>&1 ]; then
echo "${CFAILURE}Does not support this OS, Please install CentOS 7+,Debian 9+,Ubuntu 16+ ${CEND}"
kill -9 $$; exit 1;
fi
command -v gcc > /dev/null 2>&1 || $PM -y install gcc
gcc_ver=$(gcc -dumpversion | awk -F. '{print $1}')
[ ${gcc_ver} -lt 5 >/dev/null 2>&1 ] && redis_ver=${redis_oldver}
if uname -m | grep -Eqi "arm|aarch64"; then
armplatform="y"
if uname -m | grep -Eqi "armv7"; then
TARGET_ARCH="armv7"
elif uname -m | grep -Eqi "armv8"; then
TARGET_ARCH="arm64"
elif uname -m | grep -Eqi "aarch64"; then
TARGET_ARCH="aarch64"
else
TARGET_ARCH="unknown"
fi
fi
if [ "$(uname -r | awk -F- '{print $3}' 2>/dev/null)" == "Microsoft" ]; then
Wsl=true
fi
if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
if [ "${TARGET_ARCH}" == 'aarch64' ]; then
SYS_ARCH=arm64
SYS_ARCH_i=aarch64
SYS_ARCH_n=arm64
else
SYS_ARCH=amd64 #openjdk
SYS_ARCH_i=x86-64 #ioncube
SYS_ARCH_n=x64 #nodejs
fi
else
echo "${CWARNING}32-bit OS are not supported! ${CEND}"
kill -9 $$; exit 1;
fi
THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
# Percona binary: https://docs.percona.com/percona-server/5.7/installation/binary-tarball.html
if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then
sslLibVer=ssl100
elif [ "${RHEL_ver}" == '7' ] && [ "${Platform}" != 'fedora' ]; then
sslLibVer=ssl101
elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then
sslLibVer=ssl102
elif [ ${Fedora_ver} -ge 27 >/dev/null 2>&1 ]; then
sslLibVer=ssl102
elif [ "${RHEL_ver}" == '8' ]; then
sslLibVer=ssl1:111
else
sslLibVer=unknown
fi
+162
View File
@@ -0,0 +1,162 @@
#!/bin/bash
# Author: Alpha Eva <kaneawk AT gmail.com>
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
installDepsDebian() {
echo "${CMSG}Removing the conflicting packages...${CEND}"
if [ "${apache_flag}" == 'y' ]; then
killall apache2
pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
echo "${CMSG}Installing dependencies packages...${CEND}"
apt-get -y update
apt-get -y autoremove
apt-get -yf install
export DEBIAN_FRONTEND=noninteractive
# critical security updates
grep security /etc/apt/sources.list > /tmp/security.sources.list
apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
# Install needed packages
case "${Debian_ver}" in
9|10|11|12)
pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg62-turbo-dev libjpeg-dev libpng-dev libgd-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev rsync git lsof lrzsz rsyslog cron logrotate chrony libsqlite3-dev psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw"
;;
*)
echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}"
kill -9 $$; exit 1;
;;
esac
for Package in ${pkgList}; do
apt-get --no-install-recommends -y install ${Package}
done
}
installDepsRHEL() {
[ -e '/etc/yum.conf' ] && sed -i 's@^exclude@#exclude@' /etc/yum.conf
if [ "${RHEL_ver}" == '9' ]; then
if [[ "${Platform}" =~ "rhel" ]]; then
subscription-manager repos --enable codeready-builder-for-rhel-9-${ARCH}-rpms
dnf -y install chrony oniguruma-devel rpcgen
elif [[ "${Platform}" =~ "ol" ]]; then
dnf config-manager --set-enabled ol9_codeready_builder
dnf -y install chrony oniguruma-devel rpcgen
else
dnf -y --enablerepo=crb install chrony oniguruma-devel rpcgen
fi
systemctl enable chronyd
elif [ "${RHEL_ver}" == '8' ]; then
if [[ "${Platform}" =~ "rhel" ]]; then
subscription-manager repos --enable codeready-builder-for-rhel-8-${ARCH}-rpms
dnf -y install chrony oniguruma-devel rpcgen
elif [[ "${Platform}" =~ "ol" ]]; then
dnf config-manager --set-enabled ol8_codeready_builder
dnf -y install chrony oniguruma-devel rpcgen
else
[ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
if grep -qw "^\[PowerTools\]" /etc/yum.repos.d/*.repo; then
dnf -y --enablerepo=PowerTools install chrony oniguruma-devel rpcgen
elif grep -qw "^\[powertools\]" /etc/yum.repos.d/*.repo; then
dnf -y --enablerepo=powertools install chrony oniguruma-devel rpcgen
fi
fi
systemctl enable chronyd
elif [ "${RHEL_ver}" == '7' ]; then
[ -z "`grep -w epel /etc/yum.repos.d/*.repo`" ] && yum -y install epel-release
yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client"
fi
if [ "${RHEL_ver}" == '9' ]; then
[ ! -e "/usr/lib64/libtinfo.so.5" ] && ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
[ ! -e "/usr/lib64/libncurses.so.5" ] && ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
fi
echo "${CMSG}Installing dependencies packages...${CEND}"
# Install needed packages
pkgList="perl-FindBin deltarpm drpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libjpeg-turbo libjpeg-turbo-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel libzip libzip-devel glibc glibc-devel krb5-devel libc-client libc-client-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel ncurses-compat-libs libaio numactl numactl-libs readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel net-tools libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel libmcrypt libmcrypt-devel mhash mhash-devel mcrypt zip unzip chrony oniguruma-devel rpcgen sqlite-devel sysstat patch bc expect expat-devel perl-devel oniguruma oniguruma-devel libtirpc-devel nss libnsl rsync rsyslog git lsof lrzsz psmisc wget which libatomic tmux chkconfig firewalld"
for Package in ${pkgList}; do
yum -y install ${Package}
done
[ ${RHEL_ver} -lt 8 >/dev/null 2>&1 ] && yum -y install cmake3
yum -y update bash openssl glibc
}
installDepsUbuntu() {
# Uninstall the conflicting software
echo "${CMSG}Removing the conflicting packages...${CEND}"
if [ "${apache_flag}" == 'y' ]; then
killall apache2
pkgList="apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker php5 php5-common php5-cgi php5-cli php5-mysql php5-curl php5-gd"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
echo "${CMSG}Installing dependencies packages...${CEND}"
apt-get -y update
apt-get -y autoremove
apt-get -yf install
export DEBIAN_FRONTEND=noninteractive
[[ "${Ubuntu_ver}" =~ ^22$ ]] && apt-get -y --allow-downgrades install libicu70=70.1-2 libglib2.0-0=2.72.1-1 libxml2-dev
# critical security updates
grep security /etc/apt/sources.list > /tmp/security.sources.list
apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
# Install needed packages
pkgList="libperl-dev debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng-dev libpng12-0 libpng12-dev libpng3 libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-gnutls-dev libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev libsqlite3-dev libcloog-ppl1 bison patch vim zip unzip tmux htop bc dc expect libexpat1-dev rsyslog libonig-dev libtirpc-dev libnss3 rsync git lsof lrzsz chrony psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg ufw"
export DEBIAN_FRONTEND=noninteractive
for Package in ${pkgList}; do
apt-get --no-install-recommends -y install ${Package}
done
}
installDepsBySrc() {
pushd ${oneinstack_dir}/src > /dev/null
if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
tar xzf icu4c-${icu4c_ver}-src.tgz
pushd icu/source > /dev/null
./configure --prefix=/usr/local
make -j ${THREAD} && make install
popd > /dev/null
rm -rf icu
fi
if command -v lsof >/dev/null 2>&1; then
echo 'already initialize' > ~/.oneinstack
else
echo "${CFAILURE}${PM} config error parsing file failed${CEND}"
kill -9 $$; exit 1;
fi
popd > /dev/null
}
+32
View File
@@ -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
echo=echo
for cmd in echo /bin/echo; do
$cmd >/dev/null 2>&1 || continue
if ! $cmd -e "" | grep -qE '^-e'; then
echo=$cmd
break
fi
done
CSI=$($echo -e "\033[")
CEND="${CSI}0m"
CDGREEN="${CSI}32m"
CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m"
CYELLOW="${CSI}1;33m"
CBLUE="${CSI}1;34m"
CMAGENTA="${CSI}1;35m"
CCYAN="${CSI}1;36m"
CSUCCESS="$CDGREEN"
CFAILURE="$CRED"
CQUESTION="$CMAGENTA"
CWARNING="$CYELLOW"
CMSG="$CCYAN"
+41
View File
@@ -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_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
if [ "${OUTIP_STATE}"x == "China"x ]; then
wget --no-check-certificate -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 --no-check-certificate -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
}
+45
View File
@@ -0,0 +1,45 @@
#!/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
DEMO() {
pushd ${oneinstack_dir}/src > /dev/null
if [ ! -e ${wwwroot_dir}/default/index.html ]; then
[ "${OUTIP_STATE}"x == "China"x ] && /bin/cp ${oneinstack_dir}/config/index_cn.html ${wwwroot_dir}/default/index.html || /bin/cp ${oneinstack_dir}/config/index.html ${wwwroot_dir}/default
fi
if [ -e "${php_install_dir}/bin/php" ]; then
src_url=${mirror_link}/oneinstack/src/xprober.php && Download_src
/bin/cp xprober.php ${wwwroot_dir}/default
echo "<?php phpinfo() ?>" > ${wwwroot_dir}/default/phpinfo.php
case "${phpcache_option}" in
1)
src_url=${mirror_link}/oneinstack/src/ocp.php && Download_src
/bin/cp ocp.php ${wwwroot_dir}/default
;;
2)
sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/apc.php" target="_blank" class="links">APC</a>@' ${wwwroot_dir}/default/index.html
;;
3)
sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/xcache" target="_blank" class="links">xcache</a>@' ${wwwroot_dir}/default/index.html
;;
4)
/bin/cp eaccelerator-*/control.php ${wwwroot_dir}/default
sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/control.php" target="_blank" class="links">eAccelerator</a>@' ${wwwroot_dir}/default/index.html
;;
*)
sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@@' ${wwwroot_dir}/default/index.html
;;
esac
fi
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default
[ -e /bin/systemctl ] && systemctl daemon-reload
popd > /dev/null
}
+17
View File
@@ -0,0 +1,17 @@
#!/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
Download_src() {
[ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget --limit-rate=100M --tries=6 -c --no-check-certificate ${src_url}; sleep 1; }
if [ ! -e "${src_url##*/}" ]; then
echo "${CFAILURE}Auto download failed! You can manually download ${src_url} into the oneinstack/src directory.${CEND}"
kill -9 $$; exit 1;
fi
}
+73
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+96
View File
@@ -0,0 +1,96 @@
#!/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=${mirror_link}/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
tar xzf fail2ban-${fail2ban_ver}.tar.gz
pushd fail2ban-${fail2ban_ver} > /dev/null
if command -v python3 > /dev/null 2>&1; then
python3 setup.py install
else
python setup.py install
fi
/bin/cp build/fail2ban.service /lib/systemd/system/
systemctl enable fail2ban
[ -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`
if [ "${PM}" == 'yum' ]; then
cat > /etc/fail2ban/jail.local << EOF
[DEFAULT]
ignoreip = 127.0.0.1/8
bantime = 86400
findtime = 600
maxretry = 5
backend = auto
banaction = firewallcmd-ipset
action = %(action_mwl)s
[sshd]
enabled = true
filter = sshd
port = ${now_ssh_port}
action = %(action_mwl)s
logpath = /var/log/secure
bantime = 86400
findtime = 600
maxretry = 5
EOF
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq inactive; then
ufw default allow incoming
ufw --force enable
fi
cat > /etc/fail2ban/jail.local << EOF
[DEFAULT]
ignoreip = 127.0.0.1/8
bantime = 86400
findtime = 600
maxretry = 5
backend = auto
banaction = ufw
action = %(action_mwl)s
[sshd]
enabled = true
filter = sshd
port = ${now_ssh_port}
action = %(action_mwl)s
logpath = /var/log/auth.log
bantime = 86400
findtime = 600
maxretry = 5
EOF
fi
cat > /etc/logrotate.d/fail2ban << EOF
/var/log/fail2ban.log {
missingok
notifempty
postrotate
/usr/local/bin/fail2ban-client flushlogs >/dev/null || true
endscript
}
EOF
kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
systemctl start fail2ban
popd > /dev/null
if [ -e "/usr/local/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() {
systemctl stop fail2ban
systemctl disable fail2ban
rm -rf /usr/local/bin/fail2ban* /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban /lib/systemd/system/fail2ban.service
echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
}
+19
View File
@@ -0,0 +1,19 @@
#!/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
get_char() {
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
+100
View File
@@ -0,0 +1,100 @@
#!/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
# Custom profile
cat > /etc/profile.d/oneinstack.sh << EOF
HISTSIZE=10000
PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '
HISTTIMEFORMAT="%F %T \$(whoami) "
alias l='ls -AFhlt --color=auto'
alias lh='l | head'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias vi=vim
GREP_OPTIONS="--color=auto"
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
EOF
sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
# history
[ -z "$(grep history-timestamp ~/.bashrc)" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
# /etc/security/limits.conf
[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
[ -z "$(grep 'session required pam_limits.so' /etc/pam.d/common-session)" ] && echo "session required pam_limits.so" >> /etc/pam.d/common-session
sed -i '/^# End of file/,$d' /etc/security/limits.conf
cat >> /etc/security/limits.conf <<EOF
# End of file
* soft nproc 1000000
* hard nproc 1000000
* soft nofile 1000000
* hard nofile 1000000
root soft nproc 1000000
root hard nproc 1000000
root soft nofile 1000000
root hard nofile 1000000
EOF
# /etc/hosts
[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
# Set timezone
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/${timezone} /etc/localtime
# Set DNS
#cat > /etc/resolv.conf << EOF
#nameserver 114.114.114.114
#nameserver 8.8.8.8
#EOF
# /etc/sysctl.conf
[ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF
fs.file-max = 1000000
fs.inotify.max_user_instances = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_orphans = 32768
EOF
sysctl -p
sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup
sed -i 's@^# en_US.UTF-8@en_US.UTF-8@' /etc/locale.gen
init q
# ufw
if [ "${firewall_flag}" == 'y' ]; then
ufw allow 22/tcp
[ "${ssh_port}" != "22" ] && ufw allow ${ssh_port}/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
else
ufw --force disable
fi
systemctl restart rsyslog ssh
. /etc/profile
. ~/.bashrc
+113
View File
@@ -0,0 +1,113 @@
#!/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
# Close SELINUX
setenforce 0
sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
# Custom profile
cat > /etc/profile.d/oneinstack.sh << EOF
HISTSIZE=10000
PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\\\$ "
HISTTIMEFORMAT="%F %T \$(whoami) "
alias l='ls -AFhlt'
alias lh='l | head'
alias vi=vim
GREP_OPTIONS="--color=auto"
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
EOF
[[ "${Platform}" =~ ^euleros$|^openeuler$ ]] && sed -i '/HISTTIMEFORMAT=/d' /etc/profile.d/oneinstack.sh
[[ ! "${Platform}" =~ ^euleros$|^openeuler$ ]] && [ -z "$(grep ^'PROMPT_COMMAND=' /etc/bashrc)" ] && cat >> /etc/bashrc << EOF
PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }'
EOF
# /etc/security/limits.conf
[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
sed -i '/^# End of file/,$d' /etc/security/limits.conf
cat >> /etc/security/limits.conf <<EOF
# End of file
* soft nproc 1000000
* hard nproc 1000000
* soft nofile 1000000
* hard nofile 1000000
EOF
# /etc/hosts
[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
# Set timezone
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/${timezone} /etc/localtime
# ip_conntrack table full dropping packets
echo -e "modprobe nf_conntrack\nmodprobe nf_conntrack_ipv4" > /etc/sysconfig/modules/nf_conntrack.modules
chmod +x /etc/sysconfig/modules/nf_conntrack.modules
modprobe nf_conntrack
modprobe nf_conntrack_ipv4
echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf
# /etc/sysctl.conf
[ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk}
cat > /etc/sysctl.conf << EOF
fs.file-max=1000000
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_syncookies = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.ip_local_port_range = 1024 65000
net.nf_conntrack_max = 6553500
net.netfilter.nf_conntrack_max = 6553500
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
EOF
sysctl -p
if [ ${RHEL_ver} -ge 7 >/dev/null 2>&1 ]; then
sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
fi
# firewall
if [ "${firewall_flag}" == 'y' ]; then
systemctl enable firewalld
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port={22/tcp,80/tcp,443/tcp}
[ "${ssh_port}" != "22" ] && firewall-cmd --permanent --zone=public --add-port=${ssh_port}/tcp
firewall-cmd --reload
else
systemctl stop firewalld
systemctl disable firewalld
fi
systemctl restart rsyslog sshd
. /etc/profile
+100
View File
@@ -0,0 +1,100 @@
#!/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
# Custom profile
cat > /etc/profile.d/oneinstack.sh << EOF
HISTSIZE=10000
HISTTIMEFORMAT="%F %T \$(whoami) "
alias l='ls -AFhlt --color=auto'
alias lh='l | head'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias vi=vim
GREP_OPTIONS="--color=auto"
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
EOF
sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
# PS1
[ -z "$(grep ^PS1 ~/.bashrc)" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc
# history
[ -z "$(grep history-timestamp ~/.bashrc)" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
# /etc/security/limits.conf
[ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
[ -z "$(grep 'session required pam_limits.so' /etc/pam.d/common-session)" ] && echo "session required pam_limits.so" >> /etc/pam.d/common-session
sed -i '/^# End of file/,$d' /etc/security/limits.conf
cat >> /etc/security/limits.conf <<EOF
# End of file
* soft nproc 1000000
* hard nproc 1000000
* soft nofile 1000000
* hard nofile 1000000
root soft nproc 1000000
root hard nproc 1000000
root soft nofile 1000000
root hard nofile 1000000
EOF
# /etc/hosts
[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
# Set timezone
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/${timezone} /etc/localtime
# /etc/sysctl.conf
[ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF
fs.file-max = 1000000
fs.inotify.max_user_instances = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_orphans = 32768
EOF
sysctl -p
sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup
locale-gen en_US.UTF-8
[ -d "/var/lib/locales/supported.d" ] && echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local
cat > /etc/default/locale << EOF
LANG=en_US.UTF-8
LANGUAGE=en_US:en
EOF
# ufw
if [ "${firewall_flag}" == 'y' ]; then
ufw allow 22/tcp
[ "${ssh_port}" != "22" ] && ufw allow ${ssh_port}/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable
else
ufw --force disable
fi
systemctl restart rsyslog ssh
. /etc/profile
. ~/.bashrc
+43
View File
@@ -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
}
+35
View File
@@ -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_Jemalloc() {
if [ ! -e "/usr/local/lib/libjemalloc.so" ]; then
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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
popd > /dev/null
fi
}
+215
View File
@@ -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}'+" ../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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+217
View File
@@ -0,0 +1,217 @@
#!/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_MariaDB104() {
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-${mariadb104_ver}-linux-systemd-x86_64.tar.gz
mv mariadb-${mariadb104_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-${mariadb104_ver}.tar.gz
pushd mariadb-${mariadb104_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}'+" ../options.conf
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mariadb-${mariadb104_ver}-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mariadb-${mariadb104_ver} boost_${boostVersion2}
fi
else
rm -rf ${mariadb_install_dir}
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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_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
${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
}
+215
View File
@@ -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_MariaDB105() {
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-${mariadb105_ver}-linux-systemd-x86_64.tar.gz
mv mariadb-${mariadb105_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-${mariadb105_ver}.tar.gz
pushd mariadb-${mariadb105_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}'+" ../options.conf
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mariadb-${mariadb105_ver}-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mariadb-${mariadb105_ver} boost_${boostVersion2}
fi
else
rm -rf ${mariadb_install_dir}
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+216
View File
@@ -0,0 +1,216 @@
#!/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_MariaDB55() {
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-${mariadb55_ver}-linux-systemd-x86_64.tar.gz
mv mariadb-${mariadb55_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
tar xzf mariadb-${mariadb55_ver}.tar.gz
pushd mariadb-${mariadb55_ver}
[ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
cmake . -DCMAKE_INSTALL_PREFIX=${mariadb_install_dir} \
-DMYSQL_DATADIR=${mariadb_data_dir} \
-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_READLINE=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}'+" ../options.conf
echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mariadb-${mariadb55_ver}-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mariadb-${mariadb55_ver}
fi
else
rm -rf ${mariadb_install_dir}
echo "${CFAILURE}MariaDB install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
[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
#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
myisam_repair_threads = 1
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
}
+127
View File
@@ -0,0 +1,127 @@
#!/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_memcached_server() {
pushd ${oneinstack_dir}/src > /dev/null
# memcached server
id -u memcached >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /sbin/nologin memcached
tar xzf memcached-${memcached_ver}.tar.gz
pushd memcached-${memcached_ver} > /dev/null
[ ! -d "${memcached_install_dir}" ] && mkdir -p ${memcached_install_dir}
./configure --prefix=${memcached_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
if [ -f "${memcached_install_dir}/bin/memcached" ]; then
echo "${CSUCCESS}memcached installed successfully! ${CEND}"
rm -rf memcached-${memcached_ver}
ln -s ${memcached_install_dir}/bin/memcached /usr/bin/memcached
/bin/cp ../init.d/memcached.service /lib/systemd/system/
systemctl enable memcached
systemctl start memcached
rm -rf memcached-${memcached_ver}
else
rm -rf ${memcached_install_dir}
echo "${CFAILURE}memcached-server install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
popd > /dev/null
}
Install_pecl_memcache() {
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_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then
tar xzf memcache-3.0.8.tgz
pushd memcache-3.0.8 > /dev/null
elif [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '7' ]; then
tar xzf memcache-${pecl_memcache_oldver}.tgz
pushd memcache-${pecl_memcache_oldver} > /dev/null
else
#git clone https://github.com/websupport-sk/pecl-memcache.git
tar xzf memcache-${pecl_memcache_ver}.tgz
pushd memcache-${pecl_memcache_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}/memcache.so" ]; then
echo "extension=memcache.so" > ${php_install_dir}/etc/php.d/05-memcache.ini
echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}"
rm -rf memcache-${pecl_memcache_ver} memcache-${pecl_memcache_oldver} memcache-3.0.8
else
echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
popd > /dev/null
fi
}
Install_pecl_memcached() {
if [ -e "${php_install_dir}/bin/phpize" ]; then
pushd ${oneinstack_dir}/src > /dev/null
phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
# php memcached extension
tar xzf libmemcached-${libmemcached_ver}.tar.gz
patch -d libmemcached-${libmemcached_ver} -p0 < libmemcached-build.patch
pushd libmemcached-${libmemcached_ver} > /dev/null
[ "${PM}" == 'yum' ] && yum -y install cyrus-sasl-devel
[ "${PM}" == 'apt-get' ] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure
./configure --with-memcached=${memcached_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf libmemcached-${libmemcached_ver}
if [ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1}')" == '5' ]; then
tar xzf memcached-${pecl_memcached_oldver}.tgz
pushd memcached-${pecl_memcached_oldver} > /dev/null
else
tar xzf memcached-${pecl_memcached_ver}.tgz
pushd memcached-${pecl_memcached_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}/memcached.so" ]; then
cat > ${php_install_dir}/etc/php.d/05-memcached.ini << EOF
extension=memcached.so
memcached.use_sasl=1
EOF
echo "${CSUCCESS}PHP memcached module installed successfully! ${CEND}"
rm -rf memcached-${pecl_memcached_oldver} memcached-${pecl_memcached_ver}
else
echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
popd > /dev/null
fi
}
Uninstall_pecl_memcache() {
if [ -e "${php_install_dir}/etc/php.d/05-memcache.ini" ]; then
rm -f ${php_install_dir}/etc/php.d/05-memcache.ini
echo; echo "${CMSG}PHP memcache module uninstall completed${CEND}"
else
echo; echo "${CWARNING}PHP memcache module does not exist! ${CEND}"
fi
}
Uninstall_pecl_memcached() {
if [ -e "${php_install_dir}/etc/php.d/05-memcached.ini" ]; then
rm -f ${php_install_dir}/etc/php.d/05-memcached.ini
echo; echo "${CMSG}PHP memcached module uninstall completed${CEND}"
else
echo; echo "${CWARNING}PHP memcached module does not exist! ${CEND}"
fi
}
+48
View File
@@ -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
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
Mem=`free -m | awk '/Mem:/{print $2}'`
Swap=`free -m | awk '/Swap:/{print $2}'`
if [ $Mem -le 640 ]; then
Mem_level=512M
Memory_limit=64
THREAD=1
elif [ $Mem -gt 640 -a $Mem -le 1280 ]; then
Mem_level=1G
Memory_limit=128
elif [ $Mem -gt 1280 -a $Mem -le 2500 ]; then
Mem_level=2G
Memory_limit=192
elif [ $Mem -gt 2500 -a $Mem -le 3500 ]; then
Mem_level=3G
Memory_limit=256
elif [ $Mem -gt 3500 -a $Mem -le 4500 ]; then
Mem_level=4G
Memory_limit=320
elif [ $Mem -gt 4500 -a $Mem -le 8000 ]; then
Mem_level=6G
Memory_limit=384
elif [ $Mem -gt 8000 ]; then
Mem_level=8G
Memory_limit=448
fi
# add swapfile
if [ ! -e ~/.oneinstack ] && [ "${Swap}" == '0' ] && [ ${Mem} -le 2048 ]; then
echo "${CWARNING}Add Swap file, It may take a few minutes... ${CEND}"
dd if=/dev/zero of=/swapfile count=2048 bs=1M
mkswap /swapfile
swapon /swapfile
chmod 600 /swapfile
[ -z "`grep swapfile /etc/fstab`" ] && echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
fi
+79
View File
@@ -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}/init.d/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'+" ../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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+87
View File
@@ -0,0 +1,87 @@
#!/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
53)
. include/php-5.3.sh
Install_PHP53 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
54)
. include/php-5.4.sh
Install_PHP54 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
55)
. include/php-5.5.sh
Install_PHP55 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
56)
. include/php-5.6.sh
Install_PHP56 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
70)
. include/php-7.0.sh
Install_PHP70 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
71)
. include/php-7.1.sh
Install_PHP71 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
72)
. include/php-7.2.sh
Install_PHP72 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
73)
. include/php-7.3.sh
Install_PHP73 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
74)
. include/php-7.4.sh
Install_PHP74 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
80)
. include/php-8.0.sh
Install_PHP80 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
81)
. include/php-8.1.sh
Install_PHP81 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
82)
. include/php-8.2.sh
Install_PHP82 2>&1 | tee -a ${oneinstack_dir}/install.log
;;
83)
. include/php-8.3.sh
Install_PHP83 2>&1 | tee -a ${oneinstack_dir}/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
}
+220
View File
@@ -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_MySQL55() {
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-${mysql55_ver}-linux-glibc2.12-x86_64.tar.gz
mv mysql-${mysql55_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
tar xzf mysql-${mysql55_ver}.tar.gz
pushd mysql-${mysql55_ver}
[ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
-DMYSQL_DATADIR=${mysql_data_dir} \
-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_READLINE=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}'+" ../options.conf
echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mysql-${mysql55_ver}-*-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mysql-${mysql55_ver}
fi
else
rm -rf ${mysql_install_dir}
echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
#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_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
myisam_repair_threads = 1
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}/scripts/mysql_install_db --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 "delete from mysql.user where Password='' and User not like 'mysql.%';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
${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
}
+219
View File
@@ -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_MySQL56() {
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-${mysql56_ver}-linux-glibc2.12-x86_64.tar.gz
mv mysql-${mysql56_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
tar xzf mysql-${mysql56_ver}.tar.gz
pushd mysql-${mysql56_ver}
cmake . -DCMAKE_INSTALL_PREFIX=${mysql_install_dir} \
-DMYSQL_DATADIR=${mysql_data_dir} \
-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}'+" ../options.conf
echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mysql-${mysql56_ver}-*-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mysql-${mysql56_ver}
fi
else
rm -rf ${mysql_install_dir}
echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
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
myisam_repair_threads = 1
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}/scripts/mysql_install_db --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 "delete from mysql.user where Password='' and User not like 'mysql.%';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
${mysql_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
${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
}
+219
View File
@@ -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}'+" ../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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+220
View File
@@ -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}'+" ../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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+220
View File
@@ -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_MySQL82() {
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-${mysql82_ver}-linux-glibc2.17-x86_64.tar.xz
mv mysql-${mysql82_ver}-linux-glibc2.17-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-${mysql82_ver}.tar.gz
pushd mysql-${mysql82_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}'+" ../options.conf
echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf mysql-${mysql82_ver}-*-x86_64
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf mysql-${mysql82_ver} boost_${boostVersion2}
fi
else
rm -rf ${mysql_install_dir}
echo "${CFAILURE}MySQL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+99
View File
@@ -0,0 +1,99 @@
#!/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
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' ${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_install_dir}*
echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
else
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* nginx-${nginx_ver}* ${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 ../init.d/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}
if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then
/bin/cp ../config/nginx_apache.conf ${nginx_install_dir}/conf/nginx.conf
elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-1]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then
/bin/cp ../config/nginx_tomcat.conf ${nginx_install_dir}/conf/nginx.conf
else
/bin/cp ../config/nginx.conf ${nginx_install_dir}/conf/nginx.conf
[[ "${php_option}" =~ ^[1-9]$|^1[0-1]$ ]] && [ -z "`grep '/php-fpm_status' ${nginx_install_dir}/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${nginx_install_dir}/conf/nginx.conf
fi
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
}
+187
View File
@@ -0,0 +1,187 @@
#!/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=${mirror_link}/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=${mirror_link}/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=${mirror_link}/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=${mirror_link}/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=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
src_url=${mirror_link}/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\'@" ../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
}
Tengine_lua_waf() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${tengine_install_dir}/sbin/nginx" ] && echo "${CWARNING}Tengine 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=${mirror_link}/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
fi
if [ ! -e "/usr/local/lib/lua/5.1/cjson.so" ]; then
src_url=${mirror_link}/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
${tengine_install_dir}/sbin/nginx -V &> $$
tengine_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
rm -rf $$
tengine_configure_args=`echo ${tengine_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 ${tengine_configure_args} | grep lua`" ]; then
src_url=http://tengine.taobao.org/download/tengine-${tengine_ver}.tar.gz && Download_src
src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/lua-nginx-module.tar.gz && Download_src
tar xzf tengine-${tengine_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.tar.gz
pushd tengine-${tengine_ver}
make clean
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
./configure ${tengine_configure_args} --with-ld-opt="-Wl,-rpath,/usr/local/lib" --add-module=../lua-nginx-module --add-module=../ngx_devel_kit
make -j ${THREAD}
if [ -f "objs/nginx" ]; then
/bin/mv ${tengine_install_dir}/sbin/nginx{,`date +%m%d`}
/bin/mv ${tengine_install_dir}/modules{,`date +%m%d`}
/bin/cp objs/nginx ${tengine_install_dir}/sbin/nginx
chmod +x ${tengine_install_dir}/sbin/*
make install
kill -USR2 `cat /var/run/nginx.pid`
sleep 1
kill -QUIT `cat /var/run/nginx.pid.oldbin`
popd > /dev/null
sed -i "s@^nginx_modules_options='\(.*\)'@nginx_modules_options=\'\1 --with-ld-opt=\"-Wl,-rpath,/usr/local/lib\" --add-module=../lua-nginx-module --add-module=../ngx_devel_kit\'@" ../options.conf
echo "${CSUCCESS}lua_module installed successfully! ${CEND}"
rm -rf tengine-${tengine_ver}
else
echo "${CFAILURE}lua_module install failed! ${CEND}"
kill -9 $$; exit 1;
fi
fi
popd > /dev/null
}
enable_lua_waf() {
pushd ${oneinstack_dir}/src > /dev/null
. ../include/check_dir.sh
rm -f ngx_lua_waf.tar.gz
src_url=${mirror_link}/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
. ../include/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
}
+35
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
Binary file not shown.
Binary file not shown.
+41
View File
@@ -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_OpenJDK11() {
if [ "${Family}" == 'rhel' ]; then
yum -y install java-11-openjdk-devel
JAVA_HOME=/usr/lib/jvm/java-11-openjdk
elif [ "${Family}" == 'debian' ]; then
apt-get --no-install-recommends -y install openjdk-11-jdk
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${SYS_ARCH}
elif [ "${Family}" == 'ubuntu' ]; then
if [[ "${Ubuntu_ver}" =~ ^16$ ]]; then
cat ${oneinstack_dir}/src/adoptium.key | sudo apt-key add -
apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb
apt -y update
apt-get --no-install-recommends -y install temurin-11-jdk
JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-${SYS_ARCH}
else
apt-get --no-install-recommends -y install openjdk-11-jdk
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-${SYS_ARCH}
fi
fi
if [ -e "${JAVA_HOME}/bin/java" ]; then
cat > /etc/profile.d/openjdk.sh << EOF
export JAVA_HOME=${JAVA_HOME}
export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib
EOF
. /etc/profile.d/openjdk.sh
echo "${CSUCCESS}OpenJDK11 installed successfully! ${CEND}"
else
echo "${CFAILURE}OpenJDK11 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
}
+62
View File
@@ -0,0 +1,62 @@
#!/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_OpenJDK17() {
if [ "${Family}" == 'rhel' ]; then
if [[ "${RHEL_ver}" =~ ^7$ ]]; then
cat > /etc/yum.repos.d/adoptium.repo << EOF
[Adoptium]
name=Adoptium
baseurl=https://mirrors.tuna.tsinghua.edu.cn/Adoptium/rpm/rhel\$releasever-\$basearch/
enabled=1
gpgcheck=0
EOF
yum -y install temurin-17-jdk
JAVA_HOME=/usr/lib/jvm/temurin-17-jdk
else
yum -y install java-17-openjdk-devel
JAVA_HOME=/usr/lib/jvm/java-17-openjdk
fi
elif [ "${Family}" == 'debian' ]; then
if [[ "${Debian_ver}" =~ ^9$|^10$ ]]; then
#wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -
cat ${oneinstack_dir}/src/adoptium.key | sudo apt-key add -
apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb
apt -y update
apt-get --no-install-recommends -y install temurin-17-jdk
JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-${SYS_ARCH}
else
apt-get --no-install-recommends -y install openjdk-17-jdk
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${SYS_ARCH}
fi
elif [ "${Family}" == 'ubuntu' ]; then
if [[ "${Ubuntu_ver}" =~ ^16$ ]]; then
cat ${oneinstack_dir}/src/adoptium.key | sudo apt-key add -
apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb
apt -y update
apt-get --no-install-recommends -y install temurin-17-jdk
JAVA_HOME=/usr/lib/jvm/temurin-17-jdk-${SYS_ARCH}
else
apt-get --no-install-recommends -y install openjdk-17-jdk
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${SYS_ARCH}
fi
fi
if [ -e "${JAVA_HOME}/bin/java" ]; then
cat > /etc/profile.d/openjdk.sh << EOF
export JAVA_HOME=${JAVA_HOME}
export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib
EOF
. /etc/profile.d/openjdk.sh
echo "${CSUCCESS}OpenJDK17 installed successfully! ${CEND}"
else
echo "${CFAILURE}OpenJDK17 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
}
+42
View File
@@ -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_OpenJDK8() {
if [ "${Family}" == 'rhel' ]; then
yum -y install java-1.8.0-openjdk-devel
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
elif [ "${Family}" == 'debian' ]; then
if [[ "${Debian_ver}" =~ ^10$|^11$|^12$ ]]; then
#wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | apt-key add -
cat ${oneinstack_dir}/src/adoptium.key | sudo apt-key add -
apt-add-repository --yes https://mirrors.tuna.tsinghua.edu.cn/Adoptium/deb
apt -y update
apt-get --no-install-recommends -y install temurin-8-jdk
JAVA_HOME=/usr/lib/jvm/temurin-8-jdk-${SYS_ARCH}
elif [[ "${Debian_ver}" =~ ^9$ ]]; then
apt-get --no-install-recommends -y install openjdk-8-jdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH}
fi
elif [ "${Family}" == 'ubuntu' ]; then
apt-get --no-install-recommends -y install openjdk-8-jdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-${SYS_ARCH}
fi
if [ -e "${JAVA_HOME}/bin/java" ]; then
cat > /etc/profile.d/openjdk.sh << EOF
export JAVA_HOME=${JAVA_HOME}
export CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib
EOF
. /etc/profile.d/openjdk.sh
echo "${CSUCCESS}OpenJDK8 installed successfully! ${CEND}"
else
echo "${CFAILURE}OpenJDK8 install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
}
+95
View File
@@ -0,0 +1,95 @@
#!/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_OpenResty() {
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 openresty-${openresty_ver}.tar.gz
tar xzf openssl-${openssl11_ver}.tar.gz
pushd openresty-${openresty_ver} > /dev/null
# close debug
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-${openresty_ver%.*}/auto/cc/gcc # close debug
[ ! -d "${openresty_install_dir}" ] && mkdir -p ${openresty_install_dir}
./configure --prefix=${openresty_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-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 -Wl,-u,pcre_version' ${nginx_modules_options}
make -j ${THREAD} && make install
if [ -e "${openresty_install_dir}/nginx/conf/nginx.conf" ]; then
popd > /dev/null
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* openresty-${openresty_ver}* ${openresty_install_dir}*
echo "${CSUCCESS}OpenResty installed successfully! ${CEND}"
else
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* openresty-${openresty_ver}* ${openresty_install_dir}*
echo "${CFAILURE}OpenResty install failed, Please Contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${openresty_install_dir}/nginx/sbin:\$PATH" >> /etc/profile
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${openresty_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${openresty_install_dir}/nginx/sbin:\1@" /etc/profile
. /etc/profile
/bin/cp ../init.d/nginx.service /lib/systemd/system/
sed -i "s@/usr/local/nginx@${openresty_install_dir}/nginx@g" /lib/systemd/system/nginx.service
systemctl enable nginx
mv ${openresty_install_dir}/nginx/conf/nginx.conf{,_bk}
if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then
/bin/cp ../config/nginx_apache.conf ${openresty_install_dir}/nginx/conf/nginx.conf
elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-1]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then
/bin/cp ../config/nginx_tomcat.conf ${openresty_install_dir}/nginx/conf/nginx.conf
else
/bin/cp ../config/nginx.conf ${openresty_install_dir}/nginx/conf/nginx.conf
[[ "${php_option}" =~ ^[1-9]$|^1[0-1]$ ]] && [ -z "`grep '/php-fpm_status' ${openresty_install_dir}/nginx/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${openresty_install_dir}/nginx/conf/nginx.conf
fi
cat > ${openresty_install_dir}/nginx/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@" ${openresty_install_dir}/nginx/conf/nginx.conf
sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${openresty_install_dir}/nginx/conf/nginx.conf
sed -i "s@^user www www@user ${run_user} ${run_group}@" ${openresty_install_dir}/nginx/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
}
+170
View File
@@ -0,0 +1,170 @@
#!/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
if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
php5_with_openssl="--with-openssl"
php70_with_openssl="--with-openssl"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php82_with_openssl="--with-openssl"
php83_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl"
php70_with_ssl="--with-ssl"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php82_with_ssl="--with-ssl"
php83_with_ssl="--with-ssl"
php5_with_curl="--with-curl"
php70_with_curl="--with-curl"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
php82_with_curl="--with-curl"
php83_with_curl="--with-curl"
elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php82_with_openssl="--with-openssl"
php83_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php82_with_ssl="--with-ssl"
php83_with_ssl="--with-ssl"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
php82_with_curl="--with-curl"
php83_with_curl="--with-curl"
[[ ${php_option} =~ ^[1-4]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y
elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl=${openssl_install_dir}"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php82_with_openssl="--with-openssl"
php83_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl=${openssl_install_dir}"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php82_with_ssl="--with-ssl"
php83_with_ssl="--with-ssl"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl=${curl_install_dir}"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
php82_with_curl="--with-curl"
php83_with_curl="--with-curl"
[[ ${php_option} =~ ^[1-5]$ ]] || [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y
else
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl=${openssl_install_dir}"
php71_with_openssl="--with-openssl=${openssl_install_dir}"
php72_with_openssl="--with-openssl=${openssl_install_dir}"
php73_with_openssl="--with-openssl=${openssl_install_dir}"
php74_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php80_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php82_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php83_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl=${openssl_install_dir}"
php71_with_ssl="--with-ssl=${openssl_install_dir}"
php72_with_ssl="--with-ssl=${openssl_install_dir}"
php73_with_ssl="--with-ssl=${openssl_install_dir}"
php74_with_ssl="--with-ssl=${openssl_install_dir}"
php80_with_ssl="--with-ssl=${openssl_install_dir}"
php81_with_ssl="--with-ssl=${openssl_install_dir}"
php82_with_ssl="--with-ssl=${openssl_install_dir}"
php83_with_ssl="--with-ssl=${openssl_install_dir}"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl=${curl_install_dir}"
php71_with_curl="--with-curl=${curl_install_dir}"
php72_with_curl="--with-curl=${curl_install_dir}"
php73_with_curl="--with-curl=${curl_install_dir}"
php74_with_curl="--with-curl=${curl_install_dir}"
php80_with_curl="--with-curl=${curl_install_dir}"
php81_with_curl="--with-curl=${curl_install_dir}"
php82_with_curl="--with-curl=${curl_install_dir}"
php83_with_curl="--with-curl=${curl_install_dir}"
with_old_openssl_flag=y
fi
Install_openSSL() {
if [ "${with_old_openssl_flag}" == 'y' ]; then
if [ ! -e "${openssl_install_dir}/lib/libssl.a" ]; then
pushd ${oneinstack_dir}/src > /dev/null
tar xzf openssl-${openssl_ver}.tar.gz
pushd openssl-${openssl_ver} > /dev/null
make clean
./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
make depend
make -j ${THREAD} && make install
popd > /dev/null
if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
echo "${CSUCCESS}openSSL installed successfully! ${CEND}"
/bin/cp cacert.pem ${openssl_install_dir}/cert.pem
rm -rf openssl-${openssl_ver}
else
echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
popd > /dev/null
fi
fi
}
+41
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+42
View File
@@ -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
sed -i 's@^CFLAGS =.*@CFLAGS = -std=c99 -g@' 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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+58
View File
@@ -0,0 +1,58 @@
#!/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
if [ "${RHEL_ver}" == '9' ]; then
cat > /etc/yum.repos.d/remi.repo << EOF
[remi]
name=Remi's RPM repository for Enterprise Linux 9 - \$basearch
mirrorlist=http://cdn.remirepo.net/enterprise/9/remi/\$basearch/mirror
enabled=0
gpgcheck=0
EOF
dnf -y --enablerepo=remi install uw-imap-devel
else
yum -y install libc-client-devel
[ ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
fi
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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+52
View File
@@ -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_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
if [ "${PM}" == 'yum' ]; then
./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib64
else
./configure --with-php-config=${php_install_dir}/bin/php-config --with-ldap --with-libdir=lib/x86_64-linux-gnu
fi
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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+69
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+46
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+54
View File
@@ -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.3$ ]]; 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=${mirror_link}/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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+62
View File
@@ -0,0 +1,62 @@
#!/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-4.5.2.tgz && Download_src
tar xzf swoole-4.5.2.tgz
pushd swoole-4.5.2 > /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.[2-4]$ ]]; 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} --enable-http2 --enable-swoole-json --enable-swoole-curl
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} swoole-1.10.5 swoole-4.5.2
else
echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+68
View File
@@ -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=${mirror_link}/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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+46
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+46
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+220
View File
@@ -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_Percona55() {
pushd ${oneinstack_dir}/src > /dev/null
id -u mysql >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
[ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir}
if [ "${dbinstallmethod}" == "1" ]; then
perconaVerStr1=$(echo ${percona55_ver} | sed "s@-@-rel@")
tar xzf ./Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz
mv Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}/* ${percona_install_dir}
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
sed -i "s@/usr/local/Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe
elif [ "${dbinstallmethod}" == "2" ]; then
tar xzf percona-server-${percona55_ver}.tar.gz
pushd percona-server-${percona55_ver}
[ "${armplatform}" == "y" ] && patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \
-DMYSQL_DATADIR=${percona_data_dir} \
-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_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_READLINE=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 "${percona_install_dir}/support-files" ]; then
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
echo "${CSUCCESS}Percona installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf percona-server-${percona55_ver}
fi
else
rm -rf ${percona_install_dir}
echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
/bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${percona_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="Percona [\\d]> "
no-auto-rehash
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = ${percona_install_dir}
datadir = ${percona_data_dir}
pid-file = ${percona_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 = ${percona_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${percona_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_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
myisam_repair_threads = 1
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
${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
chown mysql:mysql -R ${percona_data_dir}
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
service mysqld start
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile
. /etc/profile
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mysql.%';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf
ldconfig
service mysqld stop
}
+220
View File
@@ -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_Percona56() {
pushd ${oneinstack_dir}/src > /dev/null
id -u mysql >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
[ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir}
if [ "${dbinstallmethod}" == "1" ]; then
perconaVerStr1=$(echo ${percona56_ver} | sed "s@-@-rel@")
tar xzf ./Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}.tar.gz
mv Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}/* ${percona_install_dir}
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
sed -i "s@/usr/local/Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe
elif [ "${dbinstallmethod}" == "2" ]; then
tar xzf percona-server-${percona56_ver}.tar.gz
pushd percona-server-${percona56_ver}
cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \
-DMYSQL_DATADIR=${percona_data_dir} \
-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_ARCHIVE_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 "${percona_install_dir}/support-files" ]; then
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
echo "${CSUCCESS}Percona installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf percona-server-${percona56_ver}
fi
else
rm -rf ${percona_install_dir}
echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
/bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${percona_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="Percona [\\d]> "
no-auto-rehash
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = ${percona_install_dir}
datadir = ${percona_data_dir}
pid-file = ${percona_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 = ${percona_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${percona_data_dir}/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#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_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
myisam_repair_threads = 1
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
${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
chown mysql:mysql -R ${percona_data_dir}
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
service mysqld start
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile
. /etc/profile
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='' and User not like 'mysql.%';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf
ldconfig
service mysqld stop
}
+220
View File
@@ -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_Percona57() {
pushd ${oneinstack_dir}/src > /dev/null
id -u mysql >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
[ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir}
if [ "${dbinstallmethod}" == "1" ]; then
tar xzf Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.17.tar.gz
mv Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.17/* ${percona_install_dir}
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
sed -i "s@Percona-Server-${percona57_ver}-Linux.x86_64.glibc2.17@${percona_install_dir}@g" ${percona_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 percona-server-${percona57_ver}.tar.gz
pushd percona-server-${percona57_ver}
cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \
-DMYSQL_DATADIR=${percona_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 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=system \
-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 "${percona_install_dir}/support-files" ]; then
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
echo "${CSUCCESS}Percona installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf Percona-Server-${percona57_ver}-Linux.x86_64.${sslLibVer}
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf percona-server-${percona57_ver} boost_${boostVersion2}
fi
else
rm -rf ${percona_install_dir}
echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
/bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${percona_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="Percona [\\d]> "
no-auto-rehash
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = ${percona_install_dir}
datadir = ${percona_data_dir}
pid-file = ${percona_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 = ${percona_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${percona_data_dir}/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#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_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
${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
chown mysql:mysql -R ${percona_data_dir}
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
service mysqld start
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile
. /etc/profile
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
[ -e "${percona_install_dir}/my.cnf" ] && rm -rf ${percona_install_dir}/my.cnf
echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf
ldconfig
service mysqld stop
}
+221
View File
@@ -0,0 +1,221 @@
#!/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_Percona80() {
pushd ${oneinstack_dir}/src > /dev/null
id -u mysql >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /sbin/nologin mysql
[ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir}
if [ "${dbinstallmethod}" == "1" ]; then
tar xzf ./Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.28.tar.gz
mv Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.28/* ${percona_install_dir}
#sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
sed -i "s@/usr/local/Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.28@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe
elif [ "${dbinstallmethod}" == "2" ]; then
boostVersion2=$(echo ${boost_percona_ver} | awk -F. '{print $1"_"$2"_"$3}')
tar xzf boost_${boostVersion2}.tar.gz
tar xzf percona-server-${percona80_ver}.tar.gz
pushd percona-server-${percona80_ver}
cmake . -DCMAKE_INSTALL_PREFIX=${percona_install_dir} \
-DMYSQL_DATADIR=${percona_data_dir} \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=../boost_${boostVersion2} \
-DFORCE_INSOURCE_BUILD=1 \
-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 \
-DEXTRA_CHARSETS=all
make -j ${THREAD}
make install
sed -i 's@^load_jemalloc=1@load_jemalloc=0@' ${percona_install_dir}/bin/mysqld_safe
popd
fi
# backup openssl so
#[ ! -e "${percona_install_dir}/lib/lib_bk" ] && mkdir ${percona_install_dir}/lib/lib_bk
#/bin/mv ${percona_install_dir}/lib/{libssl,libcrypto}.so* ${percona_install_dir}/lib/lib_bk/
if [ -d "${percona_install_dir}/support-files" ]; then
sed -i "s+^dbrootpwd.*+dbrootpwd='${dbrootpwd}'+" ../options.conf
echo "${CSUCCESS}Percona installed successfully! ${CEND}"
if [ "${dbinstallmethod}" == "1" ]; then
rm -rf Percona-Server-${percona80_ver}-Linux.x86_64.glibc2.28
elif [ "${dbinstallmethod}" == "2" ]; then
rm -rf percona-server-${percona80_ver} boost_${boostVersion2}
fi
else
rm -rf ${percona_install_dir}
echo "${CFAILURE}Percona install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
/bin/cp ${percona_install_dir}/support-files/mysql.server /etc/init.d/mysqld
sed -i "s@^basedir=.*@basedir=${percona_install_dir}@" /etc/init.d/mysqld
sed -i "s@^datadir=.*@datadir=${percona_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="Percona [\\d]> "
no-auto-rehash
[mysqld]
port = 3306
socket = /tmp/mysql.sock
default_authentication_plugin = mysql_native_password
basedir = ${percona_install_dir}
datadir = ${percona_data_dir}
pid-file = ${percona_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 = ${percona_data_dir}/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = ${percona_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
${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
[ "${Wsl}" == true ] && chmod 600 /etc/my.cnf
chown mysql:mysql -R ${percona_data_dir}
[ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
service mysqld start
[ -z "$(grep ^'export PATH=' /etc/profile)" ] && echo "export PATH=${percona_install_dir}/bin:\$PATH" >> /etc/profile
[ -n "$(grep ^'export PATH=' /etc/profile)" -a -z "$(grep ${percona_install_dir} /etc/profile)" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${percona_install_dir}/bin:\1@" /etc/profile
. /etc/profile
${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "create user root@'127.0.0.1' identified by \"${dbrootpwd}\";"
${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;"
${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "grant all privileges on *.* to root@'localhost' with grant option;"
${percona_install_dir}/bin/mysql -uroot -hlocalhost -e "alter user root@'localhost' identified by \"${dbrootpwd}\";"
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"
rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
[ -e "${percona_install_dir}/my.cnf" ] && rm -f ${percona_install_dir}/my.cnf
echo "${percona_install_dir}/lib" > /etc/ld.so.conf.d/z-percona.conf
ldconfig
service mysqld stop
}
+253
View File
@@ -0,0 +1,253 @@
#!/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_PHP53() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php53_ver}.tar.gz
patch -d php-${php53_ver} -p0 < fpm-race-condition.patch
pushd php-${php53_ver} > /dev/null
patch -p1 < ../php5.3patch
patch -p1 < ../debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
make clean
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
{ [ ${RHEL_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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 --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
{ [ ${RHEL_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile
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 = 5@' ${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 [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php53_ver}
popd > /dev/null
}
+250
View File
@@ -0,0 +1,250 @@
#!/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_PHP54() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php54_ver}.tar.gz
patch -d php-${php54_ver} -p0 < fpm-race-condition.patch
pushd php-${php54_ver} > /dev/null
make clean
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
{ [ ${RHEL_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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 --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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 = 5@' ${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 [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php54_ver}
popd > /dev/null
}
+263
View File
@@ -0,0 +1,263 @@
#!/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_PHP55() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php55_ver}.tar.gz
patch -d php-${php55_ver} -p0 < fpm-race-condition.patch
pushd php-${php55_ver} > /dev/null
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
{ [ ${RHEL_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl'
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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 \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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 = 5@' ${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
[ "${phpcache_option}" == '1' ] && cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
[opcache]
zend_extension=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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php55_ver}
popd > /dev/null
}
+269
View File
@@ -0,0 +1,269 @@
#!/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_PHP56() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php5_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php56_ver}.tar.gz
pushd php-${php56_ver} > /dev/null
make clean
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
{ [ ${RHEL_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl'
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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 \
--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php5_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php5_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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 = 5@' ${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.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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php56_ver}
popd > /dev/null
}
+274
View File
@@ -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_PHP70() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php70_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php70_ver}.tar.gz
pushd php-${php70_ver}
make clean
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
{ [ ${Debian_ver} -ge 10 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 19 >/dev/null 2>&1 ]; } || intl_modules_options='--enable-intl'
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php70_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php70_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php70_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php70_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --with-xsl ${intl_modules_options} \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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.fast_shutdown=1
opcache.consistency_checks=0
;opcache.optimization_level=0
EOF
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php70_ver}
popd > /dev/null
}
+277
View File
@@ -0,0 +1,277 @@
#!/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_PHP71() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php71_with_ssl} ${with_nghttp2}
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/bin/libmcrypt-config" -a ! -e "/usr/bin/libmcrypt-config" ]; then
tar xzf libmcrypt-${libmcrypt_ver}.tar.gz
pushd libmcrypt-${libmcrypt_ver} > /dev/null
./configure
make -j ${THREAD} && make install
ldconfig
pushd libltdl > /dev/null
./configure --enable-ltdl-install
make -j ${THREAD} && make install
popd > /dev/null
popd > /dev/null
rm -rf libmcrypt-${libmcrypt_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 "/usr/bin/libmcrypt-config" ] && ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
[ ! -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
if [ ! -e "/usr/local/bin/mcrypt" -a ! -e "/usr/bin/mcrypt" ]; then
tar xzf mcrypt-${mcrypt_ver}.tar.gz
pushd mcrypt-${mcrypt_ver} > /dev/null
ldconfig
./configure
make -j ${THREAD} && make install
popd > /dev/null
rm -rf mcrypt-${mcrypt_ver}
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}
tar xzf php-${php71_ver}.tar.gz
pushd php-${php71_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
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php71_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php71_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php71_with_curl} --enable-mbregex \
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf ${php71_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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.fast_shutdown=1
opcache.consistency_checks=0
;opcache.optimization_level=0
EOF
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php71_ver}
popd > /dev/null
}
+270
View File
@@ -0,0 +1,270 @@
#!/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_PHP72() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php72_with_ssl} ${with_nghttp2}
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/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}
tar xzf php-${php72_ver}.tar.gz
pushd php-${php72_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
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php72_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php72_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
else
./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-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php72_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php72_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --enable-soap --disable-debug ${php_modules_options}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php72_ver}
popd > /dev/null
}
+270
View File
@@ -0,0 +1,270 @@
#!/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_PHP73() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php73_with_ssl} ${with_nghttp2}
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/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}
tar xzf php-${php73_ver}.tar.gz
pushd php-${php73_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
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${phpcache_arg} --disable-fileinfo \
--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local --with-freetype-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php73_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php73_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --without-libzip --enable-soap --disable-debug ${php_modules_options}
else
./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-dir=${freetype_install_dir} --with-jpeg-dir --with-png-dir --with-zlib \
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
--enable-sysvsem --enable-inline-optimization ${php73_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --with-gd ${php73_with_openssl} \
--with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
--with-gettext --enable-zip --without-libzip --enable-soap --disable-debug ${php_modules_options}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php73_ver}
popd > /dev/null
}
+280
View File
@@ -0,0 +1,280 @@
#!/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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php74_with_ssl} ${with_nghttp2}
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}
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
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${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}
else
./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}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php74_ver}
popd > /dev/null
}
+280
View File
@@ -0,0 +1,280 @@
#!/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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php80_with_ssl} ${with_nghttp2}
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}
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
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${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}
else
./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}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php80_ver}
popd > /dev/null
}
+276
View File
@@ -0,0 +1,276 @@
#!/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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php81_with_ssl} ${with_nghttp2}
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}
tar xzf php-${php81_ver}.tar.gz
pushd php-${php81_ver} > /dev/null
make clean
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${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}
else
./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}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php81_ver}
popd > /dev/null
}
+276
View File
@@ -0,0 +1,276 @@
#!/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_PHP82() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php82_with_ssl} ${with_nghttp2}
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_up_ver}.tar.gz
pushd libsodium-${libsodium_up_ver} > /dev/null
./configure --disable-dependency-tracking --enable-minimal
make -j ${THREAD} && make install
popd > /dev/null
rm -rf libsodium-${libsodium_up_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}
tar xzf php-${php82_ver}.tar.gz
pushd php-${php82_ver} > /dev/null
make clean
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${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 ${php82_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php82_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}
else
./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 ${php82_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php82_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}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php82_ver}
popd > /dev/null
}
+276
View File
@@ -0,0 +1,276 @@
#!/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_PHP83() {
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
[ -e "/usr/local/lib/libnghttp2.so" ] && with_nghttp2='--with-nghttp2=/usr/local'
./configure --prefix=${curl_install_dir} ${php83_with_ssl} ${with_nghttp2}
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_up_ver}.tar.gz
pushd libsodium-${libsodium_up_ver} > /dev/null
./configure --disable-dependency-tracking --enable-minimal
make -j ${THREAD} && make install
popd > /dev/null
rm -rf libsodium-${libsodium_up_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}
tar xzf php-${php83_ver}.tar.gz
pushd php-${php83_ver} > /dev/null
make clean
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH
[ ! -d "${php_install_dir}" ] && mkdir -p ${php_install_dir}
[ "${phpcache_option}" == '1' ] && phpcache_arg='--enable-opcache' || phpcache_arg='--disable-opcache'
if [ "${apache_mode_option}" == '2' ]; then
./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-apxs2=${apache_install_dir}/bin/apxs ${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 ${php83_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php83_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}
else
./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 ${php83_with_curl} --enable-mbregex \
--enable-mbstring --with-password-argon2 --with-sodium=/usr/local --enable-gd ${php83_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}
fi
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
if [ "${apache_mode_option}" != '2' ]; then
# php-fpm Init Script
/bin/cp ${oneinstack_dir}/init.d/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
elif [ "${apache_mode_option}" == '2' ]; then
systemctl restart httpd
fi
popd > /dev/null
[ -e "${php_install_dir}/bin/phpize" ] && rm -rf php-${php83_ver}
popd > /dev/null
}
+32
View File
@@ -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 32)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
chown -R ${run_user}:${run_group} ${wwwroot_dir}/default/phpMyAdmin
popd > /dev/null
fi
}
+51
View File
@@ -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}/init.d/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'+" ../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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+65
View File
@@ -0,0 +1,65 @@
#!/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 ../init.d/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
# Firewall Ftp
if [ "${PM}" == 'yum' ]; then
if [ "`firewall-cmd --state`" == "running" ]; then
firewall-cmd --permanent --zone=public --add-port={21/tcp,20000-30000/tcp}
firewall-cmd --reload
fi
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq active; then
ufw allow 21/tcp
ufw allow 20000:30000/tcp
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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
popd > /dev/null
}
+85
View File
@@ -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_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 ../init.d/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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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-4.3.0.tgz
pushd redis-4.3.0 > /dev/null
elif [[ "$(${php_install_dir}/bin/php-config --version | awk -F. '{print $1$2}')" =~ ^7[0-1]$ ]]; then
tar xzf redis-5.3.7.tgz
pushd redis-5.3.7 > /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-4.3.0 redis-5.3.7
else
echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+49
View File
@@ -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
}
+94
View File
@@ -0,0 +1,94 @@
#!/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_Tengine() {
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 tengine-${tengine_ver}.tar.gz
tar xzf openssl-${openssl11_ver}.tar.gz
pushd tengine-${tengine_ver} > /dev/null
# Modify Tengine version
#sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h
[ ! -d "${tengine_install_dir}" ] && mkdir -p ${tengine_install_dir}
./configure --prefix=${tengine_install_dir} --user=${run_user} --group=${run_group} --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-jemalloc ${nginx_modules_options}
make && make install
if [ -e "${tengine_install_dir}/conf/nginx.conf" ]; then
popd > /dev/null
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* tengine-${tengine_ver}* rm -rf ${tengine_install_dir}*
echo "${CSUCCESS}Tengine installed successfully! ${CEND}"
else
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* tengine-${tengine_ver}* rm -rf ${tengine_install_dir}*
echo "${CFAILURE}Tengine install failed, Please Contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=${tengine_install_dir}/sbin:\$PATH" >> /etc/profile
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep ${tengine_install_dir} /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=${tengine_install_dir}/sbin:\1@" /etc/profile
. /etc/profile
/bin/cp ../init.d/nginx.service /lib/systemd/system/
sed -i "s@/usr/local/nginx@${tengine_install_dir}@g" /lib/systemd/system/nginx.service
systemctl enable nginx
mv ${tengine_install_dir}/conf/nginx.conf{,_bk}
if [ "${apache_flag}" == 'y' ] || [ -e "${apache_install_dir}/bin/httpd" ]; then
/bin/cp ../config/nginx_apache.conf ${tengine_install_dir}/conf/nginx.conf
elif { [[ ${tomcat_option} =~ ^[1-4]$ ]] || [ -e "${tomcat_install_dir}/conf/server.xml" ]; } && { [[ ! ${php_option} =~ ^[1-9]$|^1[0-1]$ ]] && [ ! -e "${php_install_dir}/bin/php" ]; }; then
/bin/cp ../config/nginx_tomcat.conf ${tengine_install_dir}/conf/nginx.conf
else
/bin/cp ../config/nginx.conf ${tengine_install_dir}/conf/nginx.conf
[[ "${php_option}" =~ ^[1-9]$|^1[0-1]$ ]] && [ -z "`grep '/php-fpm_status' ${tengine_install_dir}/conf/nginx.conf`" ] && sed -i "s@index index.html index.php;@index index.html index.php;\n location ~ /php-fpm_status {\n #fastcgi_pass remote_php_ip:9000;\n fastcgi_pass unix:/dev/shm/php-cgi.sock;\n fastcgi_index index.php;\n include fastcgi.conf;\n allow 127.0.0.1;\n deny all;\n }@" ${tengine_install_dir}/conf/nginx.conf
fi
cat > ${tengine_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@" ${tengine_install_dir}/conf/nginx.conf
sed -i "s@/data/wwwlogs@${wwwlogs_dir}@g" ${tengine_install_dir}/conf/nginx.conf
sed -i "s@^user www www@user ${run_user} ${run_group}@" ${tengine_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
}
+129
View File
@@ -0,0 +1,129 @@
#!/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_Tomcat10() {
pushd ${oneinstack_dir}/src > /dev/null
. /etc/profile
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 /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; }
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
tar xzf apache-tomcat-${tomcat10_ver}.tar.gz
[ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir}
/bin/cp -R apache-tomcat-${tomcat10_ver}/* ${tomcat_install_dir}
rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*}
if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then
rm -rf ${tomcat_install_dir}
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
pushd ${tomcat_install_dir}/bin > /dev/null
tar xzf tomcat-native.tar.gz
pushd tomcat-native-*-src/native > /dev/null
if [ "${armplatform}" == "y" ]; then
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
else
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} --with-ssl=${openssl_install_dir}
fi
make -j ${THREAD} && make install
popd > /dev/null
rm -rf tomcat-native-*
if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then
[ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
let XmxMem="${Mem}/2"
cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib"
# -Djava.rmi.server.hostname=$IPADDR
# -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
# -Dcom.sun.management.jmxremote.ssl=false"
EOF
chmod +x ./*.sh
/bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
popd # goto ${oneinstack_dir}/src
/bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf
sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml
if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
if [ "${PM}" == 'yum' ]; then
if [ "`firewall-cmd --state`" == "running" ]; then
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
fi
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq active; then
ufw allow 8080/tcp
fi
fi
fi
[ ! -d "${tomcat_install_dir}/conf/vhost" ] && mkdir ${tomcat_install_dir}/conf/vhost
cat > ${tomcat_install_dir}/conf/vhost/localhost.xml << EOF
<Host name="localhost" appBase="${wwwroot_dir}/default" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
</Host>
EOF
# logrotate tomcat catalina.out
cat > /etc/logrotate.d/tomcat << EOF
${tomcat_install_dir}/logs/catalina.out {
daily
rotate 5
missingok
dateext
compress
notifempty
copytruncate
}
EOF
[ -z "$(grep '<user username="admin" password=' ${tomcat_install_dir}/conf/tomcat-users.xml)" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"$(cat /dev/urandom | head -1 | md5sum | head -c 10)\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" ${tomcat_install_dir}/conf/tomcat-users.xml
cat > ${tomcat_install_dir}/conf/jmxremote.access << EOF
monitorRole readonly
controlRole readwrite \
create javax.management.monitor.*,javax.management.timer.* \
unregister
EOF
cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8)
# controlRole R&D
EOF
chown -R ${run_user}:${run_group} ${tomcat_install_dir}
/bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat
sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat
sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat
sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat
[ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
[ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults
echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
rm -rf apache-tomcat-${tomcat10_ver}
else
popd > /dev/null
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
service tomcat start
popd > /dev/null
}
+131
View File
@@ -0,0 +1,131 @@
#!/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_Tomcat7() {
pushd ${oneinstack_dir}/src > /dev/null
. /etc/profile
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 /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; }
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
tar xzf apache-tomcat-${tomcat7_ver}.tar.gz
[ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir}
/bin/cp -R apache-tomcat-${tomcat7_ver}/* ${tomcat_install_dir}
rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*}
if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then
rm -rf ${tomcat_install_dir}
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
/bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib
pushd ${tomcat_install_dir}/bin > /dev/null
tar xzf tomcat-native.tar.gz
pushd tomcat-native-*-src/native > /dev/null
if [ "${armplatform}" == "y" ]; then
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
else
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} --with-ssl=${openssl_install_dir}
fi
make -j ${THREAD} && make install
popd > /dev/null
rm -rf tomcat-native-*
if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then
[ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
let XmxMem="${Mem}/2"
cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib"
# -Djava.rmi.server.hostname=$IPADDR
# -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
# -Dcom.sun.management.jmxremote.ssl=false"
EOF
chmod +x ./*.sh
/bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
popd # goto ${oneinstack_dir}/src
/bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf
sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml
if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
if [ "${PM}" == 'yum' ]; then
if [ "`firewall-cmd --state`" == "running" ]; then
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
fi
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq active; then
ufw allow 8080/tcp
fi
fi
fi
[ ! -d "${tomcat_install_dir}/conf/vhost" ] && mkdir ${tomcat_install_dir}/conf/vhost
cat > ${tomcat_install_dir}/conf/vhost/localhost.xml << EOF
<Host name="localhost" appBase="${wwwroot_dir}/default" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
</Host>
EOF
# logrotate tomcat catalina.out
cat > /etc/logrotate.d/tomcat << EOF
${tomcat_install_dir}/logs/catalina.out {
daily
rotate 5
missingok
dateext
compress
notifempty
copytruncate
}
EOF
[ -z "$(grep '<user username="admin" password=' ${tomcat_install_dir}/conf/tomcat-users.xml)" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"$(cat /dev/urandom | head -1 | md5sum | head -c 10)\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" ${tomcat_install_dir}/conf/tomcat-users.xml
cat > ${tomcat_install_dir}/conf/jmxremote.access << EOF
monitorRole readonly
controlRole readwrite \
create javax.management.monitor.*,javax.management.timer.* \
unregister
EOF
cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8)
# controlRole R&D
EOF
chown -R ${run_user}:${run_group} ${tomcat_install_dir}
/bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat
sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat
sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat
sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat
[ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
[ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults
echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
rm -rf apache-tomcat-${tomcat7_ver}
else
popd > /dev/null
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
service tomcat start
popd > /dev/null
}
+129
View File
@@ -0,0 +1,129 @@
#!/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_Tomcat8() {
pushd ${oneinstack_dir}/src > /dev/null
. /etc/profile
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 /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; }
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
tar xzf apache-tomcat-${tomcat8_ver}.tar.gz
[ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir}
/bin/cp -R apache-tomcat-${tomcat8_ver}/* ${tomcat_install_dir}
rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*}
if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then
rm -rf ${tomcat_install_dir}
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
pushd ${tomcat_install_dir}/bin > /dev/null
tar xzf tomcat-native.tar.gz
pushd tomcat-native-*-src/native > /dev/null
if [ "${armplatform}" == "y" ]; then
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
else
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} --with-ssl=${openssl_install_dir}
fi
make -j ${THREAD} && make install
popd > /dev/null
rm -rf tomcat-native-*
if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then
[ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
let XmxMem="${Mem}/2"
cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib"
# -Djava.rmi.server.hostname=$IPADDR
# -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
# -Dcom.sun.management.jmxremote.ssl=false"
EOF
chmod +x ./*.sh
/bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
popd # goto ${oneinstack_dir}/src
/bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf
sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml
if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
if [ "${PM}" == 'yum' ]; then
if [ "`firewall-cmd --state`" == "running" ]; then
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
fi
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq active; then
ufw allow 8080/tcp
fi
fi
fi
[ ! -d "${tomcat_install_dir}/conf/vhost" ] && mkdir ${tomcat_install_dir}/conf/vhost
cat > ${tomcat_install_dir}/conf/vhost/localhost.xml << EOF
<Host name="localhost" appBase="${wwwroot_dir}/default" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
</Host>
EOF
# logrotate tomcat catalina.out
cat > /etc/logrotate.d/tomcat << EOF
${tomcat_install_dir}/logs/catalina.out {
daily
rotate 5
missingok
dateext
compress
notifempty
copytruncate
}
EOF
[ -z "$(grep '<user username="admin" password=' ${tomcat_install_dir}/conf/tomcat-users.xml)" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"$(cat /dev/urandom | head -1 | md5sum | head -c 10)\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" ${tomcat_install_dir}/conf/tomcat-users.xml
cat > ${tomcat_install_dir}/conf/jmxremote.access << EOF
monitorRole readonly
controlRole readwrite \
create javax.management.monitor.*,javax.management.timer.* \
unregister
EOF
cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8)
# controlRole R&D
EOF
chown -R ${run_user}:${run_group} ${tomcat_install_dir}
/bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat
sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat
sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat
sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat
[ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
[ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults
echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
rm -rf apache-tomcat-${tomcat8_ver}
else
popd > /dev/null
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
service tomcat start
popd > /dev/null
}
+129
View File
@@ -0,0 +1,129 @@
#!/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_Tomcat9() {
pushd ${oneinstack_dir}/src > /dev/null
. /etc/profile
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 /bin/bash ${run_user} || { [ -z "$(grep ^${run_user} /etc/passwd | grep '/bin/bash')" ] && usermod -g ${run_group} -s /bin/bash ${run_user}; }
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
tar xzf apache-tomcat-${tomcat9_ver}.tar.gz
[ ! -d "${tomcat_install_dir}" ] && mkdir -p ${tomcat_install_dir}
/bin/cp -R apache-tomcat-${tomcat9_ver}/* ${tomcat_install_dir}
rm -rf ${tomcat_install_dir}/webapps/{docs,examples,host-manager,manager,ROOT/*}
if [ ! -e "${tomcat_install_dir}/conf/server.xml" ]; then
rm -rf ${tomcat_install_dir}
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
kill -9 $$; exit 1;
fi
pushd ${tomcat_install_dir}/bin > /dev/null
tar xzf tomcat-native.tar.gz
pushd tomcat-native-*-src/native > /dev/null
if [ "${armplatform}" == "y" ]; then
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
else
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir} --with-ssl=${openssl_install_dir}
fi
make -j ${THREAD} && make install
popd > /dev/null
rm -rf tomcat-native-*
if [ -e "${apr_install_dir}/lib/libtcnative-1.la" ]; then
[ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
let XmxMem="${Mem}/2"
cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
CATALINA_OPTS="-Djava.library.path=${apr_install_dir}/lib"
# -Djava.rmi.server.hostname=$IPADDR
# -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
# -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
# -Dcom.sun.management.jmxremote.ssl=false"
EOF
chmod +x ./*.sh
/bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
popd # goto ${oneinstack_dir}/src
/bin/cp ${oneinstack_dir}/config/server.xml ${tomcat_install_dir}/conf
sed -i "s@/usr/local/tomcat@${tomcat_install_dir}@g" ${tomcat_install_dir}/conf/server.xml
if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
if [ "${PM}" == 'yum' ]; then
if [ "`firewall-cmd --state`" == "running" ]; then
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
fi
elif [ "${PM}" == 'apt-get' ]; then
if ufw status | grep -wq active; then
ufw allow 8080/tcp
fi
fi
fi
[ ! -d "${tomcat_install_dir}/conf/vhost" ] && mkdir ${tomcat_install_dir}/conf/vhost
cat > ${tomcat_install_dir}/conf/vhost/localhost.xml << EOF
<Host name="localhost" appBase="${wwwroot_dir}/default" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="${wwwroot_dir}/default" reloadable="false" crossContext="true"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
<Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>
</Host>
EOF
# logrotate tomcat catalina.out
cat > /etc/logrotate.d/tomcat << EOF
${tomcat_install_dir}/logs/catalina.out {
daily
rotate 5
missingok
dateext
compress
notifempty
copytruncate
}
EOF
[ -z "$(grep '<user username="admin" password=' ${tomcat_install_dir}/conf/tomcat-users.xml)" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"$(cat /dev/urandom | head -1 | md5sum | head -c 10)\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" ${tomcat_install_dir}/conf/tomcat-users.xml
cat > ${tomcat_install_dir}/conf/jmxremote.access << EOF
monitorRole readonly
controlRole readwrite \
create javax.management.monitor.*,javax.management.timer.* \
unregister
EOF
cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
monitorRole $(cat /dev/urandom | head -1 | md5sum | head -c 8)
# controlRole R&D
EOF
chown -R ${run_user}:${run_group} ${tomcat_install_dir}
/bin/cp ${oneinstack_dir}/init.d/Tomcat-init /etc/init.d/tomcat
sed -i "s@JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" /etc/init.d/tomcat
sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=${tomcat_install_dir}@" /etc/init.d/tomcat
sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=${run_user}@" /etc/init.d/tomcat
[ "${PM}" == 'yum' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
[ "${PM}" == 'apt-get' ] && update-rc.d tomcat defaults
echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
rm -rf apache-tomcat-${tomcat9_ver}
else
popd > /dev/null
echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
fi
service tomcat start
popd > /dev/null
}
+179
View File
@@ -0,0 +1,179 @@
#!/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/Percona is not installed on your system! ${CEND}" && exit 1
[ "${armplatform}" == 'y' ] && echo "${CWARNING}The arm architecture operating system does not support upgrading MySQL/MariaDB/Percona! ${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'+" ../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
[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://archive.mariadb.org
DB=MariaDB
OLD_db_ver=`echo ${OLD_db_ver_tmp} | awk -F'-' '{print $1}'`
elif [ -n "`${db_install_dir}/bin/mysql -V | grep -o Percona`" ]; then
DB=Percona
OLD_db_ver=${OLD_db_ver_tmp}
else
#[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=http://mirrors.ustc.edu.cn/mysql-ftp/Downloads || DOWN_ADDR=http://cdn.mysql.com/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}" == 'Percona' ]; then
if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then
perconaVerStr1=$(echo ${NEW_db_ver} | sed "s@-@-rel@")
else
perconaVerStr1=${NEW_db_ver}
fi
if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^8.0$ ]]; then
DB_filename=Percona-Server-${perconaVerStr1}-Linux.x86_64.glibc2.28
elif [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.7$ ]]; then
DB_filename=Percona-Server-${perconaVerStr1}-Linux.x86_64.glibc2.17
else
DB_filename=Percona-Server-${perconaVerStr1}-Linux.x86_64.${sslLibVer}
fi
DB_URL=https://www.percona.com/downloads/Percona-Server-`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`/Percona-Server-${NEW_db_ver}/binary/tarball/${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}" == 'Percona' ]; then
tar xzf ${DB_filename}.tar.gz
service mysqld stop
mv ${percona_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
mv ${percona_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
[ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
mkdir -p ${percona_data_dir};chown mysql:mysql -R ${percona_data_dir}
mv ${DB_filename}/* ${percona_install_dir}/
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
sed -i "s@/usr/local/${DB_filename}@${percona_install_dir}@g" ${percona_install_dir}/bin/mysqld_safe
if [[ "`echo ${NEW_db_ver} | awk -F. '{print $1"."$2}'`" =~ ^5.[5-6]$ ]]; then
${percona_install_dir}/scripts/mysql_install_db --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
else
${percona_install_dir}/bin/mysqld --initialize-insecure --user=mysql --basedir=${percona_install_dir} --datadir=${percona_data_dir}
fi
chown mysql:mysql -R ${percona_data_dir}
service mysqld start
${percona_install_dir}/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
service mysqld restart
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
${percona_install_dir}/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
${percona_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
}
+61
View File
@@ -0,0 +1,61 @@
#!/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_Memcached() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${memcached_install_dir}/bin/memcached" ] && echo "${CWARNING}Memcached is not installed on your system! ${CEND}" && exit 1
OLD_memcached_ver=`${memcached_install_dir}/bin/memcached -V | awk '{print $2}'`
Latest_memcached_ver=`curl --connect-timeout 2 -m 3 -s https://github.com/memcached/memcached/wiki/ReleaseNotes | grep 'internal present.*ReleaseNotes' | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1`
Latest_memcached_ver=${Latest_memcached_ver:-1.5.12}
echo "Current Memcached Version: ${CMSG}${OLD_memcached_ver}${CEND}"
while :; do echo
[ "${memcached_flag}" != 'y' ] && read -e -p "Please input upgrade Memcached Version(default: ${Latest_memcached_ver}): " NEW_memcached_ver
NEW_memcached_ver=${NEW_memcached_ver:-${Latest_memcached_ver}}
if [ "${NEW_memcached_ver}" != "${OLD_memcached_ver}" ]; then
[ "${OUTIP_STATE}"x == "China"x ] && DOWN_ADDR=${mirror_link}/oneinstack/src || DOWN_ADDR=http://www.memcached.org/files
[ ! -e "memcached-${NEW_memcached_ver}.tar.gz" ] && wget --no-check-certificate -c ${DOWN_ADDR}/memcached-${NEW_memcached_ver}.tar.gz > /dev/null 2>&1
if [ -e "memcached-${NEW_memcached_ver}.tar.gz" ]; then
echo "Download [${CMSG}memcached-${NEW_memcached_ver}.tar.gz${CEND}] successfully! "
break
else
echo "${CWARNING}Memcached version does not exist! ${CEND}"
fi
else
echo "${CWARNING}input error! Upgrade Memcached version is the same as the old version${CEND}"
exit
fi
done
if [ -e "memcached-${NEW_memcached_ver}.tar.gz" ]; then
echo "[${CMSG}memcached-${NEW_memcached_ver}.tar.gz${CEND}] found"
if [ "${memcached_flag}" != 'y' ]; then
echo "Press Ctrl+c to cancel or Press any key to continue..."
char=`get_char`
fi
tar xzf memcached-${NEW_memcached_ver}.tar.gz
pushd memcached-${NEW_memcached_ver}
make clean
./configure --prefix=${memcached_install_dir}
make -j ${THREAD}
if [ -e "memcached" ]; then
echo "Restarting Memcached..."
service memcached stop
make install
service memcached start
popd > /dev/null
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_memcached_ver}${CEND} to ${CWARNING}${NEW_memcached_ver}${CEND}"
rm -rf memcached-${NEW_memcached_ver}
else
echo "${CFAILURE}Upgrade Memcached failed! ${CEND}"
fi
fi
popd > /dev/null
}
+67
View File
@@ -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
Upgrade_OneinStack() {
pushd ${oneinstack_dir} > /dev/null
Latest_OneinStack_MD5=$(curl --connect-timeout 3 -m 5 -s ${mirror_link}/md5sum.txt | grep oneinstack.tar.gz | awk '{print $1}')
[ ! -e README.md ] && ois_flag=n
if [ "${oneinstack_md5}" != "${Latest_OneinStack_MD5}" ]; then
/bin/mv options.conf /tmp
sed -i '/oneinstack_dir=/d' /tmp/options.conf
[ -e /tmp/oneinstack.tar.gz ] && rm -rf /tmp/oneinstack.tar.gz
wget --no-check-certificate -qc ${mirror_link}/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/options.conf`
do
IFS=$IFS_old
Key="`echo ${L%%=*}`"
Value="`echo ${L#*=}`"
sed -i "s|^${Key}=.*|${Key}=${Value}|" ./options.conf
done
rm -rf /tmp/{oneinstack.tar.gz,options.conf}
[ "${ois_flag}" == "n" ] && rm -f ss.sh LICENSE README.md
sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
if [ -e "change_jdk_version.sh" ]; then
rm -f change_jdk_version.sh
wget -qc ${mirror_link}/scripts/change_jdk_version.sh
chmod +x change_jdk_version.sh
fi
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
[ -e "/usr/local/php82/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php82/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
[ ! -e "${oneinstack_dir}/options.conf" ] && [ -e "/tmp/options.conf" ] && /bin/cp /tmp/options.conf ${oneinstack_dir}/options.conf
popd > /dev/null
}
+74
View File
@@ -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
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`
pythonCtl=python
command -v python3 > /dev/null 2>&1 && pythonCtl=python3
Latest_php_ver=`curl --connect-timeout 2 -m 3 -s https://www.php.net/releases/active.php | ${pythonCtl} -mjson.tool | awk '/version/{print $2}' | sed 's/"//g' | grep "${OLD_php_ver%.*}"`
Latest_php_ver=${Latest_php_ver:-5.5.38}
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
src_url=${mirror_link}/oneinstack/src/fpm-race-condition.patch && Download_src
patch -d php-${NEW_php_ver} -p0 < fpm-race-condition.patch
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}
if [ -e "${apache_install_dir}/bin/httpd" ]; then
echo "Stoping apache..."
service httpd stop
make install
echo "Starting apache..."
service httpd start
else
echo "Stoping php-fpm..."
service php-fpm stop
make install
echo "Starting php-fpm..."
service php-fpm start
fi
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
}
+54
View File
@@ -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
}
+59
View File
@@ -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
}
+360
View File
@@ -0,0 +1,360 @@
#!/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=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/ngx_devel_kit.tar.gz && Download_src
src_url=${mirror_link}/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=${mirror_link}/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=${mirror_link}/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=${mirror_link}/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
}
Upgrade_Tengine() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${tengine_install_dir}/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1
OLD_tengine_ver_tmp=`${tengine_install_dir}/sbin/nginx -v 2>&1`
OLD_tengine_ver="`echo ${OLD_tengine_ver_tmp#*/} | awk '{print $1}'`"
Latest_tengine_ver=`curl --connect-timeout 2 -m 3 -s http://tengine.taobao.org/changelog.html | grep -v generator | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1`
echo
echo "Current Tengine Version: ${CMSG}${OLD_tengine_ver}${CEND}"
while :; do echo
[ "${tengine_flag}" != 'y' ] && read -e -p "Please input upgrade Tengine Version(default: ${Latest_tengine_ver}): " NEW_tengine_ver
NEW_tengine_ver=${NEW_tengine_ver:-${Latest_tengine_ver}}
if [ "${NEW_tengine_ver}" != "${OLD_tengine_ver}" ]; then
[ ! -e "tengine-${NEW_tengine_ver}.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-${NEW_tengine_ver}.tar.gz > /dev/null 2>&1
if [ -e "tengine-${NEW_tengine_ver}.tar.gz" ]; then
src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
tar xzf openssl-${openssl11_ver}.tar.gz
tar xzf pcre-${pcre_ver}.tar.gz
echo "Download [${CMSG}tengine-${NEW_tengine_ver}.tar.gz${CEND}] successfully! "
break
else
echo "${CWARNING}Tengine version does not exist! ${CEND}"
fi
else
echo "${CWARNING}input error! Upgrade Tengine version is the same as the old version${CEND}"
exit
fi
done
if [ -e "tengine-${NEW_tengine_ver}.tar.gz" ]; then
echo "[${CMSG}tengine-${NEW_tengine_ver}.tar.gz${CEND}] found"
if [ "${tengine_flag}" != 'y' ]; then
echo "Press Ctrl+c to cancel or Press any key to continue..."
char=`get_char`
fi
tar xzf tengine-${NEW_tengine_ver}.tar.gz
pushd tengine-${NEW_tengine_ver}
make clean
${tengine_install_dir}/sbin/nginx -V &> $$
tengine_configure_args_tmp=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
rm -rf $$
tengine_configure_args=`echo ${tengine_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} @"`
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.1
./configure ${tengine_configure_args}
make
if [ -f "objs/nginx" ]; then
/bin/mv ${tengine_install_dir}/sbin/nginx{,`date +%m%d`}
/bin/mv ${tengine_install_dir}/modules{,`date +%m%d`}
/bin/cp objs/nginx ${tengine_install_dir}/sbin/nginx
chmod +x ${tengine_install_dir}/sbin/*
make install
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_tengine_ver${CEND} to ${CWARNING}${NEW_tengine_ver}${CEND}"
rm -rf tengine-${NEW_tengine_ver}
else
echo "${CFAILURE}Upgrade Tengine failed! ${CEND}"
fi
fi
popd > /dev/null
}
Upgrade_OpenResty() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${openresty_install_dir}/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1
OLD_openresy_ver_tmp=`${openresty_install_dir}/nginx/sbin/nginx -v 2>&1`
OLD_openresy_ver="`echo ${OLD_openresy_ver_tmp#*/} | awk '{print $1}'`"
Latest_openresy_ver=`curl --connect-timeout 2 -m 3 -s https://openresty.org/en/download.html | awk '/download\/openresty-/{print $0}' | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -1`
echo
echo "Current OpenResty Version: ${CMSG}${OLD_openresy_ver}${CEND}"
while :; do echo
[ "${openresty_flag}" != 'y' ] && read -e -p "Please input upgrade OpenResty Version(default: ${Latest_openresy_ver}): " NEW_openresy_ver
NEW_openresy_ver=${NEW_openresy_ver:-${Latest_openresy_ver}}
if [ "${NEW_openresy_ver}" != "${OLD_openresy_ver}" ]; then
[ ! -e "openresty-${NEW_openresy_ver}.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-${NEW_openresy_ver}.tar.gz > /dev/null 2>&1
if [ -e "openresty-${NEW_openresy_ver}.tar.gz" ]; then
src_url=https://www.openssl.org/source/openssl-${openssl11_ver}.tar.gz && Download_src
src_url=${mirror_link}/oneinstack/src/pcre-${pcre_ver}.tar.gz && Download_src
tar xzf openssl-${openssl11_ver}.tar.gz
tar xzf pcre-${pcre_ver}.tar.gz
echo "Download [${CMSG}openresty-${NEW_openresy_ver}.tar.gz${CEND}] successfully! "
break
else
echo "${CWARNING}OpenResty version does not exist! ${CEND}"
fi
else
echo "${CWARNING}input error! Upgrade OpenResty version is the same as the old version${CEND}"
exit
fi
done
if [ -e "openresty-${NEW_openresy_ver}.tar.gz" ]; then
echo "[${CMSG}openresty-${NEW_openresy_ver}.tar.gz${CEND}] found"
if [ "${openresty_flag}" != 'y' ]; then
echo "Press Ctrl+c to cancel or Press any key to continue..."
char=`get_char`
fi
tar xzf openresty-${NEW_openresy_ver}.tar.gz
pushd openresty-${NEW_openresy_ver}
make clean
sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-${NEW_openresy_ver%.*}/auto/cc/gcc # close debug
${openresty_install_dir}/nginx/sbin/nginx -V &> $$
./configure --prefix=${openresty_install_dir} --user=${run_user} --group=${run_user} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_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 -Wl,-u,pcre_version' ${nginx_modules_options}
make -j ${THREAD}
if [ -f "build/nginx-${NEW_openresy_ver%.*}/objs/nginx" ]; then
/bin/mv ${openresty_install_dir}/nginx/sbin/nginx{,`date +%m%d`}
make install
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_openresy_ver}${CEND} to ${CWARNING}${NEW_openresy_ver}${CEND}"
rm -rf openresty-${NEW_openresy_ver}
else
echo "${CFAILURE}Upgrade OpenResty failed! ${CEND}"
fi
fi
popd > /dev/null
}
Upgrade_Apache() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${apache_install_dir}/bin/httpd" ] && echo "${CWARNING}Apache is not installed on your system! ${CEND}" && exit 1
OLD_apache_ver="`${apache_install_dir}/bin/httpd -v | grep version | awk -F'/| ' '{print $4}'`"
Latest_apache_ver=`curl --connect-timeout 2 -m 3 -s http://httpd.apache.org/download.cgi | awk "/#apache24/{print $2}" | head -1 | grep -oE "2\.[24]\.[0-9]+"`
Latest_apache_ver=${Latest_apache_ver:-${apache22_ver}}
echo
echo "Current Apache Version: ${CMSG}${OLD_apache_ver}${CEND}"
while :; do echo
[ "${apache_flag}" != 'y' ] && read -e -p "Please input upgrade Apache Version(Default: ${Latest_apache_ver}): " NEW_apache_ver
NEW_apache_ver=${NEW_apache_ver:-${Latest_apache_ver}}
if [ `echo ${NEW_apache_ver} | awk -F. '{print $1$2}'` == "24" ]; then
if [ "${NEW_apache_ver}" != "${OLD_apache_ver}" ]; then
src_url=http://archive.apache.org/dist/apr/apr-${apr_ver}.tar.gz && Download_src
src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_ver}.tar.gz && Download_src
[ ! -e "httpd-${NEW_apache_ver}.tar.gz" ] && wget --no-check-certificate -c http://archive.apache.org/dist/httpd/httpd-${NEW_apache_ver}.tar.gz > /dev/null 2>&1
if [ -e "httpd-${NEW_apache_ver}.tar.gz" ]; then
echo "Download [${CMSG}apache-${NEW_apache_ver}.tar.gz${CEND}] successfully! "
break
else
echo "${CWARNING}Apache version does not exist! ${CEND}"
fi
else
echo "${CWARNING}input error! Upgrade Apache version is the same as the old version${CEND}"
exit
fi
else
echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_apache_ver%.*}.xx${CEND}'"
[ "${apache_flag}" == 'y' ] && exit
fi
done
if [ -e "httpd-${NEW_apache_ver}.tar.gz" ]; then
echo "[${CMSG}httpd-${NEW_apache_ver}.tar.gz${CEND}] found"
if [ "${apache_flag}" != 'y' ]; then
echo "Press Ctrl+c to cancel or Press any key to continue..."
char=`get_char`
fi
# install apr
if [ ! -e "${apr_install_dir}/bin/apr-1-config" ]; then
tar xzf apr-${apr_ver}.tar.gz
pushd apr-${apr_ver} > /dev/null
./configure --prefix=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-${apr_ver}
fi
# install apr-util
if [ ! -e "${apr_install_dir}/bin/apu-1-config" ]; then
tar xzf apr-util-${apr_util_ver}.tar.gz
pushd apr-util-${apr_util_ver} > /dev/null
./configure --prefix=${apr_install_dir} --with-apr=${apr_install_dir}
make -j ${THREAD} && make install
popd > /dev/null
rm -rf apr-util-${apr_util_ver}
fi
tar xzf httpd-${NEW_apache_ver}.tar.gz
pushd httpd-${NEW_apache_ver}
make clean
LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --enable-mpms-shared=all --with-pcre --with-apr=${apr_install_dir} --with-apr-util=${apr_install_dir} --enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-remoteip --enable-expires --enable-static-support --enable-suexec --enable-mods-shared=most --enable-nonportable-atomics=yes --enable-ssl --with-ssl=${openssl_install_dir} --enable-http2 --with-nghttp2=/usr/local
make -j ${THREAD}
if [ -e 'httpd' ]; then
[[ -d ${apache_install_dir}_bak && -d ${apache_install_dir} ]] && rm -rf ${apache_install_dir}_bak
service httpd stop
/bin/cp -R ${apache_install_dir}{,_bak}
make install && unset LDFLAGS
service httpd start
popd > /dev/null
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_apache_ver}${CEND} to ${CWARNING}${NEW_apache_ver}${CEND}"
rm -rf httpd-${NEW_apache_ver}
else
echo "${CFAILURE}Upgrade Apache failed! ${CEND}"
fi
fi
popd > /dev/null
}
Upgrade_Tomcat() {
pushd ${oneinstack_dir}/src > /dev/null
[ ! -e "${tomcat_install_dir}/conf/server.xml" ] && echo "${CWARNING}Tomcat is not installed on your system! ${CEND}" && exit 1
OLD_tomcat_ver="`${tomcat_install_dir}/bin/version.sh | awk '/Server number/{print $3}' | awk -F. '{print $1"."$2"."$3}'`"
Tomcat_flag="`echo ${OLD_tomcat_ver} | awk -F. '{print $1}'`"
Latest_tomcat_ver=`curl --connect-timeout 2 -m 3 -s https://tomcat.apache.org/download-${Tomcat_flag}0.cgi | grep "README" | head -1 | grep -oE "[6-9]\.[0-9]\.[0-9]+"`
Latest_tomcat_ver=${Latest_tomcat_ver:-${tomcat10_ver}}
echo
echo "Current Tomcat Version: ${CMSG}${OLD_tomcat_ver}${CEND}"
while :; do echo
[ "${tomcat_flag}" != 'y' ] && read -e -p "Please input upgrade Tomcat Version(Default: ${Latest_tomcat_ver}): " NEW_tomcat_ver
NEW_tomcat_ver=${NEW_tomcat_ver:-${Latest_tomcat_ver}}
if [ "`echo ${NEW_tomcat_ver} | awk -F. '{print $1}'`" == "${Tomcat_flag}" ]; then
rm -f catalina-jmx-remote.jar
echo "Download tomcat-${NEW_tomcat_ver}..."
src_url=${mirror_link}/apache/tomcat/v${NEW_tomcat_ver}/apache-tomcat-${NEW_tomcat_ver}.tar.gz && Download_src
[ ! -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ] && wget --no-check-certificate -c https://archive.apache.org/dist/tomcat-${OLD_tomcat_ver}/v${NEW_tomcat_ver}/bin/apache-tomcat-${NEW_tomcat_ver}.tar.gz > /dev/null 2>&1
if [ -e "${tomcat_install_dir}/lib/catalina-jmx-remote.jar" ]; then
src_url=${mirror_link}/apache/tomcat/v${NEW_tomcat_ver}/catalina-jmx-remote.jar && Download_src
[ ! -e "catalina-jmx-remote.jar" ] && wget --no-check-certificate -c https://archive.apache.org/dist/tomcat-${OLD_tomcat_ver}/v${NEW_tomcat_ver}/bin/extras/catalina-jmx-remote.jar > /dev/null 2>&1
fi
if [ -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ]; then
echo "Download [${CMSG}apache-tomcat-${NEW_tomcat_ver}.tar.gz${CEND}] successfully! "
break
else
echo "${CWARNING}Tomcat version does not exist! ${CEND}"
fi
else
echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${Tomcat_flag}.xx${CEND}'"
fi
done
if [ -e "apache-tomcat-${NEW_tomcat_ver}.tar.gz" ]; then
echo "[${CMSG}apache-tomcat-${NEW_tomcat_ver}.tar.gz${CEND}] found"
if [ "${tomcat_flag}" != 'y' ]; then
echo "Press Ctrl+c to cancel or Press any key to continue..."
char=`get_char`
fi
tar xzf apache-tomcat-${NEW_tomcat_ver}.tar.gz
/bin/mv apache-tomcat-${NEW_tomcat_ver}/conf/server.xml{,_bk}
/bin/cp ${tomcat_install_dir}/conf/{server.xml,jmxremote.access,jmxremote.password,tomcat-users.xml} apache-tomcat-${NEW_tomcat_ver}/conf/
[ -e "${tomcat_install_dir}/lib/catalina-jmx-remote.jar" ] && /bin/cp catalina-jmx-remote.jar apache-tomcat-${NEW_tomcat_ver}/lib
/bin/cp ${tomcat_install_dir}/bin/setenv.sh apache-tomcat-${NEW_tomcat_ver}/bin/
/bin/cp -R ${tomcat_install_dir}/conf/vhost apache-tomcat-${NEW_tomcat_ver}/conf/
chmod +x apache-tomcat-${NEW_tomcat_ver}/bin/*.sh
[[ -d ${tomcat_install_dir}_bak && -d ${tomcat_install_dir} ]] && rm -rf ${tomcat_install_dir}._bak
service tomcat stop
/bin/mv ${tomcat_install_dir}{,_bak}
/bin/mv apache-tomcat-${NEW_tomcat_ver} ${tomcat_install_dir} && chown -R ${run_user}:${run_group} ${tomcat_install_dir}
if [ -e "${tomcat_install_dir}/conf/server.xml" ]; then
service tomcat start
echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}${OLD_tomcat_ver}${CEND} to ${CWARNING}${NEW_tomcat_ver}${CEND}"
else
echo "${CFAILURE}Upgrade Tomcat failed! ${CEND}"
fi
fi
popd > /dev/null
}
+86
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}
+85
View File
@@ -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}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
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
}