Ubuntu is derived from Debian, so the process is the same for both Ubuntu and Debian. We will use Debian 8 Jessie and Ubuntu 14.04 Server LTS. The same process can be applied to desktop versions for both.
First, add the repositories for both Debian and Ubuntu.
As of the time we're writing this book, Debian does not provide an official repository for PHP 7. So, for Debian, we will use dotdeb repositories to install NGINX and PHP 7. Perform the following steps:
/etc/apt/sources.list file and add the following two lines at the end of the file:deb http://packages.dotdeb.org jessie all deb-src http://packages.dotdeb.org jessie all
wget https://www.dotdeb.org/dotdeb.gpg sudo apt-key add dotdeb.gpg sudo apt-get update
The first two commands will add dotdeb repo to Debian and the last command will refresh the cache for sources.
As of the time of writing this book, Ubuntu also does not provide PHP 7 in their official repos, so we will use a third-party repo for the PHP 7 installation. Perform the following steps:
sudo add-apt-repository ppa:ondrej/php sudo apt-get update
sudo apt-get install nginx

The following is a list of three useful NGINX commands:
service nginx start: This starts the NGINX serverservice nginx restart: This restarts the NGINX serverservice nginx stop: This stops the NGINX server
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql php7.0-mcrypt php7.0-cli
This will install PHP 7 along with the other modules mentioned. Also, we installed PHP Cli for the command-line purpose. To verify whether PHP 7 is properly installed, issue the following command in the terminal:
php –v

/etc/nginx/sites-available/default to /etc/nginx/sites-available/www.packt.com.conf using the following command in the terminal:cd /etc/nginx/sites-available sudo cp default www.packt.com.conf sudo ln –s /etc/nginx /sites-available/www.packt.com.conf /etc/ nginx/sites-enabled/www.packt.com.conf
First, we copied the default configuration file, created another virtual host configuration file, www.packt.com.conf, and then created a symbolic link file to this virtual host file in the sites-enabled folder.
/etc/nginx/sites-available/www.packt.com.conf file and add or edit the highlighted code, as shown here:server {
server_name your_ip:80;
root /var/www/html;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}The preceding configuration is not a complete configuration file. We copied only those configuration options that are important and that we may want to change.
In the preceding code, our webroot path is /var/www/html, where our PHP files and other application files will be placed. In the index config option, add index.php so that if no file is provided in the URL, NGINX can look for and parse index.php.
We added a location block for PHP that includes a fastcgi_pass option, which has a path to the PHP7 FPM socket. Here, our PHP runs on a Unix socket, which is faster than that of TCP/IP.
info.php file at the root of the webroot folder and place the following code in it:<?php phpinfo(); ?>
server_ip/info.php, and if you see a PHP configuration page, then congratulations! PHP and NGINX are both properly configured.Now, let's install Percona Server. Percona Server is a fork of MySQL and is optimized for high performance. We will read more about Percona Server in Chapter 3, Increasing PHP 7 Application Performance. Now, let's install Percona Server on Debian/Ubuntu via the following steps:
sudo wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb sudo dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb
The first command will download the repo packages from the Percona repo. The second command will install the downloaded packages and will create a percona-release.list file at /etc/apt/sources.list.d/percona-release.list.
sudo apt-get update
sudo apt-get install percona-server-5.5
The installation process will start. It will take a while to download it.
During the installation, the password for the root user will be asked, as shown in the following screenshot:

It is optional but recommended to enter the password. After entering the password, re-enter the password on the next screen. The installation process will continue.
mysql –-version
It will display the version of Percona Server. As mentioned before, Percona Server is a fork of MySQL, so all the same MySQL commands, queries, and settings can be used.