Connect to the CentOS 9 server:
- Launch the VMware application.
- Power on the CentOS 9 virtual machine.
- Wait for the CentOS login prompt.
- Log in to the CentOS 9 server using your credentials.
Update the system:
- Run the following command to update the system packages:
sudo yum update
- Run the following command to update the system packages:
Install PHP and related packages:
Run the following command to install PHP and commonly used PHP modules:
sudo yum install php php-cli php-fpm php-mysqlnd php-json php-opcache php-xml php-gd php-curl php-mbstring
sudo chown -R nginx:nginx /var/log/php-fpm
Start and enable PHP-FPM service:
- Run the following command to start the PHP-FPM service:
sudo systemctl start php-fpm
- Run the following command to enable the PHP-FPM service to start on system boot:
sudo systemctl enable php-fpm
- Run the following command to start the PHP-FPM service:
Verify the PHP installation:
- Create a PHP test file by running the following command:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
- Open a web browser on your local machine and enter the following URL:Replace
http://<server-ip-address>/phpinfo.php
<server-ip-address>
with the actual IP address of your CentOS 9 server. - If PHP is installed correctly, you should see the PHP information page with details about your PHP installation.
- Create a PHP test file by running the following command: