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:
- Ubuntu
-
Add a
PPA(Personal Package Archive) for PHP 8.5 (Optional in most cases)sudo add-apt-repository ppa:ondrej/php -
Update the package repository
sudo apt update -y -
Install
PHP 8.5& required modulessudo 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 -
Configure
PHP-FPMWe 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.confFind the following lines and uncomment them:
listen.owner = www-datalisten.group = www-datalisten.mode = 0660Enable
pm.max_requestsThis 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
-
Edit the PHP configuration file using the following command:
sudo nano /etc/php/8.5/fpm/php.ini -
Update the following values:
memory_limit = 256Mupload_max_filesize = 100Mpost_max_size = 100Mmax_execution_time = 360max_input_time = 360 -
Enable Extensions:
extension=bz2extension=curlextension=exifextension=ftpextension=fileinfoextension=gdextension=gettextextension=intlextension=ldapextension=mbstringextension=mysqliextension=opensslextension=pdo_mysqlextension=soapextension=zip
Composer Installation
Install Composer using the following command:
sudo apt install composer
i18n Setup
-
Install Gettext using the following command:
sudo apt-get install gettext -
Add Locales using the following command:
sudo locale-gen ml_IN.UTF-8sudo update-locale -
Restart the PHP-FPM service using the following command:
sudo systemctl restart php8.5-fpm