Easy PHP container customization with Docker

Started by lovtzova, Aug 07, 2022, 06:27 AM

Previous topic - Next topic

lovtzovaTopic starter

Have you ever found yourself with a couple of half-forgotten projects running on modern software and not wanting to maintain a separate machine for them? This is a common problem, but the hosting company support service is here to help. One script that has proven useful is a PHP installer for VestaCP that takes only a few minutes to add the required version of PHP.



The script installs docker via a unified installer and creates a template for Vesta and two service files, docker.httpd and docker.php.56. The PHP versions available through this solution are 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 and 7.3.

Services will install/update images, which may take some time on the first launch or on restarting if updates are available. PHP runs as www-data, all directories will be appropriately set up, and the script creates a directory to store configuration files.

The installation takes up roughly 800 Mb for the docker itself and around 400 Mb for images. The performance boost can range from 1.5 to 2 times higher when using the VestaCP + Docker bundle compared to using a similar version of PHP as an Apache module.

For those installing on a single-core processor, there's a slightly different process. You'll need to manually edit a file and restart the docker, then switch to the desired PHP version.

The scheme of work for this solution is as follows: Nginx -> Apache in a container -> php-fpm in a container. Apache is running on port 9080, so the script edits the nginx configuration. PHP runs on 9000+version, i.e., 9056, 9070, 9072, etc.

To add modules or packages to the container, a Dockerfile can be created with the necessary content and run using the docker build command. Alternatively, PHP modules can be installed using scripts included in the container.

To use this solution, you would need to modify the service file to ensure that the local image is launched instead of a newly downloaded one from DockerHub. Service files can be found in /etc/systemd/system/.

If this solution is useful to you, the author encourages feedback.
  •  

JustinC

It has been over two years since Vesta was last updated, and there are several unpatched vulnerabilities. With more than three hundred open issues on Github and the lack of support for Ubuntu 20 and Debian 10, it's starting to seem like Vesta is no longer a suitable choice for use as a panel.

It's important to consider alternative solutions that offer better functionality and security for server management. There are now several popular alternatives available that provide robust features and regular updates to ensure optimal performance. Keeping up-to-date with the latest solutions can help ensure the best possible performance and security for your servers.
  •  

seoguy

When using Nginx in PHP-FPM, we lose the ability to use .htaccess files and require custom Nginx configurations for each site. If you're interested in using Nginx+PHP-FPM, consider exploring ISPConfig - a free hosting control panel with more features than VestaCP.

It's worth noting that this solution should be reserved for supporting older projects, in which case there may be an extensive history of renaming website sections, different subdomains in various folders, and other complex configurations stored in the same .htaccess file. For newer projects, there are likely more effective solutions available that allow for greater flexibility and ease of use.
  •  
    The following users thanked this post: Sevad

Nibintono

The PHP installer script installs Docker via a unified installer and creates a template for Vesta, as well as two service files: docker.httpd and docker.php.56. This allows you to work with PHP versions ranging from 5.2 to 7.3. The installation process takes up around 800 Mb for Docker itself and approximately 400 Mb for images.

With this solution, PHP runs as www-data, and all directories are appropriately set up. The script also creates a directory to store configuration files. The performance boost can range from 1.5 to 2 times higher when using the VestaCP + Docker bundle compared to using a similar version of PHP as an Apache module.

For those with a single-core processor, there's a slightly different process involving manual file editing and docker restart to switch to the desired PHP version. The scheme of work involves Nginx directing to Apache in a container, with php-fpm also in a container. To add modules or packages to the container, you can create a Dockerfile with the necessary content and run it using the docker build command.

To use this solution effectively, you'll need to modify the service file to ensure that the local image is launched instead of a newly downloaded one from DockerHub. The service files can be found in /etc/systemd/system/. It's worth noting that the author encourages feedback on the solution.


The PHP installer for VestaCP with Docker integration aims to address the challenge of managing multiple projects with different PHP versions without the need for separate hardware. The flexibility to work with PHP versions ranging from 5.2 to 7.3, along with the performance benefits compared to using similar versions of PHP as Apache modules, makes this solution a compelling option.

The approach of running Nginx directing to Apache in a container, with php-fpm also in a container, provides a modular and scalable architecture for hosting multiple projects. Additionally, the ability to add modules or packages to the container using Dockerfile and docker build commands adds further customization options.

For those with single-core processors, the slightly different process of manually editing files and restarting Docker to switch PHP versions ensures compatibility even with older hardware configurations.

The script's emphasis on creating a directory to store configuration files and encouraging feedback from users indicates a commitment to enhancing the solution based on practical use cases and user input.

In conclusion, the PHP installer for VestaCP with Docker integration offers a comprehensive and efficient solution for maintaining multiple projects with different PHP versions without the need for separate hardware. It's important to thoroughly test the setup with your specific projects and provide feedback to the author to further improve the solution.
  •