Building PHP 7.1 from source on Debian Jessie (8.7)
Today we will build the latest PHP from source package on GNU/Debian Jessie (8.x) Linux distribution!
Prerequisites
apt-get install libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dbg libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng12-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev bison build-essential autoconf libreadline-dev
After this operation, 22.8 MB of additional disk space will be used.
sudo su
mkdir -p /root/sources/php7.1&&cd /root/sources/php7.1
Then we are going to search for the latest php version on https://github.com/php/php-src/releases as of writting it's 7.1.2
wget https://github.com/php/php-src/archive/php-7.1.2.tar.gztar xzf php-7.1.2.tar.gz
cd php-src-php-7.1.2/
ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a # if we gonna build with --with-imap support./buildconf —force
./configure --prefix=/opt/php/7.1 --bindir=/opt/php/7.1/bin --sbindir=/opt/php/7.1 --libexecdir=/opt/php/7.1/lib --datadir=/opt/php/7.1/share --sysconfdir=/opt/php/7.1/etc --sharedstatedir=/php/7.1/com --localstatedir=/opt/php/7.1/var --libdir=/opt/php/7.1/lib/x86_64-linux-gnu --includedir=/opt/php/7.1/include --infodir=/opt/php/7.1/share/info --mandir=/opt/php/7.1/share/man --with-pdo-pgsql --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --with-pgsql --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 --enable-gd-native-ttf --with-openssl --with-fpm-user=www-data --with-fpm-group=www-data --with-libdir=/lib/x86_64-linux-gnu --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --with-readline=/usr --enable-shmop --enable-wddx --disable-ipv6
make
make install
[PEAR] Archive_Tar - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.3.0
[PEAR] PEAR - installed: 1.10.1
Wrote PEAR system config file at: /opt/php/7.1/etc/pear.conf
You may want to add: /opt/php/7.1/lib/x86_64-linux-gnu/php to your php.ini include_path
/root/sources/php7.1/php-src-php-7.1.2/build/shtool install -c ext/phar/phar.phar /opt/php/7.1/bin
ln -s -f phar.phar /opt/php/7.1/bin/phar
Installing PDO headers: /opt/php/7.1/include/php/ext/pdo/
cp php.ini-production /opt/php/7.1/etc/php.ini
ln -s /opt/php/7.1/etc/php.ini /opt/php/7.1/lib/x86_64-linux-gnu/php.ini
If you need Zend OPCache then open php.ini and add this line on the end of file:
zend_extension=opcache.so
Prepare php-fpm
cd /opt/php/7.1/etc/
mv php-fpm.conf.default php-fpm.conf
nano /opt/php/7.1/etc/php-fpm.conf
Uncomment ;pid = run/php-fpm.pid
If you need to create more php-fpm pools, do it in /opt/php/7.1/etc/php-fpm.d/ directory, there will be ww.conf by default
Systemd Service
For normal use, we need to start php-fpm at system startup, so we make systemd service unit script for that
For normal use, we need to start php-fpm at system startup, so we make systemd service unit script for that
nano /lib/systemd/system/php-7.1-fpm.service
[Unit]
Description=The PHP 7.1 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/opt/php/7.1/var/run/php-fpm.pid
ExecStart=/opt/php/7.1/php-fpm --nodaemonize --fpm-config /opt/php/7.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
systemctl enable php-7.1-fpm.service
systemctl daemon-reload
systemctl start php-7.1-fpm.serviceThants all, now you have to setup your httpd server (apache, nginx etc...), let it be another article to do that correctly ;-)
No comments: