FedoraRHEL Based

How To Install PHP on Fedora 39

Install PHP on Fedora 39

In this tutorial, we will show you how to install PHP on Fedora 39. PHP 8.3 stands as a testament to PHP’s commitment to innovation, offering a range of improvements and new features. Enhanced type system, JIT compiler advancements, and better error handling make it a compelling upgrade. Developers and system administrators find in PHP 8.3 a robust platform with improved performance and security.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the PHP scripting language on a Fedora 39.

Prerequisites

Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You’ll need an active internet connection to download PHP and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PHP on Fedora 39

Step 1. Before you dive into the installation, ensure that your Fedora 39 system is up to date. Start by refreshing your system repositories:

sudo dnf clean all
sudo dnf update

Step 2. Enabling the Remi Repository.

Begin by installing the Remi repository RPM package. Execute the following command to enable the PHP 8.3 repository:

sudo dnf install https://rpms.remirepo.net/fedora/remi-release-39.rpm

Ensure the repository is enabled by default:

sudo dnf module reset php
sudo dnf module enable php:remi-8.3

Confirm the repository configuration using:

sudo dnf list php\*

This should display the available PHP packages, affirming the successful repository addition.

Step 3. Installing PHP on Fedora 39.

Now install PHP 8.3 and the necessary modules:

sudo dnf install php

For additional modules, use the following format:

sudo dnf install php-module_name

For example:

sudo dnf install php-cli php-fpm php-curl php-mysqlnd php-gd php-opcache php-zip php-intl php-common php-bcmath php-imap php-imagick php-xmlrpc php-json php-readline php-memcached php-redis php-mbstring php-apcu php-xml php-dom php-redis php-memcached php-memcache

After installation and configuration, it’s vital to ensure that PHP 8.3 is functioning as expected. First, verify the installed PHP version:

php -v

Now, create a simple PHP script to confirm that PHP is correctly configured. For example, create a file named ‘test.php‘ in your web server’s document root directory with the following content:

<?php
phpinfo();
?>

Access the script through your web browser by navigating to ‘http://your_server_ip/test.php‘. You should see a comprehensive PHP information page.

Step 4. Configuration and Optimization.

To ensure PHP 8.3 performs optimally on your Fedora 39 system, you might need to make some configuration adjustments. The primary configuration file for PHP is php.ini. You can locate it at /etc/php.ini.

You can tweak various settings within php.ini to match your specific requirements. For instance, you can increase the maximum upload file size, set time zones, and fine-tune memory limits. Here’s an example of increasing the maximum upload file size:

sudo nano /etc/php.ini

Find the upload_max_filesize parameter and modify it as per your requirements:

upload_max_filesize = 32M

Remember to restart the Apache web server for changes to take effect:

sudo systemctl restart httpd

Step 5. Troubleshooting and Common Issues.

Installation and configuration can sometimes present challenges. Here are some common issues and how to resolve them:

  • PHP Not Working

If PHP isn’t functioning as expected, review the installation steps and ensure that the Remi repository is correctly configured. Restart the web server if necessary.

  • Extensions Issues

If you encounter problems with PHP extensions, double-check that you’ve installed them correctly and that they’re enabled in ‘php.ini‘.

  • Permissions Problems

Ensure that your web server has the necessary permissions to read PHP files and execute scripts.

  • Error Logs

Check PHP error logs for detailed information on any problems:

tail -f /var/log/php-fpm/error.log

Congratulations! You have successfully installed PHP 8.3. Thanks for using this tutorial for installing the PHP popular general-purpose scripting language on your Fedora 39 system. For additional Apache or useful information, we recommend you check the official PHP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button