Merge branch 'master' into 1.5.0

merge multi-php feature
This commit is contained in:
Cristhian Martínez Ochoa 2018-05-07 22:48:54 -06:00
commit 830c574c2d
5 changed files with 107 additions and 71 deletions

View file

@ -149,16 +149,30 @@ nginx_install() {
php_install() {
api_update ip1
if [[ -n $(conf_read php-ver) && ($(conf_read php-ver) == "7.2" || $(conf_read php-ver) == "7.1" || $(conf_read php-ver) == "7.0" || $(conf_read php-ver) == "5.6") ]]; then
echo "${gre} Custom PHP version '$(conf_read php-ver)' detected!${end}"
echo "${gre}Default PHP version '$(conf_read php-ver)' detected!${end}"
else
# Default PHP version
conf_write php-ver 7.2
fi
ver=$(conf_read php-ver)
# Fix ondrej issue - https://github.com/oerdnj/deb.sury.org/issues/56
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
# Multi-PHP
if [[ $(conf_read multi-php) == "true" && -n $1 && $1 =~ ^(5.6|7.0|7.1|7.2)$ && $(conf_read php) == "true" && $1 != $ver ]]; then
ver="$1"
echo "${gre}Multi-PHP version is enabled. PHP '$ver' will be installed!${end}"
elif [[ $(conf_read multi-php) != "true" && -n $1 ]]; then
echo "${red}Multi-PHP is not enabled! ${end}"
exit 1
elif [[ $(conf_read multi-php) == "true" && -n $1 ]]; then
echo "${red}Please, enter a valid PHP version or default PHP is not installed yet! ${end}"
exit 1
fi
if [[ $(conf_read php) != "true" ]]; then
# Fix ondrej issue - https://github.com/oerdnj/deb.sury.org/issues/56
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
fi
pre_install
sudo apt-get -y install php${ver}-common php${ver}-cli php${ver}-fpm php${ver}-curl php${ver}-gd php${ver}-imap php${ver}-readline php${ver}-recode php${ver}-mysql php${ver}-mbstring php${ver}-bcmath php${ver}-mysql php${ver}-opcache php${ver}-zip php${ver}-xml php${ver}-soap php-imagick graphviz php-pear php-msgpack
@ -171,10 +185,14 @@ php_install() {
sudo apt-get -y install php-xdebug
fi
sudo cp /etc/php/$(conf_read php-ver)/fpm/php.ini /opt/webinoly/templates/source/
sudo cp /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf /opt/webinoly/templates/source/
def=$(conf_read php-ver)
if [[ $(conf_read php-v${def}) != "true" ]]; then
sudo cp /etc/php/$ver/fpm/php.ini /opt/webinoly/templates/source/
sudo cp /etc/php/$ver/fpm/pool.d/www.conf /opt/webinoly/templates/source/
fi
conf_write php true
conf_write php-v$ver true
echo "${gre}PHP has been installed successfully! ${end}"
api_update ip2
}
@ -255,52 +273,60 @@ nginx_optim() {
# PHP OPTIM
php_optim() {
api_update ip3
[[ -n $1 ]] && ver="$1" || ver=$(conf_read php-ver)
if [[ -n $(conf_read max-mb-uploads) && $(conf_read max-mb-uploads) =~ ^[0-9]+$ ]]; then
local maxuploads=$(conf_read max-mb-uploads)
else
local maxuploads="100"
fi
sudo sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/memory_limit =/c\memory_limit = 128M' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/max_execution_time =/c\max_execution_time = 300' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/expose_php =/c\expose_php = Off' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i "/upload_max_filesize =/c\upload_max_filesize = ${maxuploads}M" /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i "/post_max_size =/c\post_max_size = ${maxuploads}M" /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/max_file_uploads =/c\max_file_uploads = 20' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/date.timezone =/c\date.timezone = America/Mexico_City' /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=0' /etc/php/$ver/fpm/php.ini
sudo sed -i '/memory_limit =/c\memory_limit = 128M' /etc/php/$ver/fpm/php.ini
sudo sed -i '/max_execution_time =/c\max_execution_time = 300' /etc/php/$ver/fpm/php.ini
sudo sed -i '/expose_php =/c\expose_php = Off' /etc/php/$ver/fpm/php.ini
sudo sed -i "/upload_max_filesize =/c\upload_max_filesize = ${maxuploads}M" /etc/php/$ver/fpm/php.ini
sudo sed -i "/post_max_size =/c\post_max_size = ${maxuploads}M" /etc/php/$ver/fpm/php.ini
sudo sed -i '/max_file_uploads =/c\max_file_uploads = 20' /etc/php/$ver/fpm/php.ini
sudo sed -i '/date.timezone =/c\date.timezone = America/Mexico_City' /etc/php/$ver/fpm/php.ini
sudo mkdir -p /var/log/php/$(conf_read php-ver)
sudo touch /var/log/php/$(conf_read php-ver)/fpm.log
sudo sed -i "/error_log =/c\error_log = /var/log/php/$(conf_read php-ver)/fpm.log" /etc/php/$(conf_read php-ver)/fpm/php-fpm.conf
sudo sed -i '/log_level =/c\log_level = notice' /etc/php/$(conf_read php-ver)/fpm/php-fpm.conf
sudo mkdir -p /var/log/php/$ver
sudo touch /var/log/php/$ver/fpm.log
sudo sed -i "/error_log =/c\error_log = /var/log/php/$ver/fpm.log" /etc/php/$ver/fpm/php-fpm.conf
sudo sed -i '/log_level =/c\log_level = notice' /etc/php/$ver/fpm/php-fpm.conf
sudo sed -i '/pm =/c\pm = ondemand' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/request_terminate_timeout =/c\request_terminate_timeout = 300' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.max_spare_servers =/c\pm.max_spare_servers = 30' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.min_spare_servers =/c\pm.min_spare_servers = 10' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.start_servers =/c\pm.start_servers = 20' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.max_children =/c\pm.max_children = 100' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.max_requests =/c\pm.max_requests = 500' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm.status_path =/c\pm.status_path = /status' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/ping.path =/c\ping.path = /ping' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/listen = /c\listen = 127.0.0.1:9000' /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf
sudo sed -i '/pm =/c\pm = ondemand' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/request_terminate_timeout =/c\request_terminate_timeout = 300' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.max_spare_servers =/c\pm.max_spare_servers = 30' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.min_spare_servers =/c\pm.min_spare_servers = 10' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.start_servers =/c\pm.start_servers = 20' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.max_children =/c\pm.max_children = 100' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.max_requests =/c\pm.max_requests = 500' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/pm.status_path =/c\pm.status_path = /status' /etc/php/$ver/fpm/pool.d/www.conf
sudo sed -i '/ping.path =/c\ping.path = /ping' /etc/php/$ver/fpm/pool.d/www.conf
[[ $ver == 7.2 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9000' /etc/php/$ver/fpm/pool.d/www.conf
[[ $ver == 7.1 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9002' /etc/php/$ver/fpm/pool.d/www.conf
[[ $ver == 7.0 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9004' /etc/php/$ver/fpm/pool.d/www.conf
[[ $ver == 5.6 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9006' /etc/php/$ver/fpm/pool.d/www.conf
sudo touch /var/log/php/$(conf_read php-ver)/slow.log
sudo cp /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i '/\[www\]/c\[debug]' /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i '/rlimit_core =/c\rlimit_core = unlimited' /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i "/slowlog =/c\slowlog = /var/log/php/$(conf_read php-ver)/slow.log" /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i '/request_slowlog_timeout =/c\request_slowlog_timeout = 10s' /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i '/listen = /c\listen = 127.0.0.1:9001' /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo touch /var/log/php/$ver/slow.log
sudo cp /etc/php/$ver/fpm/pool.d/www.conf /etc/php/$ver/fpm/pool.d/debug.conf
sudo sed -i '/\[www\]/c\[debug]' /etc/php/$ver/fpm/pool.d/debug.conf
sudo sed -i '/rlimit_core =/c\rlimit_core = unlimited' /etc/php/$ver/fpm/pool.d/debug.conf
sudo sed -i "/slowlog =/c\slowlog = /var/log/php/$ver/slow.log" /etc/php/$ver/fpm/pool.d/debug.conf
sudo sed -i '/request_slowlog_timeout =/c\request_slowlog_timeout = 10s' /etc/php/$ver/fpm/pool.d/debug.conf
[[ $ver == 7.2 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9001' /etc/php/$ver/fpm/pool.d/debug.conf
[[ $ver == 7.1 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9003' /etc/php/$ver/fpm/pool.d/debug.conf
[[ $ver == 7.0 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9005' /etc/php/$ver/fpm/pool.d/debug.conf
[[ $ver == 5.6 ]] && sudo sed -i '/listen = /c\listen = 127.0.0.1:9007' /etc/php/$ver/fpm/pool.d/debug.conf
if [[ -n $ver && ($ver == "7.2" || $ver == "7.1" || $ver == "7.0") ]]; then
# xdebug deprecated in 5.6
sudo echo 'php_admin_flag[xdebug.profiler_enable] = off' >> /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo echo 'php_admin_flag[xdebug.profiler_enable_trigger] = on' >> /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo echo 'php_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R' >> /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo echo 'php_admin_value[xdebug.profiler_output_dir] = /tmp/' >> /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf
sudo sed -i '/zend_extension=/c\;zend_extension=xdebug.so' /etc/php/$(conf_read php-ver)/mods-available/xdebug.ini
sudo echo 'php_admin_flag[xdebug.profiler_enable] = off' >> /etc/php/$ver/fpm/pool.d/debug.conf
sudo echo 'php_admin_flag[xdebug.profiler_enable_trigger] = on' >> /etc/php/$ver/fpm/pool.d/debug.conf
sudo echo 'php_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R' >> /etc/php/$ver/fpm/pool.d/debug.conf
sudo echo 'php_admin_value[xdebug.profiler_output_dir] = /tmp/' >> /etc/php/$ver/fpm/pool.d/debug.conf
sudo sed -i '/zend_extension=/c\;zend_extension=xdebug.so' /etc/php/$ver/mods-available/xdebug.ini
fi
conf_write php-optim true

View file

@ -30,7 +30,7 @@ if [[ $arg == "-purge=force" || $opt == "-purge-server-all=force" || $opt == "-p
fi
# Extract value if exist
if [[ $opt == "-nginx="* || $opt == "-html="* || $opt == "-lemp="* ]]; then
if [[ $opt == "-nginx="* || $opt == "-html="* || $opt == "-lemp="* || $opt == "-php="* || $opt == "-php-ver="* ]]; then
value=$(echo "${opt}" | cut -d'=' -f 2 -s)
opt=$(echo "${opt}" | cut -d'=' -f 1 -s)
fi
@ -126,17 +126,17 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
clear_force_flag
exit 0
fi
echo ""
echo "${red} ¡ C A U T I O N ! You are about to remove PHP from your server!"
echo " This action will also remove PhpMyAdmin if its installed because depends on PHP. ${end}"
echo ""
if [[ $(conf_read force-flag) != "true" ]]; then
echo " ${blu} Are you sure [y/N]? ${end}"
while read -r -n 1 -s answer; do
answer=${answer:-n}
[[ $answer = [YyNn] ]] && break
answer=${answer:-n}
[[ $answer = [YyNn] ]] && break
done
fi
@ -151,16 +151,20 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
sudo apt-get -y autoremove
sudo rm -rf /etc/php
sudo rm /opt/webinoly/templates/source/*
conf_write php purged
conf_write php-optim purged
[[ $(conf_read php-v7.2) == "true" ]] && conf_write php-v7.2 purged
[[ $(conf_read php-v7.1) == "true" ]] && conf_write php-v7.1 purged
[[ $(conf_read php-v7.0) == "true" ]] && conf_write php-v7.0 purged
[[ $(conf_read php-v5.6) == "true" ]] && conf_write php-v5.6 purged
if [[ $(conf_read php-tool) == "true" ]]; then
rm -rf /var/www/$(conf_read tools-port)/htdocs/fpm
rm -rf /var/www/$(conf_read tools-port)/htdocs/php
conf_write php-tool purged
fi
[[ $(conf_read nginx-tool) != "true" ]] && conf_write web-tool purged
echo ""
echo "${gre}PHP has been deleted successfully! ${end}"
@ -172,6 +176,7 @@ elif [[ $arg == "-purge" && $opt == "-php" ]]; then
fi
echo ""
api_update pp2
elif [[ $arg == "-purge" && $opt == "-mysql" ]]; then
api_update pm1
@ -344,7 +349,7 @@ elif [[ $opt == "-html" || $opt == "-nginx" ]]; then
fi
elif [[ $opt == "-php" ]]; then
if [[ $(conf_read php) != "true" ]]; then
if [[ $(conf_read php) != "true" || ( -n $value && $(conf_read php-v${value}) != "true" ) ]]; then
if [[ $(conf_read nginx) != "true" && $(conf_read force-flag) != "true" ]]; then
echo ""
echo "${blu}Nginx is not installed, do you want to install it too [Y/n]?${end} "
@ -355,10 +360,12 @@ elif [[ $opt == "-php" ]]; then
[[ $answer != [Nn] ]] && stack -nginx $arg
fi
php_install
php_optim
[[ $arg != "-notools" ]] && php_tool
echo ""
[[ -n $value ]] && php_install $value || php_install
[[ -n $value && $(conf_read php-v${value}) == "true" ]] && php_optim $value
[[ -z $value ]] && php_optim
def=$(conf_read php-ver)
[[ $arg != "-notools" && $(conf_read php-tool) != "true" ]] && php_tool
echo ""
echo "${gre}PHP has been successfully Optimized by Webinoly! ${end}"
echo ""
else
@ -408,31 +415,35 @@ elif [[ $opt == "-lemp" ]]; then
echo "${gre}Nginx, PHP, MySQL (MariaDB) and some other useful tools have been installed successfully! ${end}"
echo ""
elif [[ $opt == "-php-ver="* ]]; then
phpver=$(echo "${opt}" | cut -d'=' -f 2 -s)
if [[ -n $phpver && ($phpver == "7.2" || $phpver == "7.1" || $phpver == "7.0" || $phpver == "5.6") ]]; then
echo "${blu} New PHP version: '$phpver' ${end}"
if [[ $(conf_read php) == "true" && $(conf_read php-ver) == $phpver ]]; then
echo "${red}PHP $phpver is currently installed!${end}"
elif [[ $opt == "-php-ver" ]]; then
if [[ $(conf_read multi-php) == "true" ]]; then
echo "${red}This command is disabled because Multi-PHP is enabled!${end}"
exit 0
fi
if [[ -n $value && ($value == "7.2" || $value == "7.1" || $value == "7.0" || $value == "5.6") ]]; then
echo "${blu}New PHP version: '$value' ${end}"
if [[ $(conf_read php) == "true" && $(conf_read php-ver) == $value ]]; then
echo "${red}PHP $value is currently installed!${end}"
elif [[ $(conf_read php) == "true" && $(conf_read mysql-tool) == "true" ]]; then
sudo stack -php -purge=force
conf_write php-ver $phpver
conf_write php-ver $value
# force flag prevent to be questioned (Unattended) when nginx is not installed.
conf_write force-flag true
sudo stack -php
sudo stack -pma
elif [[ $(conf_read php) == "true" && $(conf_read mysql-tool) != "true" ]]; then
sudo stack -php -purge=force
conf_write php-ver $phpver
conf_write php-ver $value
conf_write force-flag true
sudo stack -php
elif [[ $(conf_read php) != "true" && $(conf_read mysql-tool) != "true" ]]; then
conf_write php-ver $phpver
echo "${gre} PHP is not already installed but new version will be installed next time! ${end}"
conf_write php-ver $value
echo "${gre}PHP is not already installed but new version will be installed next time! ${end}"
fi
clear_force_flag
else
echo "${red} Please, enter a valid PHP version!${end}"
echo "${red}Please, enter a valid PHP version!${end}"
fi

View file

@ -302,7 +302,7 @@ elif [[ $opt == "-clear-cache" ]]; then
sudo chown -R www-data:www-data /var/www/$port/htdocs/php/opcache
sudo chmod 644 /var/www/$port/htdocs/php/opcache/index.php
fi
wget -q --spider --timeout=15 http://localhost:$port/php/opcache/
wget --spider --no-check-certificate --timeout=15 localhost:22222/php/opcache/ > /dev/null 2>&1 &
echo "${gre}- OpCache has been successfully cleared!${end}"
else
echo "${red}[ERROR] We can not clear OpCache because PHP and NGINX are not installed!${end}"

View file

@ -1,9 +1,9 @@
# Common upstream settings
upstream php {
#server unix:/run/php/php7.0-fpm.sock;
server 127.0.0.1:9000;
server 127.0.0.1:9000;
}
upstream debug {
# Debug Pool
server 127.0.0.1:9001;
# Debug Pool
server 127.0.0.1:9001;
}

3
weby
View file

@ -40,14 +40,13 @@ done
if [[ $2 == "-ver="* ]]; then
ver=$(echo "$2" | cut -d'=' -f 2 -s)
# Be sure we have a valid server response for the requested version
code=$(wget --server-response https://qrok.es/webinoly?version=$ver 2>&1 | awk '/^ HTTP/{print $2}')
code=$(wget --server-response --spider https://qrok.es/webinoly?version=$ver 2>&1 | awk '/^ HTTP/{print $2}')
# Get the last code (redirections)
code="${code##*$'\n'}"
echo "$(tput setaf 1)"
if [[ $code == 200 ]]; then
sudo wget --timeout=15 -qrO $HOME/webinoly.tar https://qrok.es/webinoly?version=$ver
sudo rm webinoly?version=$ver
webyversion="$ver"
[[ $ver == "beta" ]] && echo "[WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments."
else