Ubuntu 16.04 Xenial with multiple sites running HTTP2 and PHP7 using Let’s Encrypt for free ssl certificate

You want a web server running HTTP2 and PHP7 and want to use Let´s Encrypt to get a free ssl certificate? This tutorial covers the creation of such a server using the latest Ubuntu 16.04 LTS Xenial Xerus and nginx.

Let’s assume you have running a fresh installed Ubuntu 16.04 LTS server. You want to host two websites on this server, blog1.org and blog2.org, and the A-Records of both domains including the www.-prefix already point at that server.

So, let’s get started.


Install prequisites:

nginx and PHP 7

Install nginx and PHP:

After that, nginx and PHP7 are installed and it should look like this:

Now we create the folder structure for our hostings:

In the config directory, the nginx config for that hosting will reside. The html-folder will contain our PHP application, the access- and error-logs will be in the logs-directory.

Create /var/www/vhosts/blog1.org/conf/nginx.conf with:

And /var/www/vhosts/blog2.org/conf/nginx.conf with:

Next we activate our new virtual hosts:

Restart our webserver:

Congratulations! Your nginx is running with PHP 7!

To prove what I’m saying, you can create a phpinfo.php-file with the following command:

When you open http://blog1.org/phpinfo.php in your browser window, you should see a screen like this:

output of phpinfo()

Page 2: how to create the Let´s Encrypt-certificates and configure the virtual hosts.

Leave a Reply

Your email address will not be published. Required fields are marked *