This guide intends to teach you to Install and Run PHP 8.3 which is the latest version of PHP on Linux Mint 21 by using Apache and Nginx Modules. As you know, PHP is a popular server-side scripting language that is used to develop Static websites or Dynamic websites or Web applications.
Note: To get more information about the newly released PHP version, you can visit this guide on Upcoming PHP 8.3 and New Improvements.
In this guide, we use Linux Mint 21.2 which is the latest version of Linux Mint. To get installation steps, you can check this guide on Linux Mint 21 Cinnamon Setup on VMware Workstation.
Steps To Install and Run PHP 8.3 on Linux Mint 21
Before you start your PHP installation, you must have access to your Linux Mint server as a non-root user with sudo privileges. Now proceed to the following steps to complete this guide.
Step 1 – Enable PPA Repository For PHP on Linux Mint 21
First, you must install the required packages and add the PPA repository for PHP installation in Linux Mint. To do this, you can run the following commands:
# sudo apt install software-properties-common -y
# sudo add-apt-repository ppa:ondrej/php -y
When you are done, run the system update and upgrade with the command below:
sudo apt update && sudo apt upgrade -y
Step 2 – Install PHP 8.3 with Apache on Mint 21
At this point, you can install PHP 8.3 for the Apache module by using the command below:
sudo apt install php8.3 libapache2-mod-php8.3 -y
Then, restart Apache to apply the changes:
sudo systemctl restart apache2
Also, you can install Apache with the PHP-FPM module. To do this, use the command below:
sudo apt install php8.3-fpm libapache2-mod-fcgid
Step 3 – Enable PHP-FPM For Apache on Mint 21
As you may know, PHP-FPM is not enabled for Apache. To enable it, you must run the following command:
sudo a2enmod proxy_fcgi setenvif && sudo a2enconf php8.3-fpm
Then, apply the changes by restarting Apache:
sudo systemctl restart apache2
Now you can verify your PHP-FPM is active and running in Linux Mint 21:
sudo systemctl status php8.3-fpm
In your output, you will see:
Next, verify your PHP 8.3 installation on Linux Mint 21 by checking its version:
php --version
Step 4 – Install PHP 8.3 with Nginx on Mint 21
If you plan to use Nginx with PHP, you can use the command below:
sudo apt install php8.3 php8.3-fpm php8.3-cli -y
Then, verify your PHP-FPM is enabled on your server with the command below:
sudo systemctl status php8.3-fpm
In your output, you will see:
Also, you need to edit your Nginx server block and add the example below for Nginx to process the PHP files on Linux Mint 21.
server {
# … some other code
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
Test Nginx to make sure you have no errors with the adjustments made with the code above; enter the following command:
sudo nginx -t
Then, restart Nginx to apply the changes:
sudo systemctl restart nginx
php --version
Conclusion
At this point, you have learned to Install and Run PHP 8.3 with Apache and Nginx modules on Linux Mint 21. PHP 8.3 is the latest stable release of PHP that you can use on your server. Hope you enjoy it. If you need any help, please comment for us.
Install the Latest WineHQ on Linux Mint 21
Installing Chrome in Linux Mint 21 Using Terminal