Skip to content

Instantly share code, notes, and snippets.

@jesusninoc
Forked from m1st0/php_build_ubuntu.sh
Created January 5, 2019 22:52
Show Gist options
  • Save jesusninoc/a4b8d59008d2130bd785ffdf1b977106 to your computer and use it in GitHub Desktop.
Save jesusninoc/a4b8d59008d2130bd785ffdf1b977106 to your computer and use it in GitHub Desktop.

Revisions

  1. Maulik Mistry revised this gist Aug 4, 2017. 1 changed file with 49 additions and 15 deletions.
    64 changes: 49 additions & 15 deletions php7_build_ubuntu.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,44 @@
    #! /bin/bash
    ## PHP 7 Initial Compile ##

    ## Some help from the various places like these. ##
    # http://www.zimuel.it/install-php-7/
    # http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
    # PHP 7 Initial Compile #
    # Author: Maulik Mistry
    # Date: Aug 04, 2017
    # References:
    # http://www.zimuel.it/install-php-7/
    # http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu
    #
    # License: BSD License 2.0
    # Copyright (c) 2015-2017, Maulik Mistry
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without
    # modification, are permitted provided that the following conditions are met:
    # * Redistributions of source code must retain the above copyright
    # notice, this list of conditions and the following disclaimer.
    # * Redistributions in binary form must reproduce the above copyright
    # notice, this list of conditions and the following disclaimer in the
    # documentation and/or other materials provided with the distribution.
    # * Neither the name of the <organization> nor the
    # names of its contributors may be used to endorse or promote products
    # derived from this software without specific prior written permission.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
    # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

    ## Setup Ubuntu 15.04/15.10 ##
    # Other dependencies for PHP 7. Add any missing ones from configure script
    # complaints, plus some LAMP needs too.

    # Stop execution if things fail to move forward.
    set -e

    # Setup Kubuntu with other dependencies for PHP 7. Add any missing ones from
    # the configure script.
    sudo apt-get update
    sudo apt-get install libldap2-dev \
    libldap-2.4-2 \
    @@ -29,7 +60,9 @@ sudo apt-get install libldap2-dev \
    mysql-server \
    mysql-common \
    libpspell-dev \
    librecode-dev
    librecode-dev \
    libcurl4-openssl-dev \
    libxft-dev

    # PHP 7 does not recognize these without additional parameters or symlinks for
    # Ldap.
    @@ -40,11 +73,11 @@ sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
    git clone https://github.com/php/php-src
    cd php-src
    # Checkout latest release
    git checkout PHP-7.0.3
    git checkout php-7.1.7

    # Helped fix configure issues.
    ./buildconf
    # Setup compile options for Kubuntu 15.04. If failures occur, check dependencies
    # Helped fix configure issues and ignored files needing an update.
    ./buildconf --force
    # Setup compile options for Kubuntu. If failures occur, check dependencies
    # and symlink needs above.
    ./configure --prefix=/usr/local/php7 \
    --with-config-file-path=/etc/php7/apache2 \
    @@ -90,7 +123,8 @@ git checkout PHP-7.0.3
    sudo make clean

    # Using as many threads as possible.
    sudo make -j `cat /proc/cpuinfo | grep processor | wc -l`
    cpunum=$((`cat /proc/cpuinfo | grep processor | wc -l` + 1))
    sudo make -j ${cpunum}

    # Install it accoridng to the configured path.
    sudo make install
    @@ -138,12 +172,12 @@ sudo update-alternatives --config php
    #</FilesMatch>
    #
    # Running PHP scripts in user directories is disabled by default
    #
    #
    # To re-enable PHP in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    # <Directory /home/*/public_html>
    # php_admin_flag engine Off
    # php_admin_flag engine Off
    # </Directory>
    #</IfModule>"
  2. @m1st0 m1st0 revised this gist Jan 20, 2016. No changes.
  3. @m1st0 m1st0 renamed this gist Jan 20, 2016. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion php7_build_ubuntu15.04-15.10.sh → php7_build_ubuntu.sh
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,8 @@ sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
    # Obtain latest source
    git clone https://github.com/php/php-src
    cd php-src
    # Checkout latest release
    git checkout PHP-7.0.3

    # Helped fix configure issues.
    ./buildconf
    @@ -81,7 +83,8 @@ cd php-src
    --with-recode=/usr \
    --with-apxs2=/usr/bin/apxs \
    --with-mysqli=/usr/bin/mysql_config \
    --with-ldap
    --with-ldap \
    --with-xdebug

    # Cleanup for previous failures.
    sudo make clean
  4. @m1st0 m1st0 renamed this gist Dec 11, 2015. 1 changed file with 3 additions and 7 deletions.
    10 changes: 3 additions & 7 deletions php7_build_ubuntu15.04.sh → php7_build_ubuntu15.04-15.10.sh
    Original file line number Diff line number Diff line change
    @@ -5,15 +5,11 @@
    # http://www.zimuel.it/install-php-7/
    # http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu

    ## Setup Ubuntu 15.04 ##
    # I like the speed of Apt-Fast. Will check for installs some other day.
    sudo apt-get install apt-fast
    # Uncomment to get the lastest updates.
    # sudo apt-fast update && sudo apt-fast upgrade

    ## Setup Ubuntu 15.04/15.10 ##
    # Other dependencies for PHP 7. Add any missing ones from configure script
    # complaints, plus some LAMP needs too.
    sudo apt-fast install libldap2-dev \
    sudo apt-get update
    sudo apt-get install libldap2-dev \
    libldap-2.4-2 \
    libtool-bin \
    libzip-dev \
  5. @m1st0 m1st0 revised this gist Dec 11, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions php7_build_ubuntu15.04.sh
    Original file line number Diff line number Diff line change
    @@ -62,6 +62,7 @@ cd php-src
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-wddx \
    --enable-intl \
    --with-curl \
    --with-mcrypt \
    --with-iconv \
    @@ -89,9 +90,8 @@ cd php-src
    # Cleanup for previous failures.
    sudo make clean

    # Using as many threads as possible. Change as necessary. Will check in future
    # for cores.
    sudo make -j 10
    # Using as many threads as possible.
    sudo make -j `cat /proc/cpuinfo | grep processor | wc -l`

    # Install it accoridng to the configured path.
    sudo make install
  6. @m1st0 m1st0 revised this gist Oct 21, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions php7_build_ubuntu15.04.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,10 @@
    #! /bin/bash
    ## PHP 7 Initial Compile ##

    ## Some help from the various places like these. ##
    # http://www.zimuel.it/install-php-7/
    # http://www.hashbangcode.com/blog/compiling-and-installing-php7-ubuntu

    ## Setup Ubuntu 15.04 ##
    # I like the speed of Apt-Fast. Will check for installs some other day.
    sudo apt-get install apt-fast
  7. @m1st0 m1st0 revised this gist Oct 9, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions php7_build_ubuntu15.04.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,9 @@
    ## Setup Ubuntu 15.04 ##
    # I like the speed of Apt-Fast. Will check for installs some other day.
    sudo apt-get install apt-fast
    # Uncomment to get the lastest updates.
    # sudo apt-fast update && sudo apt-fast upgrade

    # Other dependencies for PHP 7. Add any missing ones from configure script
    # complaints, plus some LAMP needs too.
    sudo apt-fast install libldap2-dev \
    @@ -27,6 +30,7 @@ sudo apt-fast install libldap2-dev \
    mysql-common \
    libpspell-dev \
    librecode-dev

    # PHP 7 does not recognize these without additional parameters or symlinks for
    # Ldap.
    sudo ln -sf /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
  8. @m1st0 m1st0 renamed this gist Oct 9, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. @m1st0 m1st0 revised this gist Oct 9, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -18,14 +18,14 @@ sudo apt-fast install libldap2-dev \
    apache2-dev \
    libjpeg-dev \
    libxpm-dev \
    libxpm-devi \
    libxpm-dev \
    libgmp-dev \
    libgmp3-dev \
    libmcrypt-dev \
    libmysqlclient-dev \
    mysql-server \
    mysql-commoni \
    libpspell-devi \
    mysql-common \
    libpspell-dev \
    librecode-dev
    # PHP 7 does not recognize these without additional parameters or symlinks for
    # Ldap.
  10. @m1st0 m1st0 revised this gist Oct 9, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -99,8 +99,8 @@ sudo a2enmod php7

    # Restart Apache if all went well.
    sudo systemctl restart apache2
    # View any errors on startup.
    sudo journalctl -xe
    # View any errors for Apache startup.
    printf "Any errors starting Apache2 with PHP7 can be seen with 'sudo journalctl -xe' .\n"

    # Update the paths on th system according to Ubuntu. Can be later removed and
    # switched back.
  11. @m1st0 m1st0 revised this gist Oct 9, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -36,6 +36,8 @@ sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
    git clone https://github.com/php/php-src
    cd php-src

    # Helped fix configure issues.
    ./buildconf
    # Setup compile options for Kubuntu 15.04. If failures occur, check dependencies
    # and symlink needs above.
    ./configure --prefix=/usr/local/php7 \
  12. @m1st0 m1st0 revised this gist Jul 18, 2015. 1 changed file with 39 additions and 11 deletions.
    50 changes: 39 additions & 11 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -4,17 +4,40 @@
    ## Setup Ubuntu 15.04 ##
    # I like the speed of Apt-Fast. Will check for installs some other day.
    sudo apt-get install apt-fast
    # Some dependencies to install for PHP 7.
    sudo apt-get install libldap2-dev libldap-2.4-2 libtool-bin libzip-dev lbzip2 bzip2 re2c axps
    # PHP 7 does not recognize these without additional parameters or symlinks for Ldap..
    sudo ln -fs /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
    # Other dependencies for PHP 7. Add any missing ones from configure script
    # complaints, plus some LAMP needs too.
    sudo apt-fast install libldap2-dev \
    libldap-2.4-2 \
    libtool-bin \
    libzip-dev \
    lbzip2 \
    libxml2-dev \
    bzip2 \
    re2c \
    libbz2-dev \
    apache2-dev \
    libjpeg-dev \
    libxpm-dev \
    libxpm-devi \
    libgmp-dev \
    libgmp3-dev \
    libmcrypt-dev \
    libmysqlclient-dev \
    mysql-server \
    mysql-commoni \
    libpspell-devi \
    librecode-dev
    # PHP 7 does not recognize these without additional parameters or symlinks for
    # Ldap.
    sudo ln -sf /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
    sudo ln -sf /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so

    sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
    # Obtain latest source
    git clone https://github.com/php/php-src
    cd php-src

    # Setup compile options for Kubuntu 15.04
    # Setup compile options for Kubuntu 15.04. If failures occur, check dependencies
    # and symlink needs above.
    ./configure --prefix=/usr/local/php7 \
    --with-config-file-path=/etc/php7/apache2 \
    --with-config-file-scan-dir=/etc/php7/apache2/conf.d \
    @@ -47,7 +70,7 @@ cd php-src
    --with-pdo-mysql=/usr \
    --with-gettext=/usr \
    --with-zlib=/usr \
    --with-bz2=/usr \
    --with-bz2 \
    --with-recode=/usr \
    --with-apxs2=/usr/bin/apxs \
    --with-mysqli=/usr/bin/mysql_config \
    @@ -56,7 +79,8 @@ cd php-src
    # Cleanup for previous failures.
    sudo make clean

    # Using as many threads as possible. Change as necessary. Will check in future for cores.
    # Using as many threads as possible. Change as necessary. Will check in future
    # for cores.
    sudo make -j 10

    # Install it accoridng to the configured path.
    @@ -76,11 +100,15 @@ sudo systemctl restart apache2
    # View any errors on startup.
    sudo journalctl -xe

    # Update the paths on th system according to Ubuntu. Can be later removed and switched back.
    sudo update-alternatives --install /usr/bin/php php /usr/local/php7/bin/php 50 --slave /usr/share/man/man1/php.1.gz php.1.gz /usr/local/php7/php/man/man1/php.1
    # Update the paths on th system according to Ubuntu. Can be later removed and
    # switched back.
    sudo update-alternatives --install /usr/bin/php php /usr/local/php7/bin/php 50 \
    --slave /usr/share/man/man1/php.1.gz php.1.gz \
    /usr/local/php7/php/man/man1/php.1

    # Choose your PHP version.
    printf "Select the version of PHP you want active in subsequent shells and the system:\n"
    printf "Select the version of PHP you want active in subsequent shells and the \
    system:\n"
    sudo update-alternatives --config php

    ## To help enable Apache 2.4 use of PHP 7. Enable this after writing the file.
  13. @m1st0 m1st0 revised this gist Jul 18, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -79,6 +79,10 @@ sudo journalctl -xe
    # Update the paths on th system according to Ubuntu. Can be later removed and switched back.
    sudo update-alternatives --install /usr/bin/php php /usr/local/php7/bin/php 50 --slave /usr/share/man/man1/php.1.gz php.1.gz /usr/local/php7/php/man/man1/php.1

    # Choose your PHP version.
    printf "Select the version of PHP you want active in subsequent shells and the system:\n"
    sudo update-alternatives --config php

    ## To help enable Apache 2.4 use of PHP 7. Enable this after writing the file.
    ## /etc/apache2/mods-available/php7.conf
    #<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
  14. @m1st0 m1st0 created this gist Jul 18, 2015.
    108 changes: 108 additions & 0 deletions php7_build.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,108 @@
    #! /bin/bash
    ## PHP 7 Initial Compile ##

    ## Setup Ubuntu 15.04 ##
    # I like the speed of Apt-Fast. Will check for installs some other day.
    sudo apt-get install apt-fast
    # Some dependencies to install for PHP 7.
    sudo apt-get install libldap2-dev libldap-2.4-2 libtool-bin libzip-dev lbzip2 bzip2 re2c axps
    # PHP 7 does not recognize these without additional parameters or symlinks for Ldap..
    sudo ln -fs /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
    sudo ln -sf /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so

    # Obtain latest source
    git clone https://github.com/php/php-src
    cd php-src

    # Setup compile options for Kubuntu 15.04
    ./configure --prefix=/usr/local/php7 \
    --with-config-file-path=/etc/php7/apache2 \
    --with-config-file-scan-dir=/etc/php7/apache2/conf.d \
    --enable-mbstring \
    --enable-zip \
    --enable-bcmath \
    --enable-pcntl \
    --enable-ftp \
    --enable-exif \
    --enable-calendar \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-wddx \
    --with-curl \
    --with-mcrypt \
    --with-iconv \
    --with-gmp \
    --with-pspell \
    --with-gd \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr \
    --with-zlib-dir=/usr \
    --with-xpm-dir=/usr \
    --with-freetype-dir=/usr \
    --with-t1lib=/usr \
    --enable-gd-native-ttf \
    --enable-gd-jis-conv \
    --with-openssl \
    --with-pdo-mysql=/usr \
    --with-gettext=/usr \
    --with-zlib=/usr \
    --with-bz2=/usr \
    --with-recode=/usr \
    --with-apxs2=/usr/bin/apxs \
    --with-mysqli=/usr/bin/mysql_config \
    --with-ldap

    # Cleanup for previous failures.
    sudo make clean

    # Using as many threads as possible. Change as necessary. Will check in future for cores.
    sudo make -j 10

    # Install it accoridng to the configured path.
    sudo make install

    # It's own make script said to do this, but it didn't do much on my system.
    libtool --finish ./libs

    # Work on non-threaded version as compiled for now.
    sudo a2dismod mpm_worker
    sudo a2enmod mpm_prefork
    # Since it is built with axps2, it sets things up correctly.
    sudo a2enmod php7

    # Restart Apache if all went well.
    sudo systemctl restart apache2
    # View any errors on startup.
    sudo journalctl -xe

    # Update the paths on th system according to Ubuntu. Can be later removed and switched back.
    sudo update-alternatives --install /usr/bin/php php /usr/local/php7/bin/php 50 --slave /usr/share/man/man1/php.1.gz php.1.gz /usr/local/php7/php/man/man1/php.1

    ## To help enable Apache 2.4 use of PHP 7. Enable this after writing the file.
    ## /etc/apache2/mods-available/php7.conf
    #<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
    # SetHandler application/x-httpd-php
    #</FilesMatch>
    #<FilesMatch ".+\.phps$">
    # SetHandler application/x-httpd-php-source
    # # Deny access to raw php sources by default
    # # To re-enable it's recommended to enable access to the files
    # # only in specific virtual host or directory
    # Require all denied
    #</FilesMatch>
    # Deny access to files without filename (e.g. '.php')
    #<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    # Require all denied
    #</FilesMatch>
    #
    # Running PHP scripts in user directories is disabled by default
    #
    # To re-enable PHP in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<IfModule mod_userdir.c>
    # <Directory /home/*/public_html>
    # php_admin_flag engine Off
    # </Directory>
    #</IfModule>"