forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_ngnix_apache_nginx-php-fpm.sh
More file actions
executable file
·73 lines (58 loc) · 2.73 KB
/
migrate_ngnix_apache_nginx-php-fpm.sh
File metadata and controls
executable file
·73 lines (58 loc) · 2.73 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
#!/bin/bash
# Function Description
# Manual upgrade script from Nginx + Apache2 + PHP-FPM to Nginx + PHP-FPM
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# shellcheck source=/usr/local/hestia/conf/hestia.conf
source $HESTIA/conf/hestia.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
if [ "$WEB_BACKEND" != "php-fpm" ]; then
check_result $E_NOTEXISTS "PHP-FPM is not enabled" > /dev/null
exit 1
fi
if [ "$WEB_SYSTEM" != "apache2" ]; then
check_result $E_NOTEXISTS "Apache2 is not enabled" > /dev/null
exit 1
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Remove apache2 from config
sed -i "/^WEB_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^WEB_SSL/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^WEB_SSL_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^WEB_RGROUPS/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^WEB_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
# Remove nginx (proxy) from config
sed -i "/^PROXY_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^PROXY_SSL_PORT/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
sed -i "/^PROXY_SYSTEM/d" $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
# Add Nginx settings to config
echo "WEB_PORT='80'" >> $HESTIA/conf/hestia.conf
echo "WEB_SSL='openssl'" >> $HESTIA/conf/hestia.conf
echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/hestia.conf
echo "WEB_SYSTEM='nginx'" >> $HESTIA/conf/hestia.conf
# Add Nginx settings to config
echo "WEB_PORT='80'" >> $HESTIA/conf/defaults/hestia.conf
echo "WEB_SSL='openssl'" >> $HESTIA/conf/defaults/hestia.conf
echo "WEB_SSL_PORT='443'" >> $HESTIA/conf/defaults/hestia.conf
echo "WEB_SYSTEM='nginx'" >> $HESTIA/conf/defaults/hestia.conf
rm $HESTIA/conf/defaults/hestia.conf
cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
# Rebuild web config
for user in $($BIN/v-list-users plain | cut -f1); do
echo $user
for domain in $($BIN/v-list-web-domains $user plain | cut -f1); do
$BIN/v-change-web-domain-tpl $user $domain 'default'
$BIN/v-rebuild-web-domain $user $domain no
done
done
systemctl restart nginx