Last active
April 27, 2016 09:50
-
-
Save barbotkin/44b1240d80dda1d1618c to your computer and use it in GitHub Desktop.
Install php7 in Linux (Mint/Ubuntu) LAMP Server
This file contains hidden or 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 | |
# PHP 7 Initial Compile (Install php7 Linux (Mint/Ubuntu) LAMP) ## | |
# Author: Roman Barbotkin | |
# Fixed error and simplified, I tested for Linux Mint 7.3. | |
# Install: just run this file, it will do everything for you :) | |
# If make error uncoments 2 line. | |
#sudo apt-get purge make | |
#sudo apt-get install make | |
# Fix error gmp.h | |
# sudo rm /usr/include/gmp.h | |
# sudo ln -sf /usr/include/i386-linux-gnu/gmp.h /usr/include/gmp.h | |
sudo apt-get install build-essential libt1-dev bison libbz2-dev libjpeg62-dev libpng12-dev libfreetype6-dev libgmp3-dev libmcrypt-dev libmysqlclient-dev libpspell-dev librecode-dev apache2-dev git | |
# Obtain latest source | |
git clone https://github.com/php/php-src | |
cd php-src | |
./buildconf | |
# Configure php7 source code | |
./configure \ | |
--prefix=/usr \ | |
--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=/usr/include/x86_64-linux-gnu \ | |
--with-pspell \ | |
--with-gd \ | |
--with-jpeg-dir=/usr \ | |
--with-png-dir=/usr \ | |
--with-zlib-dir=/usr \ | |
--with-xpm-dir=/usr \ | |
--with-freetype-dir=/usr \ | |
--enable-gd-native-ttf \ | |
--enable-gd-jis-conv \ | |
--with-openssl \ | |
--with-pdo-mysql=/usr \ | |
--with-gettext=/usr \ | |
--with-zlib=/usr \ | |
--with-bz2=/bin \ | |
--with-recode=/usr \ | |
--with-mysqli=/usr/bin/mysql_config \ | |
--with-apxs2 \ | |
--enable-dtrace | |
# PHP 7 does not recognize these without additional parameters or symlinks for | |
sudo ln -sf /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h | |
sudo make | |
sudo make test | |
# 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 | |
sudo a2dismod php5 | |
sudo a2enmod php7 | |
# Restart Apache if all went well. | |
sudo service apache2 start | |
cat <<EOF >> php7.conf | |
<FilesMatch ".+\.ph(p[345]?|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 | |
Order Deny,Allow | |
Deny from all | |
</FilesMatch> | |
# Deny access to files without filename (e.g. '.php') | |
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$"> | |
Order Deny,Allow | |
Deny from all | |
</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> | |
EOF | |
sudo cp php7.conf /etc/apache2/mods-available | |
sudo service apache2 start | |
php -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment