Show
In this tutorial, we will show you how to install PHP 7.4 on Rocky Linux 8. For those of you who didn’t know, PHP is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. It is the core of most blogging systems such as WordPress, Drupal, and much more. 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 ‘ Prerequisites
Install PHP 7.4 on Rocky Linux 8Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands: sudo dnf check-update sudo dnf update Step 2. Installing PHP 7.4 on Rocky Linux 8. By default, PHP 7.4 is not available on Rocky Linux 8 base repository. Now run the following command below to add Remi repository to your system: rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm Next, install the Remi repository by using the below command: sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm To get a list of all the PHP modules, run the command: sudo dnf module list php Finally, install PHP 7.4 via the Remi repository using the following command below: sudo dnf install php php-zip php-intl php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-json php-mbstring php-posix Step 3. Verify the PHP Version. Once successfully installed PHP, check the PHP version: php -v Output: [ ~]# php -v PHP 7.4.19 (cli) (built: Apr 4 2022 15:06:46) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies Congratulations! You have successfully installed PHP. Thanks for using this tutorial for installing PHP 7.4 on your Rocky Linux 8 system. For additional help 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! PHP (PHP Hypertext Preprocessor) is a source scripting language, specially designed for web application development. In 2021, PHP represented a little less than 80% of the web pages generated in the world. PHP is open-source and is the core of the most famous CMS (WordPress, Drupal, Joomla!, Magento, ...). PHP-FPM (FastCGI Process
Manager) is integrated to PHP since its version 5.3.3. The FastCGI version of php brings additional functionalities. CGI (Common Gateway Interface) and FastCGI allow communication between the web server (Apache, Nginx, ...) and a development
language (Php, Python, Java): PHP-FPM, in addition to better performances, brings: Note Since Apache has a php module, the use of php-fpm is more commonly used on an Nginx server. Rocky Linux, like its upstream, offers many versions of the language. Some of them have reached the end of their life but are kept to continue hosting historical applications that are not yet compatible with new versions of PHP. Please refer to the supported-versions page of the php.net
website to choose a supported version. To obtain a list of available versions, simply enter the following command:
Rocky provides, from its AppStream repository, different PHP modules. You will note that the default version of a Rocky 8.5 is 7.2 which has already reached its end of life at the time of writing. You can activate a newer module by entering the following command:
Note You cannot currently install php 8 from the AppStream repositories. For this, you will have to go through the REMI repository. This installation is not covered in this document. You can now proceed to the installation of the php engine. PHP cgi mode¶First, let's see how to install and use php in its CGI mode. We will only be able to make it work with the Apache web server and its
Installation¶The installation of php is quite trivial, since it consists in installing the main package as well as the few php modules that you will need. The example below installs php with the modules that are usually installed with it.
You can check that the installed version corresponds to the expected one:
Configuration¶Apache integration¶To serve php pages in cgi mode, you will have to install the apache server, configure it, activate it and start it.
The default vhost should work out of the box. PHP provides a Create the file Use a web browser to check that the server is working properly by going to the page http://yourip/info.php. Warning Do not leave the info.php file on your server! PHP-FPM (FastCGI)¶As we highlighted earlier in this document, there are many advantages to switching web hosting to php-fpm mode. Installation¶The installation is limited to the php-fpm package:
As php-fpm is a service from a system point of view, it must be activated and started:
Configuration¶The main configuration file is stored under
Note The php-fpm configuration files are widely commented. Go and have a look! As you can see, the files in the By default, a php process pool, named
Configuring the way to access php-fpm processes¶There are 2 ways to connect. Via an inet interface such as:
Or via a Unix socket:
Note The use of a socket when the web server and the php server are on the same machine allows the removal of the TCP/IP layer and optimizes the performances. When working via an interface, you have to configure When working via a socket, you have to configure Example : Static or dynamic configuration¶The processes of php-fpm can be managed statically or dynamically In static mode, the number of child processes is set by the value of
This configuration will launch 10 processes. In dynamic mode, PHP-FPM will launch at most the number of
processes specified by the value of Example:
PHP-FPM will create a new process to replace one that has processed a number of requests equivalent to By default, There is a third mode of operation, the Note The configuration of the operating mode of PHP-FPM is essential to ensure an optimal functioning of your web server. Process status¶PHP-FPM offers, like Apache and its To activate the page, setup its access path via the
Logging long requests¶The slowlog directive specifies the file that receives logging of requests that are too long (i.e., whose time exceeds the value of the The default location of the generated file is
A value of 0 for NGinx integration¶The default setting of nginx already includes the necessary configuration to make php work with PHP-FPM. The configuration file
In order for nginx to process If php-fpm is listening on port 9000:
If php-fpm is listening on a unix socket:
Apache integration¶The configuration of apache to use a php pool is quite simple. You just have to use the proxy modules with a
Solid configuration of php pools¶It is essential, to optimize the quantity of requests which will be able to be served, to analyze the memory used by the php scripts and thus to optimize the maximum quantity of launched threads. First of all, we need to know the average amount of memory used by a PHP process, with the command:
After a while, this should give us a pretty accurate idea of the average memory footprint of a php process on this server. For the rest of this document, let's say that the result is a memory footprint of 120MB per process at full load. On a server with 8Gb of RAM, keeping 1Gb for the system and 1Gb for the OPCache (see the rest of this document), there is 6Gb left to process PHP requests from clients. We can easily conclude that this server can accept at most 50 threads A
good configuration of
with:
Opcache configuration¶The It keeps in memory the compiled php scripts which strongly impacts the execution of the web pages (removes the reading on disk of the script + the compilation time). To configure it, we must work on:
By configuring correctly
To install it:
To configure it, edit the
where:
You can refer to an Note At each new deployment of new code, it will be necessary to empty the opcache (for example by restarting the php-fpm process) Note Don't underestimate the speed gain that can be achieved by setting up and configuring the opcache correctly. Last update: April 28, 2022 Author: Antoine Le Morvan Contributors: Steven Spencer How install PHP 7.4 on rocky Linux?How to Install PHP 7.4 on on Rocky Linux and AlmaLinux. Step 1: Check PHP Installation in Rocky Linux. We will start off by checking if PHP is installed. ... . Step 2: Install PHP 7.4 in Rocky Linux. To install PHP 7.4, first enable the module as provided. ... . Step 3: Verify the Version of PHP Installed.. How do I install PHP on Linux?Follow the below steps to install PHP on Linux:. Step 1: Open your terminal in Linux. On your Linux computer open the terminal. ... . Step 2: Update your packages. On your terminal update your packages using the following command. ... . Step 3: Upgrade your packages. ... . Step 4: Install PHP.. How install PHP install?Follow the below steps to install PHP on Windows: Step 1: Visit https://www.php.net/ website using any web browser and click on Downloads. Step 2: Click on the Windows “Downloads” button. Step 3: The new webpage has different options, choose the Thread safe version, and click on the zip button and Download it.
How install PHP and configure Ubuntu?Installing PHP on Ubuntu 22.04. Install few dependencies required by this tutorial with the below-mentioned command: sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https.. Add the Ondrej PPA to your system, which contains all versions of PHP packages for the Ubuntu systems.. |