PHP is a popular programming language that is widely used for web development. With the release of PHP 8.3, there are numerous new features and improvements that make it an attractive option for developers. If you are using Ubuntu 24.04 as your server operating system and want to install PHP 8.3 with either Apache or Nginx, this guide will walk you through the process.
There are two main ways to install PHP 8.3 on Ubuntu 24.04. You can either compile it from source or use a package manager like apt. In this guide, we will focus on using the apt package manager as it is the easiest and most convenient method for most users.
- Update your system:
Before installing PHP 8.3, it is always a good practice to update your system to ensure that you have the latest packages and security updates. You can do this by running the following commands in your terminal:
sudo apt update
sudo apt upgrade
- Add Ondřej Surý’s PHP PPA:
Ondřej Surý maintains a Personal Package Archive (PPA) that contains the latest versions of PHP for Ubuntu. You can add this PPA to your system by running the following command:
sudo add-apt-repository ppa:ondrej/php
- Install PHP 8.3:
Now that you have added the PHP PPA, you can install PHP 8.3 by running the following command:
sudo apt install php8.3
During the installation process, you may be prompted to confirm the installation and dependencies. Simply type ‘Y’ and press Enter to proceed.
- Verify the installation:
Once the installation is complete, you can verify that PHP 8.3 is installed correctly by running the following command:
php -v
You should see output that indicates the PHP version (8.3) and some additional information about the installation.
- Configure PHP with Apache or Nginx:
If you are using Apache as your web server, you will need to enable the PHP module by running the following command:
sudo a2enmod php8.3
For Nginx users, you can configure PHP by installing the PHP-FPM package and integrating it with Nginx. You can do this by running the following command:
sudo apt install php8.3-fpm
After installing PHP-FPM, you will need to configure Nginx to work with PHP-FPM. You can find detailed instructions on how to do this in the official Nginx documentation.
- Restart your web server:
After configuring PHP with either Apache or Nginx, you will need to restart your web server to apply the changes. You can do this by running the following command:
sudo systemctl restart apache2 OR sudo systemctl restart nginx
Congratulations! You have successfully installed PHP 8.3 on Ubuntu 24.04 with either Apache or Nginx. You can now start developing and hosting your PHP applications using the latest version of PHP.
In conclusion, installing PHP 8.3 on Ubuntu 24.04 is a straightforward process that can be completed in just a few simple steps. By following this guide, you can take advantage of the new features and improvements in PHP 8.3 for your web development projects.