How to install LAMP on CentOS 7

What is LAMP?
LAMP is a basic server installation of open source software that is also an acronym. The acronym stands for: Linux, Apache, MySQL and PHP.

Since the server comes with CentOS 7 installed, we just need to install Apache, MySQL, and PHP.

Requirements
The VPS or server you perform this installation on needs to be CentOS 7. This tutorial was installed successfully on a 1GB RAM VPS with CentOS 7 installed.

Step one: Update
To start, lets go ahead and update the VPS repositories. Run the command:

sudo yum update


The sudo argument runs each of these commands with root privileges. Great! Your VPS will now update its repositories. Once it has finished, you are ready to onto step two!

Step two: Install Apache
Apache is free webserver software that is very commonly used worldwide.

To install apache, we need to run:

sudo yum install httpd


Now that we have installed apache, we need to start it of course! Run:

sudo systemctl start httpd.service

To make sure apache starts everytime we boot the VPS, also run:

sudo systemctl enable httpd.service

Perfect! We have installed and started the webserver, Apache. We also made it so apache starts upon boot of the VPS. Time to go on to step three.

Step three: Install MySQL
MySQL is a advanced database system that is used to send and retrieve data. It is very commonly used on virtual private servers.

To install MySQL, we are going to run:

sudo yum install mariadb-server mariadb


Once MySQL has finished installing, its time to start MySQL. Run:

sudo systemctl start mariadb

Great! Now that we have installed and started MySQL, its time to setup MySQL. Run:

sudo mysql_secure_installation


After you run that command, it will start asking you questions. The first question asks you to enter the current root password for MySQL. If you have it set, type it in and hit enter. If you have not set it, just hit enter then hit Y when it asks you if you would like to set a root password. Below I have pasted how I went through this step:

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!

Now that you have set the root password or entered the root password, use Y to answer the rest of the questions. 
 
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
 ... Success!
 
Cleaning up...
 
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
 
Thanks for using MariaDB!
 
To finish this step, lets enable MySQL to start upon the server boot. Run:

sudo systemctl enable mariadb.service

Sweet! You now have Apache and MySQL setup and started on your VPS server. Next we install PHP to complete the installation of LAMP on your CentOS 7 VPS.

Step five: Install PHP
PHP is an extremely common web scripting language. Just like PHP, it is open source.

To install PHP, we need to run:

sudo yum install php php-mysql


After PHP installs, you are finished! You have installed the LAMP setup on your CentOS 7 VPS server!
  • 2 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

How to install LAMP on CentOS 6

What is LAMP?LAMP is a basic server installation of open source software that is also an acronym....

How to install LAMP on Ubuntu 14.04

What is LAMP?LAMP is a basic server installation of open source software that is also an acronym....

How to install LAMP on Debian 6

What is LAMP?LAMP is a basic server installation of open source software that is also an acronym....

Powered by WHMCompleteSolution