How To Install Apache 2.4 and PHP 7.3 On Fedora, CentOS, RHEL Linux? – POFTUT

How To Install Apache 2.4 and PHP 7.3 On Fedora, CentOS, RHEL Linux?

Apache and PHP are very popular tools used to publish and serve web pages. These web pages can be a simple website, a WordPress installation or a complex web application. In this tutorial, we will learn how to install and use Apache and PHP tools for rpm based distributions like Fedora, CentOS, RedHat.

Update Current Repository and Package Information

Before installing the Apache and PHP tools we need to update current repository information for the latest version information. This will also update the currently installed packages if there are some updates about them. We will provide the sudo command for the root privileges as the package installation requires this.

Update Current Repository and Package Information

Update Current Repository and Package Information

Install Apache or Httpd 2.4

Apache is the well-known name of the httpd which is one of the most popular web server software. In rpm based distributions Apache is named as httpd and the package is also named as httpd.

Install Apache or Httpd 2.4

Install Apache or Httpd 2.4

Check Apache Service Status

Apache is a web service and works as a daemon or service. We can star, stop, restart the service. We can also check the Apache service with the systemctl command like below.

Check Apache Service Status

Check Apache Service Status

We can see from the screenshot that the service is stopped currently and not working.

Start Apache Service

We can start the Apache service with the systemctl start command by providing the  httpd service name. As this is an administrative task we need to provide the root privileges with the sudo command. Then we will check service status if it is started properly.

LEARN MORE  What Is a Web Browser?

Start Apache Service

Start Apache Service

We can see from the httpd status that it started properly without a problem.

Stop Apache Service

If its require we can stop the service with the following systemctl stop command. This command also requires the root privileges with the sudo command.

Install PHP 7.3

PHP is popular programming language which is named as php package in Fedora, CentOS, RedHat. We will also provide some usefull PHP modules like php-gd, php-xml, php-xmlrpc.

Install PHP 7.3

Install PHP 7.3

Test Default Web Page

If the Apache web server is started properly and everything is working correctly we can navigate to the default web page just using localhost or 127.0.0.1 like below.

Test Default Web Page

Test Default Web Page

Test PHP with phpinfo()

PHP provides the phpinfo() function which will provide information about the current PHP installation and details. This information can be API level, Build Date, Debug status, enabled extensions, System information, etc. As the default web page is located at the /var/www/html/index.html we will change its content to the following.

Test PHP with phpinfo()

Test PHP with phpinfo()

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)