How to install Linux, Apache, MySQL, PHP on CentOS 6.x

In this tutorial we will guide you the steps to install LAMP stack, a collection of open source software used to get web servers up and running so you can host all your site’s files and databases in it.

The steps in this tutorial require the user on the virtual private server to have root privileges.You can see how to set that up in the how to create user in cPanel.

1. Install Apache

To install Apache, open terminal and run this command:

yum install httpd

Once installed, you can start Apache running on your VPS:

service httpd start

2. Install MySQL

To install MySQL on your VPS, open terminal and type in these commands

yum install mysql-server
service mysql start
/etc/init.d/mysqld restart

During the installation, MySQL will ask for your permission twice. After you say Yes to both, MySQL will install.

Once its installed, you can set a root MySQL password:

/usr/bin/mysql_secure_installation

The prompt will ask you for your current root password, you most likely won’t have one, so leave it blank by pressing enter.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Next, you’ll be asked: Set root password? [Y/n]. Type Y and hit Enter then type in your new password twice.

You’ll also be asked for several questions. Simply answer with Y to move on.

Remove anonymous users? [Y/n] y                                            
 ... Success!
 
Disallow root login remotely? [Y/n] y
... Success!
 
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reload privilege tables now? [Y/n] y
 ... Success!

At the end, you will see the message: Thanks for using MySQL!

3. Install PHP

To install PHP on your VPS, open terminal and type in this command:

yum install php php-mysql

Once you confirm ‘yes’ to the PHP prompt, PHP will be installed.

4. PHP Modules

Firstly you have to check all available libraries and modules by issuing this command:

yum search php-

It will then show you all libraries with “php-” prefix. you can also retrieve more detailed information about what each module does. Use this command:

yum info php-module-name

Instead of installing each module one by one, you can simply install multiple libraries at once by separating the name of each module with a space. Here’s the example:

yum install php-common php-cli php-devel php-fpm php-gd php-imap php-intl
php-mysql php-process php-xml php-xmlrpc php-zts

We should also have to set the process to run automatically when the server boots (php will run automatically once Apache starts):

chkconfig httpd on
chkconfig mysqld on

Restart Apache so that all of the changes take effect on your Server:

service httpd restart

Congratulations! You now have LAMP stack on your server!

Leave a Reply

Register to Get FREE Offers

Why Pay for Software when you can GET it for FREE

JOIN US TONIGHT!