Skip to main content
Version: Legacy

PHP Configuration

PHP is a popular programming language used for web development. To install the latest version of PHP & to configure it, please follow the steps mentioned below:

  1. Add a PPA (Personal Package Archive) for PHP 8.5 (Optional in most cases)

    sudo add-apt-repository ppa:ondrej/php
  2. Update the package repository

    sudo apt update -y
  3. Install PHP 8.5 & required modules

    sudo apt install php8.5 php8.5-fpm php8.5-redis php8.5-curl php8.5-mbstring php8.5-mysql php8.5-xml php8.5-zip -y
  4. Configure PHP-FPM

    We need to configure PHP-FPM (FastCGI Process Manager) to work with the Web Server. Edit the PHP-FPM configuration file using the following command:

    sudo nano /etc/php/8.5/fpm/pool.d/www.conf

    Find the following lines and uncomment them:

    listen.owner = www-data
    listen.group = www-data
    listen.mode = 0660

    Enable pm.max_requests

    This forces a worker to "retire" and restart after handling 500 requests. This is the ultimate safety net for memory leaks—it ensures that even if Guzzle or a third-party library "forgets" to release memory, the process eventually resets and clears the RAM.

    pm.max_requests = 500

PHP.ini Configuration

  1. Edit the PHP configuration file using the following command:

    sudo nano /etc/php/8.5/fpm/php.ini
  2. Update the following values:

    memory_limit = 256M
    upload_max_filesize = 100M
    post_max_size = 100M
    max_execution_time = 360
    max_input_time = 360
  3. Enable Extensions:

    extension=bz2
    extension=curl
    extension=exif
    extension=ftp
    extension=fileinfo
    extension=gd
    extension=gettext
    extension=intl
    extension=ldap
    extension=mbstring
    extension=mysqli
    extension=openssl
    extension=pdo_mysql

    extension=soap
    extension=zip

Composer Installation

Install Composer using the following command:

sudo apt install composer

i18n Setup

  1. Install Gettext using the following command:

    sudo apt-get install gettext
  2. Add Locales using the following command:

    sudo locale-gen ml_IN.UTF-8
    sudo update-locale
  3. Restart the PHP-FPM service using the following command:

    sudo systemctl restart php8.5-fpm