Install and configure CentOS 8 with full LAMP Stack on Oracle Virtualbox

Download and install the latest build of oracle virutalbox vm from the link for your platform https://www.virtualbox.org/wiki/Downloads

Download CentOS 8 image for oracle virualbox from the link https://www.linuxvmimages.com/images/centos-8/

select create a new VM option and Add the vmdk image of centos 8 and start the VM

On the Network settings of Virualbox change the Network settings of adapter 1 from NAT to Bridged Adapeter or host only adapter

Login to Centos using the username : centos password : centos

switch to root using command sudo -u

root password : centos

update the Centos installtion using the command

sudo yum update -y

Start the LAMP stack installation

Install Apache webserver

sudo yum install httpd httpd-tools -y

start apache webserver

sudo systemctl start httpd

enable http deamon to start automatically

sudo systemctl enable httpd

add firewall rules to allow http and https traffic to the apache

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

Reload the firewall

systemctl reload firewalld

Enter the IP address of the the Centos server in the browser to see the apache server status

to find the ip type ifconfig command

This is the default Apache homescreen

Install Database

dnf install mariadb-server mariadb -y

Start and enable the database

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure the database

sudo mysql_secure_installation
Change root password, Disallow root login remotely , remove test database, reload privilege tables

Install PHP

Install the EPEL repository

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Install yum utils and enable remi-repository

sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

List the available PHP modules

sudo dnf module list php
In the output we can see the current version installed is 7.2

To install the newer version PHP7 7.4 reset the PHP modules

sudo dnf module reset php

Enable the PHP 7.4

sudo dnf module enable php:remi-7.4

Install PHP, PHP-FPM ( FastCGI Process Manager)

sudo dnf install php php-opcache php-gd php-curl php-mysqlnd

verify the installed PHP version

php -v

Test PHP Information

create a info.php info file under /var/www/html/

use vi editor to create the file with the below content

<?php
phpinfo ();
?>

Browse the server with the URL

http://server-ip-address/info.php

Now the installation of LAMP stack with Apache,MariaDB,PHP in Centos 8 platform in your Oracle Virtualbox is completed, and you can access the resources from your host