How To Setup LAMP Configuration On CentOS

< Back to the Title Topic

How To Setup LAMP Configuration On CentOS

You may need to set up a LAMP server if you are planning to run your site using content management systems such as WordPress or Joomla.

LAMP is an acronym for Linux, Apache, MySQL and PHP; four of the most commonly used software to host and run virtually all websites on the Internet.

Linux – Choice of operating system, ie: Red Hat, CentOS, Ubuntu.

Apache – Web server application.

MySQL – World’s second most widely used relational database management system (RDBMS).

PHP – Server-side scripting language designed for web development and general-purpose programming language.

To start, you will need access to your web server. 

To Install Apache

1) Run the following command using the server’s terminal.

yum install httpd

2) Start Apache service after the installation is completed.

service httpd start

3) Stop iptables and set Apache to start itself after server reboots.

service iptables stop
chkconfig iptables off
chkconfig httpd on

*You’ll not be able to access the Apache Test Page if iptables is not turned off.

4) Type http://your-ip-address-here in your browser’s address bar to check if you have performed step 2 correctly.

If successful, you should see the Apache Test Page.

To Install MySQL

1) Run the following command using the server’s terminal.

yum install mysql-server

2) Start MySQL service after the installation is completed. MySQL database will initialize and start. You do not have any login credentials to MySQL at this stage.

service mysqld start

3) There are two ways to create a user account to access MySQL.

/usr/bin/mysqladmin -u root password 'insert-your-desire-password-here'



The first method will grant you direct access to MySQL. The second method, which is the preferred method, will guide a user through a series of steps and options to remove a test database and anonymous user created by default.

You can now access MySQL database by typing the command into your server’s terminal.

mysql -u root -p

To Install PHP

1) Run the following command using your server’s terminal.

yum install php php-mysql

2) Create a new file by running the command below to check if PHP has been successfully installed and is now working on your server.

vi /var/www/html/info.php


3) Type and save the command below into the newly created file.

4) Restart Apache service.

service httpd restart

5) By now, your server is able to run any PHP-scripted software. Type http://your-ip-address-here/info.php into your browser’s address bar and if successful, you should see something similar as below else repeat Step 1.

You have successfully installed LAMP on your server and ready to run your website using WordPress or Joomlah.

Previous How to install WordPress in Ubuntu
Next How to change MySQL database user privileges (DirectAdmin)