assuming that you have root permission, otherwise, you may start commands with “sudo”.

Install Apache Server with Basic Configurations

First of all you have to Install Apache 2.4 httpd service binary package provided from official repositories using the following command:

 yum install httpd

Make your Apache to run at startup:

systemctl enable httpd

After the installation of Apache, you also have to add some rules to your firewall:

 firewall-cmd --add-service=http
 firewall-cmd --permanent --add-service=http
 systemctl restart firewalld
 systemctl restart httpd

Now you can test your Apache by opening your browser and see your Public IP address (or domain). You should see something like the picture below:

Install MySQL (MariaDB)

We are going to install MariaDB instead of MySQL, you might ask why? MariaDB is a community-developed fork of the MySQL, and it’s led by MySQL developers. MariaDB maintains high compatibility with MySQL, It’s very smooth and lightweight:

 yum install mariadb-server mariadb

Make MariaDB to run at startup:

systemctl enable mariadb

After the installation, we should start MariaDB with the following command:

 systemctl start mariadb

In this step we are going to run MySQL secure installation to remove some insecure defaults:

 mysql_secure_installation

If you are happy with your MySQL root password then you can skip the first question, it’s recommended to answer all other questions with “y”.

After the secure installation done, you have to enable your database management to run at the startup

 systemctl enable mariadb.service

Install PHP 5

We’re going to include the PHP-MySQL package as well:

 yum install php php-mysql

We should restart the Apache service in order to work with PHP with the command below:

 systemctl restart httpd.service

Now it’s time to test your PHP. create a file named “info.php” in the location below:

 nano /var/www/html/info.php

Add the following PHP code in it then save and exit (Ctrl+ O, Ctrl+X)

<?php phpinfo(); ?>

If you are running a firewall, run the following commands to allow HTTP and HTTPS traffic:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https  firewall-cmd --reload

You can now test your service by opening your browser and enter your Public IP address or domain. 

Was this answer helpful? 0 Users Found This Useful (0 Votes)