Install Linux, Apache, MySQL, PHP (LAMP) stack on CentOS 6

by | 2 Aug 2015 | CentOS, Linux, OS, PHP, Programming, Server, Technology | 0 comments

LAMP stack is a group of open source softwares used to get web servers up and running. This guide assumes that you already have your CentOS installed successfully.

1. Install Apache

Apache is the web server in the lamp stack.

Install apache command

sudo yum install httpd

Start apache on your server

sudo service httpd start

(Optional) Test if apache is alive

Get your IP address first

ifconfig eth0 | grep inet | awk '{ print $2 }'

Then open the following url in your web browser

http://youripaddress

2. Install MySQL

MySQL is the database management system used in LAMP stack.

Install MySQL command

sudo yum install mysql-server

Start MySQL service

sudo service mysqld start

Set a root MySQL password

sudo /usr/bin/mysql_secure_installation

This will prompt you for your current MySQL root password, which you will most likely have none, because you have just installed MySQL only. So just leave it blank by pressing enter.

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Next a series of yes/no questions will appear. All you have to do is just say Yes to all the options.

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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, MySQL 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 MySQL installation should now be secure.

Thanks for using MySQL!

3. Install PHP

Install PHP command

sudo yum install php php-mysql

(Optional) Install additional php modules

Search for PHP modules command

yum search php-

Next a bunch of php modules with their description will appear. So just use yum to install which ever modules that you want.

sudo yum install name_of_the_module

4. Configure Apache and MySQL to run on boot

sudo chkconfig httpd on

sudo chkconfig mysqld on

5. Test if PHP is working on your server

By default apache web root directory is at /var/www/html

Create a file called info.php 

sudo nano /var/www/html/info.php

(Optional) If nano is not installed yet

sudo yum install nano

Add the following code to info.php

<?php

phpinfo();

?>

Then save and exit

Restart Apache and visit the url on your web browser as follows

http://youripaddress/info.php

Then you should see your server’s php information

 

Feel free to contact me at [email protected] if you have any further questions.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

Amazon Web Services (AWS)ApacheCentOSDatabaseLinuxMySQLOSProgrammingServerTechnology
8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

8 Simple Steps to Setup a Web Server with Apache Virtual Hosts & MySQL in Centos

This tutorial will be guiding you in setting up a web server with pre-installed Centos. In summary, you will be installing Apache and MySQL, and learning how to configure virtual hosts in Apache. Note: before proceeding with this tutorial. Make sure you figure out...

AppleiOSMobile PhonesObjective-CProgrammingSwiftTechnology
How to install Cocoapods for Objective-C/Swift development on Mac OS?

How to install Cocoapods for Objective-C/Swift development on Mac OS?

Steps to install Cocoapods Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on...

AndroidAndroidAppleiOSJavaMobile PhonesObjective-CProgramming
iPhone Camera
Complete overview of the mobile app development process (Infographic)

Complete overview of the mobile app development process (Infographic)

Clients always have the misperception that developing a mobile app is as easy as developing a mobile application would be a walk in a park without much effort involved. The following infographic pretty much sums up the total cost and effort for mobile app...