forked from EngineScript/EngineScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp-install.sh
More file actions
93 lines (77 loc) · 3.34 KB
/
php-install.sh
File metadata and controls
93 lines (77 loc) · 3.34 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
#!/usr/bin/env bash
#----------------------------------------------------------------------------
# EngineScript - A High-Performance WordPress Server Built on Ubuntu and Cloudflare
#----------------------------------------------------------------------------
# Website: https://EngineScript.com
# GitHub: https://github.com/Enginescript/EngineScript
# Company: VisiStruct / EngineScript
# License: GPL v3.0
# OS: Ubuntu 22.04 (jammy)
#----------------------------------------------------------------------------
# EngineScript Variables
source /usr/local/bin/enginescript/enginescript-variables.txt
source /home/EngineScript/enginescript-install-options.txt
# Check current user's ID. If user is not 0 (root), exit.
if [ "${EUID}" != 0 ];
then
echo "${BOLD}ALERT:${NORMAL}"
echo "EngineScript should be executed as the root user."
exit
fi
#----------------------------------------------------------------------------
# Start Main Script
# Update & Upgrade
/usr/local/bin/enginescript/scripts/functions/enginescript-apt-update.sh
# Install PHP
apt install -qy php${PHP_VER} php${PHP_VER}-bcmath php${PHP_VER}-bz2 php${PHP_VER}-common php${PHP_VER}-curl php${PHP_VER}-fpm php${PHP_VER}-gd php${PHP_VER}-igbinary php${PHP_VER}-imagick php${PHP_VER}-intl php${PHP_VER}-mbstring php${PHP_VER}-msgpack php${PHP_VER}-mysql php${PHP_VER}-opcache php${PHP_VER}-readline php${PHP_VER}-redis php${PHP_VER}-soap php${PHP_VER}-ssh2 php${PHP_VER}-xml php${PHP_VER}-zip
# Logrotate
cp -rf /usr/local/bin/enginescript/etc/logrotate.d/opcache /etc/logrotate.d/opcache
cp -rf /usr/local/bin/enginescript/etc/logrotate.d/php${PHP_VER}-fpm /etc/logrotate.d/php${PHP_VER}-fpm
# Backup PHP config
/usr/local/bin/enginescript/scripts/functions/cron/php-backup.sh
# Update PHP config
/usr/local/bin/enginescript/scripts/update/php-config-update.sh
mkdir -p /var/cache/opcache
mkdir -p /var/cache/php-sessions
mkdir -p /var/cache/wsdlcache
mkdir -p /var/log/opcache
mkdir -p /var/log/php
touch /var/log/opcache/opcache.log
touch /var/log/php/php${PHP_VER}-fpm.log
#touch /var/log/php/php.log
#touch /var/log/php/php-www.log
#touch /var/log/php/php-fpm.log
find /var/log/php -type d,f -exec chmod 775 {} \;
find /var/log/opcache -type d,f -exec chmod 775 {} \;
find /etc/php -type d,f -exec chmod 775 {} \;
chmod 775 /var/cache/opcache
chmod 775 /var/cache/php-sessions
chmod 775 /var/cache/wsdlcache
chown -R www-data:www-data /var/cache/opcache
chown -R www-data:www-data /var/cache/php-sessions
chown -R www-data:www-data /var/cache/wsdlcache
chown -R www-data:www-data /var/log/opcache
chown -R www-data:www-data /var/log/php
chown -R www-data:www-data /etc/php
# Restart PHP
service php${PHP_VER}-fpm restart
# PHP Service Check
STATUS="$(systemctl is-active php${PHP_VER}-fpm)"
if [ "${STATUS}" = "active" ]; then
echo "PASSED: PHP ${PHP_VER} is running."
echo "PHP=1" >> /home/EngineScript/install-log.txt
else
echo "FAILED: PHP ${PHP_VER} not running. Please diagnose this issue before proceeding."
exit 1
fi
echo ""
echo "============================================================="
echo ""
echo "PHP ${PHP_VER} setup completed."
echo ""
echo "============================================================="
echo ""
sleep 5
# Cleanup
/usr/local/bin/enginescript/scripts/functions/php-clean.sh
/usr/local/bin/enginescript/scripts/functions/enginescript-cleanup.sh