How to install Apache MySQL and PHP in CentOS Linux



How to install Apache MySQL and PHP in CentOS Linux

How to install Apache MySQL and PHP in CentOS Linux

In this video we are going to show you how to install Apache, MySQL and PHP on a CentOS Linux server. How to install apache in Linux, how to install MySQL using command line and how to install PHP. Basically, this video shows how to build a Linux web server.

This video was produced using a plain server from Copahost (without cPanel).

VPS Servers from 3€ – https://www.copahost.com/en/cheap-vps-hosting

Dedicated servers from 49€ – https://www.copahost.com/en/dedicated-servers

For this task we’re going to use a VPS server from COPAHOST but you can install this in any server or in your PC running CentOS.

First of all we’re going to open our SSH terminal. We like using PuTT but you can use anyone of your choice. We are going to place the IP address of the server here (see timecode 0:43) and then click “open”.
Lets login as root and then type the root password.We’re going to install the Apache web server
Let just type: sudo yum install httpd
what does it mean?

“Sudo” is for the super user privileges. Admin privileges

“Yum” is the installer of CentOS. You can install almost everything with CentOS.
“Install” is a common so that yum install something

And “httpd” is the name of the Apache mode.
So lets hits enter, lets hit yes to confirm enter Lets hit yes again to confirm and enter. Now our httpd is installed and we’re going to install MySQL, so let just type “Sudo yum install MySQL-server”
Lets hit enter. Lets hit “yes” to confirm.
So now lets start MySQL

Lets type “sudo service mysqld start”
Lets hit enter.

Ok so now the MySQL is already started, we must now configure the MySQL root password.
We are going to simply copy and paste this two lines in here (see timecode 3:01).
Let’s start with the first line. We are going to set the password to 123change.
So
usr/bin/mysqladmin -u root password ‘123change’

We are setting the root password as 123change this is the same password will have to use in our
applications in the future.
Lets hit enter, now the second common which is almost the same.
The only one difference is that you’re mentioning the hosting of the server.
But we have to do it twice so 123change is our password.
Ok so now both password are set for the MySQL
We are now we’re going to install PHP so lets do it:

sudo yum install php php-mysql
We’re installing both the PHP model.
And the PHP MySQL model so lets hit enter
“Yes” to confirm.
Now PHP is installed.
we must make sure we restart now the webserver as we finish installing PHP and they are prety related services. So lets do it:

sudo service httpd restart

Ok. We’re just restarted our web server. Now we have to make sure that both service of httpd and MySQL

We’ll start at the boot time of the server. If we don’t do these we as we reboot the server, this service will be offline so lets do it:

Sudo chkconfig httpd on
And then
sudo chkconfig mysqld on

This common chkconfig ensures the service will be up at the boot time.

Now we’re going to enter in the root folder of our web server which is:

/var/www/html

Here is the root folder where all the files are stored by default in our APACHE.
So lets install the nano editor, so that we can edit simple files, so lets do it:

Sudo yum install nano
Yes

Now we’re going to edit simple file. Lets do just like
sudo nano index.php

Now we are going to place just and example. We are going to show the phpinfo function which is a function that test the PHP functionality and shows all the installed modules:

Ctrl-x

Lets hit “yes” to confirm and enter

Ok now lets test our web server

So let just open a new tab here copy and paste the IP address

/index.php which is
the file we just edited

So that’s it. Our PHP is working, yes here we can see all the information about the webserver and the PHP.

We hope you enjoyed this video. Thanks for watching.

Comments are closed.