Skip to content

Instantly share code, notes, and snippets.

@risyasin
Last active December 20, 2019 06:50
Show Gist options
  • Save risyasin/4aba3da60177610274cc9a4f8ed0ad4e to your computer and use it in GitHub Desktop.
Save risyasin/4aba3da60177610274cc9a4f8ed0ad4e to your computer and use it in GitHub Desktop.
Ubuntu 18 PHP compile Pear + DB4 + Argon for AWS "A" instances
#!/bin/bash
### Builds PHP from source on Ubuntu 18
set -e
echo "Prepairing build tools"
DEBIAN_FRONTEND=noninteractive apt update -y && apt install -y build-essential \
bison autoconf bison re2c pkg-config libsystemd-dev libxml2-dev \
libssl-dev libsqlite3-dev libcurl4-openssl-dev libcurl4 \
unzip libenchant-dev libffi-dev libpng-dev libgmp-dev libonig-dev \
libpq-dev libedit-dev librecode-dev libargon2-0-dev libzip-dev
cd /usr/src
rm -rf php-src 2> /dev/null
echo "Cloning PHP source from github"
git clone https://github.com/php/php-src.git
cd /usr/src/php-src
git checkout PHP-7.3.7
wget http://download.oracle.com/berkeley-db/db-4.8.30.zip
unzip db-4.8.30.zip
cd db-4.8.30/build_unix/
../dist/configure --prefix=/usr/local --enable-cxx
make -j2
make install
cd /usr/src/php-src
./buildconf --force
### Configure PHP
./configure --prefix=/usr/local --exec-prefix=/usr/local --sysconfdir=/etc/php7 \
--with-config-file-path=/etc/php7 \
--with-config-file-scan-dir=/etc/php7/conf.d/ \
--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-fpm-systemd \
--enable-bcmath \
--enable-calendar \
--enable-gd \
--enable-exif \
--enable-intl \
--enable-mbstring \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-mysqlnd \
--enable-shmop \
--enable-sockets \
--with-curl \
--with-db4 \
--with-enchant \
--with-ffi \
--with-openssl \
--with-zlib \
--with-gmp \
--with-mhash \
--with-mysqli \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-pdo-mysql \
--with-pdo-pgsql \
--without-pdo-sqlite \
--with-readline \
--with-libedit \
--with-recode \
--with-password-argon2 \
--with-zip \
--with-pear
## Compile
make -j4
## Install
make install
### Pecl configure
cp php.ini-production /etc/php7/php.ini
pear config-set php_ini /etc/php7/php.ini
pecl channel-update pecl.php.net
### Composer install
git clone https://github.com/composer/getcomposer.org.git composer
php ./composer/web/installer
cp composer.phar /usr/local/bin/composer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment