-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall_php.sh
More file actions
executable file
·113 lines (101 loc) · 3.48 KB
/
install_php.sh
File metadata and controls
executable file
·113 lines (101 loc) · 3.48 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
#!/bin/bash
# PHP version to be installed supplied by command line argument
version=$1
# Navigate to script's working directory
cd "$(dirname "$0")"
# Checking for a missing argument
if (( $# != 1 ))
then
echo "Missing PHP version argument!"
echo "Usage eg.: ./install 7.0.0"
exit 1
fi
# Install Prerequisites
apt-get update
apt-get install -y \
autoconf \
bison \
build-essential \
git-core \
libbz2-dev \
libcurl4-openssl-dev \
libfreetype6-dev \
libicu-dev \
libjpeg-dev \
libmcrypt-dev \
libpng-dev \
libpspell-dev \
libreadline-dev \
libssl-dev \
libxml2-dev \
pkg-config
# Create directory to be used as an installation target
mkdir /usr/local/php-$version
git clone https://github.com/php/php-src.git
cd php-src
# Exit if non-existing PHP version is supplied
git checkout PHP-$version || { echo "PHP version $version not found!" ; exit 1; }
./buildconf --force
CONFIGURE_STRINGS="--enable-bcmath \
--enable-calendar \
--enable-dba \
--enable-exif \
--enable-filter \
--enable-fpm \
--enable-ftp \
--enable-gd-native-ttf \
--enable-intl \
--enable-mbstring \
--enable-mysqlnd \
--enable-pcntl \
--enable-shmop \
--enable-simplexml \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-xmlreader \
--enable-xmlwriter \
--enable-zip \
--prefix=/usr/local/php-$version \
--with-bz2 \
--with-config-file-scan-dir=/usr/local/php-$version/etc/conf.d \
--with-curl \
--with-fpm-group=www-data \
--with-fpm-user=www-data \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-jpeg-dir \
--with-mcrypt \
--with-mhash \
--with-mysqli=mysqlnd \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-openssl \
--without-pear \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-png-dir \
--with-pspell \
--with-readline \
--with-sqlite3 \
--with-zlib"
./configure $CONFIGURE_STRINGS
# Perform compilation and subsequent installation
make
make install
# Configure PHP-FPM
cd ..
for i in $( ls conf/* ); do sed -i "s/VERSION/$version/" $i; done
ln -s /usr/local/php-$version/sbin/php-fpm /usr/local/php-$version/sbin/php-$version-fpm
cp php-src/php.ini-production /usr/local/php-$version/lib/php.ini
mv /usr/local/php-$version/etc/php-fpm.d/www.conf.default /usr/local/php-$version/etc/php-fpm.d/www.conf
cp conf/php-fpm.conf /usr/local/php-$version/etc/php-fpm.conf
# Enable modules
echo "zend_extension=opcache.so" >> /usr/local/php-$version/lib/php.ini
# Configure php7-fmp init.d script
cp conf/php7-fpm.init /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
update-rc.d php7-fpm defaults