Hitesh Jethva
stderr
and stdout
logging, emergency restarts, and adaptive process spawning, which is useful for heavy-loaded sites. In fact, using Apache with PHP-FPM is one of the best stacks for hosting PHP applications, especially when it comes to performance.site1.your_domain
, will deploy PHP 7.0. The second, site2.your_domain
, will deploy PHP 7.2.A
record in our DNS settings: site1.your_domain
and site2.your_domain
.Ondrej PHP
repository to your system.apt-get
command to install software-properties-common
:software-properties-common
package provides the apt-add-repository
command-line utility, which you will use to add the ondrej/php
PPA (Personal Package Archive) repository.ondrej/php
repository to your system. The ondrej/php
PPA will have more up-to-date versions of PHP than the official Ubuntu repositories, and it will also allow you to install multiple versions of PHP in the same system:php7.0
, php7.0-fpm
, php7.0-mysql
, libapache2-mod-php7.0
, and libapache2-mod-fcgid
with the following commands:php7.0
is a metapackage used to run PHP applications.php7.0-fpm
provides the Fast Process Manager interpreter that runs as a daemon and receives Fast/CGI requests.php7.0-mysql
connects PHP to the MySQL database.libapahce2-mod-php7.0
provides the PHP module for the Apache webserver.libapache2-mod-fcgid
contains a mod_fcgid that starts a number of CGI program instances to handle concurrent requests.php7.2
, php7.2-fpm
, php7.2-mysql
, and libapache2-mod-php7.2
:php7.0-fpm
service:php7.0-fpm
service:php7.2-fpm
service:php7.2-fpm
service:actions
is used for executing CGI scripts based on media type or request method.fcgid
is a high performance alternative to mod_cgi
that starts a sufficient number of instances of the CGI program to handle concurrent requests.alias
provides for the mapping of different parts of the host filesystem in the document tree, and for URL redirection.proxy_fcgi
allows Apache to forward requests to PHP-FPM.site1.your_domain
and site2.your_domain
:www-data
user and www-data
group. To ensure that you have the correct ownership and permissions of your website root directories, execute the following commands:info.php
file inside each website root directory. This will display each website’s PHP version information. Begin with site1
:info.php
file you created to site2
:/etc/apache2/sites-available/000-default.conf
, you’ll create two new ones inside the directory /etc/apache2/sites-available/
.site1.your_domain
. Here you will direct Apache to render content using php7.0
:DocumentRoot
to your new directory and ServerAdmin
to an email that the your_domain
site administrator can access. You’ve also updated ServerName
, which establishes the base domain for this virtual host configuration, and you’ve added a SetHandler
directive to run PHP as a fastCGI process server.site2.your_domain
. You will specify this subdomain to deploy php7.2
:http://site1.your_domain
and http://site2.your_domain
. You will see two pages that look like this:site1.your_domain
deployed PHP version 7.0. The second indicates that site2.your_domain
deployed PHP version 7.2.info.php
files. Because they contain sensitive information about your server and are accessible to unauthorized users, they pose a security threat. To remove both files, run the following commands:sdtout
and stderr
. Alternatively, you could now secure your websites. To accomplish this, you can follow our tutorial on how to secure your sites with free TLS/SSL certificates from Let’s Encrypt.