With PHP 8.x version stream out, it is important for Linux users such as those under AlmaLinux to quickly adapt to this new version change due to the feature improvements associated with it. Show
PHP 8.x boasts of remarkable features and feature improvements such as Union Types, JIT (Just in Time) compiler support, the NullSafe Operator, Named Arguments, Attributes, Match Expression, Constructor Property Promotion, Throw Expression, and Inheritance with Private Methods. AlmaLinux being a free, open-source, and community-supported Linux distribution makes it a perfect candidate for PHP 8.x installation. This open-source server-side scripting language has a lot of contributive footprint in generating dynamic web pages towards the creation of performant web applications. PrerequisitesEnsure that you are a root/sudoer user of the AlmaLinux operating system you are using. We can now begin the article walk-through on installing and configuring PHP 8.x on AlmaLinux operating system. Installing PHP 8 on AlmaLinuxYour AlmaLinux operating system needs to be up-to-date for the best performance. $ sudo dnf update && sudo dnf upgrade -y There is no direct way of installing PHP 8.x on AlmaLinux without going through the EPEL and Remi repositories. This repo makes it possible to not only install PHP’s latest version release but also keep track of future version releases. You, therefore, do not have to worry about the PHP version you need to use on your web application projects. $ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y $ sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm In order for AlmaLinux to recognize the addition of repositories, you need to run a system update for the second time. $ sudo dnf update && sudo dnf upgrade -y We are now ready to use the Remi repo for PHP installation. The first step is to list all the available PHP versions this repository has to offer AlmaLinux. We will use the list module command. $ sudo dnf module list phpList PHP Module in AlmaLinux As you can see, the above command lists PHP 7.x module. In order to get PHP 8.x modules, we first need to reset the default PHP 7.x module. $ sudo dnf module reset phpReset PHP Module in AlmaLinux After resetting PHP from its default module, we should now be able to see the PHP modules Remi repo has to offer by re-running the module list command. $ sudo dnf module list phpList PHP Module in AlmaLinux As you can see, the Remi repository offers PHP versions from 7.2 to 8.1. Since PHP 8.1 is the latest version release under Remi repo, we first need to enable it before we can proceed and install PHP 8.1, or else PHP 7.4 from AppStream will be installed. $ sudo dnf module enable php:remi-8.1Enable PHP Module in AlmaLinux We can now proceed and install PHP 8.1 on AlmaLinux. $ sudo dnf install php -yInstall PHP in AlmaLinux Check on PHP installed version. $ php --versionCheck PHP in AlmaLinux To install additional PHP extensions, adhere to the syntax: $ sudo dnf install php-extension-name For instance, we can install the php-fpm extension: $ sudo dnf install php-fpm Your AlmaLinux system is now installed and configured with the latest version of PHP (8.1). Steps to Install LAMP on AlmaLinux 8 #The steps are described here to install and set up a Lamp server on AlmaLinux 8 can also be used for CentOS 8 Stream and RHEL 8 Linux server or desktop systems. 1. Run system update #One of the necessary steps before running the installation programs is to run the command to update the system. This helps us to make sure all the installed packages are in their latest state but also rebuild the system repository cache. This helps in the process of any software or services installation running smoothly. Run system updateWrite ” y ” and Enter. 2. Install Apache web server on AlmaLinux 8 #The next step is to install the Apache webserver on AlmaLinux along with some other tools to run Code sudo dnf install httpd httpd-tools Command to install Apache on AlmaLinux 8again, Write ” y ” and Enter. 3. Enable and start Apache #Once the webserver is installed, let’s start its service and also make it automatically up with the system boot. This will ensure whenever you boot AlmaLinux you won’t need to start Apache manually. Code sudo systemctl start httpd After installing Apache and applying its settings, we will now check its Status: Code sudo systemctl status httpd Check Apache Status in Almalinux 84. Update FireWall rules #If you want to access the Apache webserver outside your local machine using some browser, then first we have to open ports 80 and 443 on our AlmaLinux server. How open port 80 or HTTP in
Almalinux 8 : |