In this guide, were going to install LAMP Server CentOS 7.
Step One — Install Apache
In the terminal type the following.
sudo yum install httpd
Once it installs, you can start Apache on your server:
sudo systemctl start httpd.service
The next step is to find out if Apache is running. Go to your browser and type in your ip address.
You will see the default CentOS 7 Apache web page, It should look something like this:
If you see this page, then your web server is now correctly installed.
The last thing you will want to do is enable Apache to start on boot. Use the following command will enable this:
sudo systemctl enable httpd.service
Step Two — Install MySQL (MariaDB)
Now that we have our web server up and running, it is now time to install MariaDB (MySQL).
sudo yum install mariadb-server mariadb
When the installation is complete, we need to start MariaDB with the following command:
sudo systemctl start mariadb
Now that the MySQL database is running, we want to run a simple security script that will remove some dangerous defaults and lock down access to the database. Run the following command:
Then the prompt will ask you for your current root password. Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter. Then the prompt will ask you if you want to set a root password. Go ahead and enter Y, and follow the instructions:
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: password
Re-enter new password: password
Password updated successfully!
Reloading privilege tables..
For the rest of the questions, you should simply hit the “ENTER” key through each prompt to accept the default values. This process will remove some sample users and databases, disable remote root logins.
The next thing you will want to do is enable MariaDB to start on boot. Use the following command:
sudo systemctl enable mariadb.service
Step Three — Install PHP
To install PHP run the following command on the terminal:
sudo yum install php php-mysql
This will install PHP. We need to restart the Apache web server in order for it to work with PHP.
sudo systemctl restart httpd.service
Once this is done that is it. There are also other PHP modules you can install. You can see what’s available by running the following:
yum search php-