forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-add-web-php
More file actions
executable file
·126 lines (98 loc) · 3.71 KB
/
v-add-web-php
File metadata and controls
executable file
·126 lines (98 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# info: add php fpm version
# options: VERSION
#
# The function checks and delete a fpm php version if not used by any domain.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
version=$1
# Includes
source $HESTIA/func/main.sh
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'VERSION'
# Set file locations
php_fpm="/etc/init.d/php$version-fpm"
# Verify php version format
if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
echo "The php version format is invalid, it should look like [0-9].[0-9]..."
exit
fi
# Check if php version already exists
if [ -f "$php_fpm" ] && [ -f "$HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl" ]; then
echo "Version already installed..."
exit
fi
# Check if php version is supported
if [ ! -f "$HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh" ]; then
echo "Version is currently not supported or does not exist..."
exit
fi
# Perform verification if read-only mode is enabled
check_hestia_demo_mode
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
mph="php$version-mbstring php$version-bcmath php$version-cli php$version-curl
php$version-fpm php$version-gd php$version-intl php$version-mysql
php$version-soap php$version-xml php$version-zip php$version-mbstring
php$version-json php$version-bz2 php$version-pspell php$version-imagick php$version-pgsql"
# Check is version is 7.1 or below to add mcrypt
if [[ `echo "$version 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
mph="$mph php$version-mcrypt"
fi
if [ -z "$DB_SYSTEM" -o "$DB_SYSTEM" = "mysql" ]; then
mph=$(echo "$mph" | sed -e "s/php$version-pgsql//")
fi
if [ -z "$DB_SYSTEM" -o "$DB_SYSTEM" = "pgsql" ]; then
mph=$(echo "$mph" | sed -e "s/php$version-mysql//")
fi
# Install php packages
apt-get -qq update
apt-get -y -qq -o Dpkg::Options::="--force-confold" install $mph > /dev/null 2>&1 &
BACK_PID=$!
# Check if package installation is done, print a spinner
echo "Install PHP-$version, please wait..."
spinner="/-\|"
spin_i=1
while kill -0 $BACK_PID > /dev/null 2>&1 ; do
printf "\b${spinner:spin_i++%${#spinner}:1}"
sleep 0.5
done
# Do a blank echo to get the \n back
echo
# Check if installation was sucessfully
if [ ! -f "$php_fpm" ]; then
echo "Installation failed, please run the following command manualy for debuging:"
echo "apt-get install $mph"
fi
# Check if required modules for apache2 are enabled
if [ "$WEB_SYSTEM" = "apache2" ]; then
if ! a2query -q -m proxy_fcgi; then
a2enmod -q proxy_fcgi
fi
if ! a2query -q -m setenvif; then
a2enmod -q setenvif
fi
$BIN/v-restart-web
fi
# Configure fpm
update-rc.d php$version-fpm defaults > /dev/null 2>&1
v_tpl=${version//.}
rm -f /etc/php/$version/fpm/pool.d/*
cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$version/fpm/pool.d/
sed -i "s/9999/99$v_tpl/g" /etc/php/$version/fpm/pool.d/dummy.conf
# Install backend template
cp -f $HESTIA_INSTALL_DIR/php-fpm/multiphp.tpl \
$HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
# Logging
log_history "installed php $version" '' 'admin'
log_event "$OK" "$ARGUMENTS"
exit