-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-php.sh
102 lines (90 loc) · 2.57 KB
/
install-php.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
#!/bin/sh
# Parse script arguments
while [ $# -gt 0 ]; do
case "$1" in
--xdebug=*)
xdebug="${1#*=}"
;;
--xdebug-version=*)
xdebug_version="${1#*=}"
;;
--xdebug-host=*)
xdebug_host="${1#*=}"
;;
--xdebug-port=*)
xdebug_port="${1#*=}"
;;
--xdebug-idekey=*)
xdebug_idekey="${1#*=}"
;;
*)
echo "Error: Invalid argument: $1"
exit 1
;;
esac
shift
done
# Check if PHPIZE_DEPS is set
if [ -z "$PHPIZE_DEPS" ]; then
echo "Error: PHPIZE_DEPS variable is not set."
exit 1
fi
# Update package repositories
apk update
# Install required packages
apk add --update --no-cache \
$PHPIZE_DEPS \
bzip2-dev \
freetype-dev \
icu-dev \
jpeg-dev \
libjpeg-turbo-dev \
libmemcached-dev \
libpng-dev \
libxml2-dev \
libzip-dev \
openldap-dev \
postgresql-dev \
freetype \
libpng \
libjpeg-turbo \
zip \
linux-headers \
supervisor \
git \
nano \
nodejs \
npm \
postgresql-client
# Configure and install gd extension
docker-php-ext-configure gd --with-freetype --with-jpeg
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1)
docker-php-ext-install -j${NPROC} gd
# Install other required extensions
docker-php-ext-install bcmath bz2 intl ldap pcntl pdo_mysql pdo_pgsql soap sockets xml zip
# Install php pickle replacement for pecl
curl -sSLo /usr/local/bin/pickle https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar
chmod +x /usr/local/bin/pickle
pickle install -n --defaults igbinary
pickle install -n --defaults memcached
pickle install -n --defaults redis
pickle install -n --defaults xmlrpc
pickle install -n --defaults xdebug@${xdebug_version}
docker-php-ext-enable igbinary memcached redis xmlrpc xdebug >/dev/null
# Install Xdebug if enabled
if [ "$xdebug" = true ]; then
docker-php-ext-enable xdebug >/dev/null
echo -e "xdebug.client_host=${xdebug_host}" \
"\nxdebug.client_port=${xdebug_port}" \
"\nxdebug.mode=develop,coverage,debug,trace" \
"\nxdebug.start_with_request=yes" \
"\nxdebug.idekey=${xdebug_idekey}" \
>>/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
fi
# Install Composer
curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install PHPUnit
curl -sSL -o /usr/bin/phpunit https://phar.phpunit.de/phpunit.phar && chmod +x /usr/bin/phpunit
# Remove temporary packages
apk del $PHPIZE_DEPS
rm -rf /var/cache/apk/* /var/tmp/* /tmp/*