LAMP is an open source Web development platform which uses Linux as the operating system, Apache as the Web server, MariaDB as the relational database and PHP as the server-side scripting language.
Step 1: Install Apache web server by using the following commands:
[root@localhost ~]# yum install httpd -y
Step 2: start and enable httpd server by using the following commands.
[root@localhost ~]# systemctl start httpd && systemctl enable httpd && systemctl status httpd
Step 3: Now need to add http server or port number with firewall by using the following commands.
[root@localhost ~]# firewall-cmd –add-service=http –permanent && firewall-cmd –reload
Now http server added in firewall for permanently on the machine, To verify Apache functionality open a remote browser and type your server IP Address using HTTP protocol on URL (http://server_IP), now you get redhat test page in your browser.
Step 4: After that need to install MariaDB by using the following commands:
[root@localhost ~]# yum install mariadb* -y
after completed installation of MariaDB, need to set root password by using the following commands, but we need to start the and enable MariaDB server.
[root@localhost ~]# systemctl start mariadb && systemctl enable mariadb && systemctl status mariadb
Run given the command to set root password of MariaDB.
[root@localhost ~]# mysql_secure_installation
Now you need to set root password and the asking question according to you of MariaDB.
Enter current password for root (enter for none):
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
… Success!
By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
– Dropping test database…
… Success!
– Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
Step 5: Now need to install PHP by using the following commands.
[root@localhost ~]# yum install php* -y
I refer the * to all PHP rpm package in the system.
Now need to test PHP is working or not to get complete information about PHP, need to create a file with PHP extension.
[root@localhost ~]# echo “<?php phpinfo(); ?>” > /var/www/html/info.php
after that need to start apache web server by using the following commands.
[root@localhost ~]# systemctl restart httpd
To verify PHP version browser again URL ( http://server_IP/info.php )
After that need to delete info.php file from /var/www/html
after test PHP web page, need to remove that file by using the following commands.
[root@localhost ~]# rm -rf /var/www/html/info.php