Linux, Apache, MySQL, and PHP are the building blocks of the internet. Many modern websites, applications, and services require these base components to function.
LAMP is an archetypal model of web service solution stacks, named as an acronym of the names of its original four components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language. The LAMP components are largely interchangeable and not limited to the original selection. As a solution stack, LAMP is suitable for building dynamic web sites and web applications. - Wikipedia
The tutorial below is a quick rundown of installing a basic LAMP stack on CentOS 7. Do note that MySQL has been replaced by MariaDB in the base repositories for CentOS 7, and is used in place of MySQL for this tutorial. Don’t worry, MariaDB basically works the same as the MySQL that you’re used to. However, if you prefer to use MySQL it can still be installed by adding the mysql repositories. (several tutorials like this one exist showing the necessary steps)
The Tutorial Environment consists of a Minimal Install of CentOS 7 in a KVM Virtual Machine. The VM has a 40GB virtual disk, 2GB of memory, and 2 vCPU’s allocated.
[root@localhost ~]# yum install httpd [root@localhost ~]# systemctl start httpd.service [root@localhost ~]# firewall-cmd --permanent --add-service=http [root@localhost ~]# firewall-cmd --permanent --add-service=https [root@localhost ~]# firewall-cmd --reload [root@localhost ~]# systemctl enable firewalld [root@localhost ~]# systemctl enable httpd
Open a browser and enter http://18.104.22.168 in the address bar. (where 22.214.171.124 is the ip address of your server) If everything is working as expected you should see the image below.
[root@localhost ~]# yum install mariadb-server mariadb [root@localhost ~]# systemctl start mariadb [root@localhost ~]# mysql_secure_installation 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 authorization. New password: (enter your new password here) Re-enter new password: (re-enter your new password here) Password updated successfully! Reloading privilege tables.. ... Success!
Accept the default answers to the remaining questions.
[root@localhost ~]# yum install php php-mysql [root@localhost ~]# systemctl restart httpd
That’s it! You should now have a fully function linux-based web server. This basic configuration will work great for hosting local web pages or running web-based services on your private network. However, if you want to expose this server to the outside world you’ll need to do a few extra things to secure it.