18th September 2021

Installing Php, Apache and Mysql on Centos

In this article, we will talk about apache, mysql and PHP installations on Centos. After logging in as root, we enter the following commands on the terminal screen in order. We can install with a single command or with a separate command. We will install apache, mysql and PHP with yum command at a time. When we type -y after yum in the command, it means that we approve the download of the required files.

install httpd php mysql mysql-server php-mysql
install httpd php mysql mysql-server php-mysql

 

You can install PHP, MySQL and Apache separately as follows, as it is installed with a single command.

install mysql mysql-server
install mysql mysql-server

 

install httpd
install httpd

install php
install php

 

Config file

We add the following lines to the config files in order for the services to start automatically when the system restarts.

Config file
Config file

 

Running services

We enter the commands that run Apache and mysql respectively.

Running services
Running services

 

Testing that PHP is Working

Apache’s default folder in Centos systems is /var/www/html. We will go into this folder and create the test.php file. We enter the test.php file and enter the following code, press CTRL+X, click y, save and exit.

/var/www/html
/var/www/html

test.php
test.php

 

LEARN MORE  SSH Configuration on Cisco Router

Now we write “http://youraddress/test.php” to our browser and see if PHP is working. As you can see on the screen below, php is working.

Testing that PHP is Working
Testing that PHP is Working

 

Leave a Reply

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