Step to Installing LAMP (Linux, Apache, MariaDB, PHP/PhpMyAdmin)




A “LAMP” stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database (using MariaDB), and dynamic content is processed by PHP.


Step One — Install Apache


The Apache web server is currently the most popular web server in the world, which makes it a great default choice for hosting a website.
We can install Apache easily using CentOS’s package manager, yum. A package manager allows us to install most software pain-free from a repository maintained by CentOS.
For our purposes, we can get started by typing these commands:
#yum install httpd
Once it installs, you can start Apache on your VPS
#systemctl start httpd.service
note:-You can do a spot check right away to verify that everything went as planned by visiting your server’s public IP address in your web browser (see the note under the next heading to find out what your public IP address is if you do not have this information already):
http://your_server_ipadd/
The last thing you will want to do is enable Apache to start on boot. Use the following command to do so:
#systemctl1 enable httpd.sevice.

Now the question is How To Find your Server’s Public IP Address

If you do not know what your server’s public IP address is, there are a number of ways you can find it. Usually, this is the address you use to connect to your server through SSH.
From the command line, you can find this a few ways. First, you can use the iproute2 tools to get your address by typing this:
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
This will give you one or two lines back. They are both correct addresses, but your computer may only be able to use one of them, so feel free to try each one.
An alternative method is to use an outside party to tell you how it sees your server. You can do this by asking a specific server what your IP address is
curl http://icanhazip.com
Regardless of the method you use to get your IP address, you can type it into your web browser’s address bar to get to your server

Step Two — Install MySQL (MariaDB)

Now that we have our web server up and running, it is time to install MariaDB, a MySQL drop-in replacement. MariaDB is a community-developed fork of the MySQL relational database management system. Basically, it will organize and provide access to databases where our site can store information.
Again, we can use yum to acquire and install our software. This time, we’ll also install some other “helper” packages that will assist us in getting our components to communicate with each other:
#yum install mariadb-server mariadb
When the installation is complete, we need to start MariaDB with the following command:
#systemctl start mariadb
Now that our MySQL database is running, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit. Start the interactive script by running:
#mysql_secure_installaton
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..
 … Success!


For the rest of the questions, you should simply hit the “ENTER” key through each prompt to accept the default values. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.

The last thing you will want to do is enable MariaDB to start on boot. Use the following command to do so:

#systemctl enable mariadb.service




At this point, your database system is now set up and we can move on.

Step Three — Install PHP/phpmyadmin

PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information, and hand the processed content over to our web server to display.
We can once again leverage the yum system to install our components. We’re going to include the php-mysql package as well.
# yum install php php-mysql(for more information check php/phpmyadmin installation page)
test for php sever
www.\\linux-server-ip/php/myadmin
Now that you have a LAMP stack installed, you have many choices for what to do next. Basically, you’ve installed a platform that will allow you to install most kinds of websites and web software on your server.

Now configure the dadatabase user and pass for wordpress
----------------------------------------------------------
Step 1: Login to MariaDB (MySQL) with root credentials you created. It will open the MariaDB shell where you can run the scripts for managing databases and its users.
#mysql -u root -p

Step 2: Create a database named wordpress. You can give your own database name.
#CREATE DATABASE wordpress;
Step 3: Now create a user named wordpress_admin for managing the wordpress database. You can choose your database username and password
#CREATE USER wordpress_admin@localhost IDENTIFIED BY 'password';
Step 4: Grant all database privileges to wordpress_admin on wordpress database.
#GRANT ALL PRIVILEGES ON wordpress.* TO wordpress_admin@localhost IDENTIFIED BY 'password';
Step 5: Flush the privileges using the following command.
#FLUSH PRIVILEGES;
Step 6: Exit the database shell
#exit
next Install and Configure WordPress and lunch web site