Project

General

Profile

Actions

Running php-fpm with next cloud

For hosting a Nextcloud instance, using PHP-FPM is generally recommended for better performance and scalability. Nextcloud is a complex web application that requires efficient handling of file operations, user authentication, and other resource-intensive tasks. PHP-FPM's process management capabilities make it a suitable choice for running Nextcloud and handling the demands of concurrent user access.

Here are a few reasons why using PHP-FPM is a good choice for hosting Nextcloud:

Concurrency Handling: Nextcloud can experience simultaneous user requests, especially in multi-user environments. PHP-FPM's process pooling and efficient request handling are beneficial in managing these concurrent requests without creating excessive resource overhead.

Resource Management: PHP-FPM allows you to allocate resources (such as memory and CPU) to the PHP processes more effectively. This separation from the web server enables finer control over resource distribution, enhancing the overall performance of Nextcloud.

Scalability: If you anticipate growth in the number of users or data volume, PHP-FPM's scalability capabilities will help you handle increased traffic and usage without sacrificing performance.

Stability: PHP-FPM's process isolation can contribute to the stability of your Nextcloud instance. If one PHP process encounters an issue, it's less likely to affect other processes, minimizing the risk of downtime.

FastCGI Protocol: PHP-FPM uses the FastCGI protocol, which is specifically designed for efficient communication between web servers and scripting engines. This protocol can improve the overall speed and responsiveness of Nextcloud.

Tuning: PHP-FPM provides various configuration options that can be fine-tuned to match the requirements of your Nextcloud installation, optimizing performance and resource usage.

That said, while using PHP-FPM is generally recommended, it's also important to consider other aspects of your server setup, such as hardware resources, web server (e.g., Apache or Nginx) configuration, database performance, and Nextcloud-specific settings. Properly configuring and optimizing your entire server stack is crucial for achieving the best performance and user experience with Nextcloud.


Install PHP-FPM for PHP 8.1:

Install PHP-FPM for PHP 8.1 on your server.

sudo apt update
sudo apt install php8.1-fpm

Start and Enable PHP-FPM:
Once PHP-FPM is installed, start the service and enable it to start on boot:

sudo systemctl start php8.1-fpm
sudo systemctl enable php8.1-fpm

Edit Apache Virtual Host Configuration:

Open your Apache virtual host configuration (/etc/apache2/sites-available/next.conf).
Add the following lines within the <VirtualHost> section to handle PHP files with PHP-FPM:

sudo nano /etc/apache2/sites-available/next.conf
<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost" 
</FilesMatch>

Save and Exit:

Save the changes and exit the text editor.

Restart Services:
After making changes, restart both Apache and PHP-FPM services:

Ensure that the Apache proxy_fcgi module is enabled:

sudo a2enmod proxy_fcgi
sudo systemctl restart apache2
sudo systemctl restart php8.1-fpm

*NOTE: You will need to update the php.ini found in the fpm folder

Clear Browser Cache:
Clear your browser cache to ensure you're not viewing a cached version of the page.

Updated by Gareth Eaton 9 months ago · 3 revisions