Last active
November 6, 2017 03:56
-
-
Save guilhermewop/305cc6bd2592962248ecffdcadd92da3 to your computer and use it in GitHub Desktop.
High-performance PHP 7.1 (with php-fpm and mysqlnd) on Apache 2.4 worker (with mod_proxy_fcgi) on Ubuntu
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
sudo apt-get update -y && apt-get upgrade -y | |
sudo apt-get install vim \ | |
git \ | |
tree \ | |
libldap2-dev \ | |
libldap-2.4-2 \ | |
libtool-bin \ | |
libzip-dev \ | |
lbzip2 \ | |
libxml2-dev \ | |
bzip2 \ | |
re2c \ | |
libbz2-dev \ | |
libjpeg-dev \ | |
libxpm-dev \ | |
libxpm-dev \ | |
libgmp-dev \ | |
libgmp3-dev \ | |
libmcrypt-dev \ | |
libpspell-dev \ | |
librecode-dev \ | |
libssl-dev \ | |
libcurl4-gnutls-dev \ | |
libpng12-dev \ | |
libfreetype6-dev \ | |
libreadline-dev \ | |
apache2-dev \ | |
apache2-bin \ | |
apache2 | |
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 | |
# PHP 7 | |
cd /tmp && wget http://br2.php.net/get/php-7.1.0.tar.gz/from/this/mirror -O php-7.1.0.tar.gz | |
tar -vzxf php-7.1.0.tar.gz | |
sudo mkdir /usr/local/php7 | |
./buildconf --force | |
./configure --prefix=/usr/local/php7 \ | |
--with-config-file-path=/usr/local/php7/etc \ | |
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \ | |
--enable-bcmath \ | |
--enable-maintainer-zts | |
--with-bz2 \ | |
--with-curl \ | |
--enable-filter \ | |
--enable-fpm \ | |
--with-gd \ | |
--enable-gd-native-ttf \ | |
--with-freetype-dir \ | |
--with-jpeg-dir \ | |
--with-png-dir \ | |
--enable-intl \ | |
--enable-mbstring \ | |
--with-mcrypt \ | |
--enable-mysqlnd \ | |
--with-mysql-sock=/var/lib/mysql/mysql.sock \ | |
--with-mysqli=mysqlnd \ | |
--with-pdo-mysql=mysqlnd \ | |
--with-pdo-sqlite \ | |
--disable-phpdbg \ | |
--disable-phpdbg-webhelper \ | |
--enable-opcache \ | |
--with-openssl \ | |
--enable-simplexml \ | |
--with-sqlite3 \ | |
--enable-xmlreader \ | |
--enable-xmlwriter \ | |
--enable-zip \ | |
--with-zlib \ | |
--with-ldap \ | |
--with-gettext \ | |
--with-mcrypt \ | |
--with-iconv \ | |
--enable-ftp \ | |
--enable-pcntl \ | |
--with-readline \ | |
--enable-exif \ | |
--with-xdebug | |
# install | |
sudo make clean | |
sudo make -j `cat /proc/cpuinfo | grep processor | wc -l` | |
sudo make install | |
libtool --finish ./libs | |
sudo mkdir /usr/local/php7/etc/conf.d | |
sudo cp -v ./php.ini-production /usr/local/php7/lib/php.ini | |
sudo cp -v ./sapi/fpm/www.conf /usr/local/php7/etc/php-fpm.d/www.conf | |
sudo cp -v ./sapi/fpm/php-fpm.conf /usr/local/php7/etc/php-fpm.conf | |
sudo vim /usr/local/php7/etc/conf.d/modules.ini | |
# Zend OPcache | |
zend_extension=opcache.so | |
sudo vim /usr/local/php7/etc/php-fpm.d/www.conf | |
user = <username> | |
group = <usergroup> | |
listen = /var/run/php-fpm.sock | |
listen.owner = <webserver-username> | |
listen.group = <webserver-password> | |
# Apache modules | |
sudo a2dismod mpm_event | |
sudo a2enmod mpm_worker | |
sudo a2enmod proxy_fcgi | |
# Apache config /etc/apache2/apache2.conf | |
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php-fpm.sock|fcgi://127.0.0.1:9000/var/www/html/$1 | |
sudo service apache2 restart | |
# References | |
# http://php.net/releases/ | |
# http://php.net/manual/pt_BR/install.fpm.install.php | |
# http://php.net/manual/pt_BR/mysqlnd.install.php | |
# https://php-fpm.org/ | |
# https://httpd.apache.org/docs/2.4/mod/worker.html | |
# https://wiki.apache.org/httpd/PHP-FPM | |
# http://www.shaunfreeman.name/compiling-php-7-on-centos/ | |
# https://gist.github.com/m1st0/1c41b8d0eb42169ce71a | |
# http://blog.chrismeller.com/configuring-and-optimizing-php-fpm-and-nginx-on-ubuntu-or-debian |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment