Last active
August 17, 2018 13:39
-
-
Save rrolla/53876e19becdde495d4ea6d809a1bd53 to your computer and use it in GitHub Desktop.
Script to install php7 from source for Raspberry Pi 3 Model B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Script to install php7 from source for Raspberry Pi 3 Model B | |
# | |
# Author rolla aka Raitis Rolis (raitis.rolis@gmail.com) | |
# | |
# Thanks for http://shaunvos.me/2018/06/14/installing-php-7-2-6-on-raspian-stretch-on-raspberry-pi-3-model-b/ | |
# Thanks for https://www.linuxbabe.com/php/compile-php7-source-raspbian-jessie | |
# | |
start=`date +%s` | |
echo | |
echo "Latest PHP 7 Build from source for Raspberry Pi 3 Model B install script" | |
echo | |
VERSION=7.2.8 | |
PHP_HOME=/home/${USER}/php-${VERSION} | |
PHP_INSTALL_PATH=/opt/php-${VERSION} | |
sudo apt -qq -y install libcurl4-openssl-dev libbz2-dev libjpeg-dev libkrb5-dev libmcrypt-dev libxslt1-dev libxslt1.1 libpq-dev git make build-essential libc-client2007e libc-client2007e-dev | |
sudo mkdir /usr/c-client | |
sudo ln -s /usr/lib/libc-client.a /usr/c-client/ | |
sudo apt -qq -y install pkg-config libssl-dev openssl | |
wget http://lv1.php.net/get/php-${VERSION}.tar.gz/from/this/mirror -O php-${VERSION}.tar.gz | |
echo "Extracting php archive..." | |
tar -zxf php-${VERSION}.tar.gz | |
cd $PHP_HOME | |
./configure --prefix=${PHP_INSTALL_PATH} --with-config-file-path=${PHP_INSTALL_PATH}/etc --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-zlib --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg-dir=/usr --with-png-dir=/usr --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/arm-linux-gnueabihf --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm | |
make -j4 | |
sudo make install | |
sudo mv ${PHP_INSTALL_PATH}/etc/php-fpm.conf.default ${PHP_INSTALL_PATH}/etc/php-fpm.conf | |
sudo mv ${PHP_INSTALL_PATH}/etc/php-fpm.d/www.conf.default ${PHP_INSTALL_PATH}/etc/php-fpm.d/www.conf | |
sudo cp ${PHP_HOME}/php.ini-production ${PHP_INSTALL_PATH}/etc/php.ini | |
sudo cp ${PHP_INSTALL_PATH}/bin/php /usr/local/bin/php | |
sudo ln -s /usr/local/bin/php /usr/bin/php | |
sudo cp ${PHP_INSTALL_PATH}/sbin/php-fpm /usr/local/bin/php-fpm | |
sudo ln -s /usr/local/bin/php-fpm /usr/bin/php-fpm | |
# echo "Cleaning install files..." | |
# sudo rm -rf $PHP_HOME | |
# sudo rm -rf $PHP_INSTALL_PATH | |
echo "PHP version ${VERSION} installed!" | |
end=`date +%s` | |
runtime=$((end-start)) | |
echo | |
echo "================================" | |
echo "Build complete in ${runtime} seconds!" | |
echo "================================" | |
echo | |
php -v | |
sudo php-fpm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment