How to setup LAMP configuration on Ubuntu

< Back to the Title Topic

How to setup LAMP configuration on Ubuntu

You 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. 

You can easily install LAMP onto your server by running the commands below.

sudo apt-get update
sudo apt-get install lamp-server^

That’s it. You have successfully installed all four web server applications with two commands.

However, if you prefer to install them individually, please continue reading.

To Install Apache

1) Run the following command using the server’s terminal. Apache will start automatically upon successful installation.

sudo apt-get install apache2

2) 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 “It works!” on your site.

To Install MySQL

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

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

You will be prompted to enter a password and another time for confirmation for root access. See image below.

When the installation is completed, you can access your MySQL database by running the command below using your server’s terminal.

sudo mysql -u root -p

It is highly recommended and a best practice to remove the test database and anonymous user from your MySQL database.

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

sudo mysql_install_db

2) Enter the following command into the terminal after Step 1 has completed.

sudo /usr/bin/mysql_secure_installation

Note: If you have forgotten the password that was set earlier, enter the command below into your terminal to reset your MySQL root password before you proceed with Step 2.

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

You should now be able to login to MySQL database with the following command.

sudo mysql -u root -p

To Install PHP

1) Run the following command using your server’s terminal. Once completed, PHP is installed.

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

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.

sudo vi /var/www/info.php

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

4) Restart Apache service

sudo service apache2 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 enable remote access to MySQL database?
Next How to install WordPress in Centos