Last week in this article, we described how the combination of Apache and Nginx is structured in Timeweb. We are very grateful to our readers for their questions and active discussion! Today, we're explaining how to implement multiple PHP versions on a single server and why we guarantee data security for our clients.

Virtual hosting (Shared hosting) implies that multiple client accounts are hosted on a single server. One client's account typically has several websites. These websites operate on both ready-made CMS (like Bitrix) and custom ones. Thus, the technical requirements for all systems differ, so it is necessary to manage multiple PHP versions within a single server.
We use Nginx as the main web server: it handles all incoming connections and serves static content. Other requests are proxied to the Apache web server. This is where the magic begins: a separate instance of Apache is launched for each PHP version, listening on a specific port. This port is specified in the virtual host configuration for the client's site.
You can read more about the operation of the Shared scheme in .

Shared scheme
It's important to note that we install PHP packages for different versions because usually all distributions contain only one PHP version.
Safety first!
One of the main objectives of virtual hosting is to ensure the security of client data. Various accounts, while on the same server, are independent. How does this work?
Website files are stored in the users' home directories, and the necessary paths are specified in the virtual host configurations of the web servers. It is crucial that the web servers, Nginx and Apache, have access to the final files of a specific client since the web server runs only under one user.
For Nginx, a security patch developed by the Timeweb team is used: this patch changes the user to the one specified in the web server's configuration file.
Other hosting providers may solve this issue, for instance, through manipulation with extended filesystem rights (ACL).
Apache operates using a multiprocess module . It allows each VirtualHost to run with its own user identifier and group ID.

Thus, thanks to the operations described above, we create a secure, isolated environment for each client. At the same time, we also address the scalability challenges for Shared hosting.
You can read about how the combination of Apache and Nginx is implemented in our article. Additionally, an alternative configuration via the Dedicated scheme is also described there.
If you have any questions for our experts, feel free to leave a comment. We will do our best to respond to everything or provide a more detailed solution in upcoming articles.
Source: habr.com
