Pre-requisites:
A system with CentOS Stream 9 installed and running
Access to a terminal or command line
Root or sudo privileges
First update your system
dnf update -y
Next, we need to enable the Remi repository
To install PHP 8, we'll need to enable this repository:
dnf install -y http://rpms.remirepo.net/enterprise/remi-release-9.rpm
To check what php versions are available to us, we will want to run:
dnf module list php
Next, enable PHP 8.0 Remi Module
dnf module enable php:remi-8.0
The following command resets the PHP module to its default state. When updating PHP, this is useful to ensure you are starting from a clean slate.
dnf module reset php
Next, install PHP 8 and some common extensions that you may need
dnf install -y php php-cli php-fpm php-json php-common php-mysqlnd php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json
After the install, check the php version
php -v
Next, configure php-fpm
Start and enable php-fpm with the following commands:
systemctl start php-fpm
systemctl enable php-fpm
Ensure that php-fpm is running
systemctl status php-fpm
At the time of PHP installation, php.ini is a special file provided as a default configuration file.
To check the file path of php.ini run the command below
find '/' -name "php.ini"
The -name option searches for files with a specific name
Run the following command for PHP information
php -i
Additionally, you could create a sample php file in the /var/www/html folder or your root directory of your web server as shown:
vim /var/www/html/info.php
Then, add the following PHP code which can be used to output a large amount of information about your PHP installation.
<?php phpinfo(); ?>
After saving the file, just point your web browser at it to view its result. For example, open:
http://<server_ip>/info.php
Output a list of command line options with one line descriptions of what they do
php -h
List all installed PHP extensions on a Linux machine
php -m
Learn about general installation considerations on the official website
http://www.php.net/manual/en/install.general.php
Learn about the PHP command line options on the official website
http://www.php.net/manual/en/features.commandline.options.php
For information on the most current stable PHP version on the official website