To install the latest stable version of PHP version 7 and all necessary modules, run:<\/p>\n
[user]$ sudo add-apt-repository ppa:ondrej\/php\r\n[user]$ sudo apt-get update\r\n[user]$ sudo apt-get -y install php7.0-fpm php7.0-cli php7.0-gd php7.0-mbstring php-pear \\\r\n php7.0-curl php7.0-dev php7.0-opcache php7.0-xml<\/pre>\nThe following PHP extensions are optional but recommended:<\/p>\n
APCu is the official replacement for the outdated APC extension. To install it, run the following commands:<\/p>\n
[user]$ sudo pecl install apcu\r\n[user]$ sudo sh -c \"echo extension=apcu.so > \/etc\/php\/7.0\/mods-available\/apcu.ini\"\r\n[user]$ sudo ln -s \/etc\/php\/7.0\/mods-available\/apcu.ini \/etc\/php\/7.0\/fpm\/conf.d\/20-apcu.ini\r\n[user]$ sudo ln -s \/etc\/php\/7.0\/mods-available\/apcu.ini \/etc\/php\/7.0\/cli\/conf.d\/20-apcu.ini\r\n[user]$ sudo service php7.0-fpm restart\r\n<\/pre>\nThe Yaml PHP Extension provides a wrapper to the LibYAML library and can dramatically increase performance. To install it, run the following commands:<\/p>\n
[user]$ sudo pecl install yaml-beta\r\n[user]$ sudo sh -c \"echo extension=yaml.so > \/etc\/php\/7.0\/mods-available\/yaml.ini\"\r\n[user]$ sudo ln -s \/etc\/php\/7.0\/mods-available\/yaml.ini \/etc\/php\/7.0\/fpm\/conf.d\/20-yaml.ini\r\n[user]$ sudo ln -s \/etc\/php\/7.0\/mods-available\/yaml.ini \/etc\/php\/7.0\/cli\/conf.d\/20-yaml.ini\r\n[user]$ sudo service php7.0-fpm restart\r\n<\/pre>\nComposer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.<\/p>\n
[user]$ curl -sS https:\/\/getcomposer.org\/installer | php\r\n[user]$ sudo mv composer.phar \/usr\/local\/bin\/composer<\/pre>\nCreate a new PHP-FPM pool for your user:<\/p>\n
[user]$ sudo nano \/etc\/php\/7.0\/fpm\/pool.d\/yourUser.conf\r\n[yourUser]\r\nuser = yourUser\r\ngroup = yourUser\r\nlisten = \/var\/run\/php-fpm-yourUser.sock\r\nlisten.owner = yourUser\r\nlisten.group = yourUser\r\nlisten.mode = 0666\r\npm = ondemand\r\npm.max_children = 5\r\npm.process_idle_timeout = 10s\r\npm.max_requests = 200\r\nchdir = \/\r\n<\/pre>\nDo not forget to change yourUser with your username.<\/p>\n
Restart PHP-FPM:<\/p>\n
[user]$ sudo service php7.0-fpm restart<\/pre>\n