Installing Linux, Apache, MySQL, PHP (LAMP) Stack On CentOS 7 Print

  • 0

A LAMP stack is a collection of open source software (Linux, Apache, MySQL, PHP), also known as a Web Stack, installed on a server to enable it to host dynamic websites.

This guide will show you how to get a LAMP stack installed on a CentOS 7 server.

Update your system by running the following command:

sudo yum update

Moving on to installing Apache, run the following command:

sudo yum install httpd

You will see a list of packages to be installed, type "y" and press enter for them to be installed.

Now that it is installed, to start Apache and configure it to start up on boot, enter the following commands:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

To enable public connections to Apache server, enter the following commands:

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

Now, navigate to your server IP in your web browser. If you see the default page for Apache as shown below, it means Apache is installed correctly and can be accessed.

Moving on, run the following command to install MySQL (MariaDB):

sudo yum install mariadb-server mariadb

As usual, packages will be shown and press "y" and enter to install them.

Start MariaDB and enable it to start at boot using the following commands:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Once the installation is done, run this command to secure the MariaDB installation:

mysql_secure_installation

Now you get a prompt asking for root password, fill in your root password.

Moving on, to install PHP,  run the following command:

sudo yum install php php-mysql

Again, packages to be installed will be shown, press "y" and enter to install them.

Once installation of packages are done, restart Apache for it to work with PHP using this command:

sudo systemctl restart httpd.service

 


Was this answer helpful?

« Back