Faruque Ahmed : MCP, MCSA, MCSE, MCTS, MCIT, CCNA, OCA, OCP, GCP
----------------install ---------------------
# apt install ca-certificates apt-transport-https software-properties-common lsb-release -y
# add-apt-repository ppa:ondrej/php -y
# add-apt-repository ppa:ondrej/php --yes# apt install php8.2 php8.2-fpm php8.2-cli
# systemctl restart php8.2-fpm
# apt install php8.2-{cli,fpm,curl,mysqlnd,gd,opcache,zip,intl,common,bcmath,imagick,xmlrpc,readline,memcached,redis,mbstring,apcu,xml,dom,memcache}
# apt install php8.2-xdebug php8.2-pcov php8.2-dev
# php8.2 -m
PHP 8.4, execute
$ sudo apt install libapache2-mod-php8.4 php8.4-fpm php8.4-mysql php8.4-xml php8.4-mbstring php8.4-curl -y
# php -v
Run the following command to install the required PHP extensions. PHP8.2 is fully supported in the 1.6 release.
# apt install php8.2-mysql
----------------------------------------
# apt -y install php-net-ldap2 php-net-ldap3 php-imagick php8.4-common php8.4-gd php8.4-imap php8.4-mysql php8.4-curl php8.4-zip php8.4-xml php8.4-mbstring php8.4-bz2 php8.4-intl php8.4-gmp php8.4-redis
RainLoop
apt install php php-fpm php-curl php-xml php-zip php-imap php-mbstring php-json php-mysql unzip -y
# apt install php8.4-mysql
# ALL
apt install -y php-mysql php-mbstring php-bcmath php-zip php-gd php-curl php-xml
# vi /etc/php/7.4/apache2/php.ini
# vi /etc/php/8.0/fpm/php.ini
# vi /etc/php/8.2/fpm/php.ini
We can modify PHP settings by editing the `php.ini` file. The file’s location depends on whether PHP is being used for the command line or a web server:
Command Line:
PHP 8.4: ‘/etc/php/8.4/cli/php.ini’
PHP 8.3: ‘/etc/php/8.3/cli/php.ini’
Web Server (Apache/Nginx):
PHP 8.4:
Apache: ‘/etc/php/8.4/apache2/php.ini’
Nginx (PHP-FPM): ‘/etc/php/8.4/fpm/php.ini’
PHP 8.3:
Apache: /etc/php/8.3/apache2/php.ini
Nginx (PHP-FPM): /etc/php/8.3/fpm/php.ini
To edit the ‘php.ini‘ file, use a text editor like `vi` or `vim`:
For PHP 8.4 (Command Line):
$ sudo vi /etc/php/8.4/cli/php.ini
For PHP 8.3 (Command Line):
$ sudo vi /etc/php/8.3/cli/php.ini
max_execution_time = 300
memory_limit = 512M;
post_max_size = 80M;
upload_max_filesize = 50M;
date.timezone = Asia/Dhaka
systemctl restart apache2
Configuring Nginx Server Block for PHP-FPM 8.2
Modify the Nginx server block to process PHP files. Add this to the relevant server blocks:
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
You can validate the syntax of your modified Nginx configuration using the following command:
sudo nginx -t
This command verifies the syntax of the configuration files and highlights any errors found. A successful output will look like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Once you’ve confirmed the syntax is correct, restart the Nginx service to apply the changes:
sudo systemctl restart nginx
As a final note, always ensure you check the version of PHP installed on your system. Use the following command to do this:
php --version