-
Notifications
You must be signed in to change notification settings - Fork 5
/
php_multi_install.sh
executable file
·138 lines (125 loc) · 5.38 KB
/
php_multi_install.sh
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
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
function php_multi_install() {
local options
while true; do
mapfile -t available_versions < <(dnf repository-packages remi-safe list | grep php | grep -oP 'php[0-9]{2}' | sort -r | uniq)
mapfile -t installed_versions < <(rpm -qa | grep php | grep -oP 'php[0-9]{2}' | sort -r | uniq)
options=()
for available in "${available_versions[@]}"; do
local skip=
for installed in "${installed_versions[@]}"; do
if [[ $available == $installed ]]; then
skip=1
break
fi
done
[[ ! $skip ]] && options+=("$available")
done
if [ ${#options[@]} -eq 0 ]; then
echo "Все доступные версии PHP уже установлены."
return
fi
echo
echo -e "Вы сможете доустановить невыбранные версии ${GREEN}PHP${WHITE} позднее, после установки RISH."
echo -e "Установка ${GREEN}PHP${WHITE} происходит по очереди, одна версия за другой."
echo -e "Выбирайте только реально необходимые, не ставьте все подряд."
echo
echo -e "Выберите нужную версию ${GREEN}PHP${WHITE} из доступных."
local current_y=$(get_cursor_row)
echo
local size=$(stty size)
local lines=${size% *}
((skip_lines=0))
((need_to_skeep=${#installed_versions[@]}))
if (((current_y + need_to_skeep + 1) > lines)); then
((skip_lines=${current_y} + need_to_skeep - ${lines} + 2))
echo -en ${ESC}"[${skip_lines}S"
((current_y = ${current_y} - ${skip_lines}))
fi
if (( ${#installed_versions[@]} > 0 )); then
cursor_to $(($current_y+2)) 23
echo -en "───────────>"
cursor_to $(($current_y)) 35
echo -en "Установлено:"
refresh_window ${current_y}+1 35 ${#installed_versions[@]} 10 0 "${installed_versions[@]}"
fi
# Добавляем опцию для завершения процесса
options+=("Завершить выбор")
cursor_to $(($current_y)) 0
echo "Доступно:"
vertical_menu "current" 1 0 10 "${options[@]}"
local ret=$?
cursor_to $(($current_y)) 0
echo -en ${ESC}"[0J"
if (( ret == 255 )) || (( ret == ${#options[@]}-1 )); then
return 0
fi
local selected_version=${options[${ret}]}
echo "Установка выбранной версии PHP ($selected_version) и дополнительных расширений..."
sudo dnf install -y "$selected_version" \
"${selected_version}-php-fpm" \
"${selected_version}-php-opcache" \
"${selected_version}-php-cli" \
"${selected_version}-php-gd" \
"${selected_version}-php-mbstring" \
"${selected_version}-php-mysqlnd" \
"${selected_version}-php-xml" \
"${selected_version}-php-soap" \
"${selected_version}-php-zip" \
"${selected_version}-php-intl" \
"${selected_version}-php-json" \
"${selected_version}-php-gmp"
Up
echo -e "${GREEN}${selected_version}${WHITE} успешно установлен."
Down
PHPINI="/etc/opt/remi/${selected_version}/php.ini"
sed -i "s/memory_limit = .*/memory_limit = 256M/" $PHPINI
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 32M/" $PHPINI
sed -i "s/post_max_size = .*/post_max_size = 32M/" $PHPINI
sed -i "s/max_execution_time = .*/max_execution_time = 60/" $PHPINI
sed -i "/^;\?max_input_vars[[:space:]]*=/c\max_input_vars = 20000" $PHPINI
sed -i "s/output_buffering .*/output_buffering = Off/" $PHPINI
echo -e "Установлены лимиты для ${GREEN}${selected_version}${WHITE}:"
echo -e "memory_limit = ${GREEN}256M${WHITE}"
echo -e "upload_max_filesize = ${GREEN}32M${WHITE}"
echo -e "post_max_size = ${GREEN}32M${WHITE}"
echo -e "max_execution_time = ${GREEN}60${WHITE}"
echo -e "max_input_vars = ${GREEN}20000${WHITE}"
echo
echo -e "Ставим ${GREEN}imagick${WHITE}?"
if vertical_menu "current" 2 0 5 "Да" "Нет"
then
Install "${selected_version}-php-pecl-imagick"
#yum install php-pecl-imagick
fi
if ${LocalServer}; then
echo -e ${CURSORUP}"Ставим ${GREEN}Xdebug${WHITE}?${ERASEUNTILLENDOFLINE}"
if vertical_menu "current" 2 0 5 "Да" "Нет"; then
Install "${selected_version}-php-xdebug"
if [[ -e "/etc/opt/remi/${selected_version}/php.d/15-xdebug.ini" ]]; then
{
echo "xdebug.idekey = \"PHPSTORM\""
echo "xdebug.mode = debug"
echo "xdebug.client_port = 9003"
echo "xdebug.discover_client_host=1"
} >>"/etc/opt/remi/${selected_version}/php.d/15-xdebug.ini"
else
echo -e "Файл ${RED}/etc/opt/remi/${selected_version}/php.d/15-xdebug.ini${WHITE} не существует!"
echo -e "Возможны ошибки при установке xdebug."
echo -e "Продолжить установку?"
if vertical_menu "current" 2 0 5 "Да" "Нет"; then
echo "Продолжаем..."
else
RemoveRim
echo "Установка завершена с ошибкой"
exit 1
fi
fi
fi
fi
systemctl enable ${selected_version}-php-fpm
echo
systemctl start ${selected_version}-php-fpm
echo
done
}