Docker volumes vs bind mounts

By default a docker container won’t store any persistent data, so anything that we write to its writable layer won’t be available once we stop it.When running Docker containers we might be interested in persisting certain data. This can be achieved by using either volumes or bind mounts. Below I’m describing main differences between the two.

Bind mounts are directories on the host filesystem mounted onto a Docker container. These can be modified outside of Docker.

read more →

Different ways of running PHP on an Apache server

When the server receives a request from the user it can serve the file directly, but sometimes it needs to translate the code using the appropriate application. Otherwise it would be showing the users the source code of the website. A server like Apache needs to be configured to handle specific content with an appropriate application like PHP.

A common set of rules of passing the information between the server and the application is the Common Gateway Interface. This standard lets programmers write applications in different languages that can plug into the server and interact with it. The interface guarantees consistency of data passed between the server and the application. An alternative to a CGI application is Microsoft’s Active Server Page (ASP).

read more →

Finding out PHP server interface

There are many ways of executing a PHP script. For example you might run it directly from a command line:

php <name_of_the_script>

Other option, readily available for tesing since PHP 5.4, is to spin up the internal PHP server and see the result in a browser:

php -S localhost:3000

If you create a simple page with the function php_sapi_name you will be able to check out the interface that is being used to run the script.

read more →

Installing Let’s Encrypt SSL certificate

Https has become a standard for websites and there’s no excuse not to have it enabled on the website, especially that it’s now possible for free.

Making your website more secure with a free Let’s Encrypt certificate is very easy with Certbot.

The prerequisites are to have SSH access to your server that is already online and serving the site over http. In the example I’m setting up the certificates with Apache.

read more →