XRL Tech Corner

Blog
Font size: +

How to install Apache, PHP and MySQL in Ubuntu

The following tutorial is intended to explain how to install LAMP, a series of packages aimed at offering dynamic web services, ie web pages that are able to access a database through a development framework that is PHP , among other things. We will see that it is very simple and it is only about following the steps one after the other.

This configuration is usually called LAMP (Linux Apache MySQL PHP) .


In broad strokes, and without going into detail, Apache is a web server, necessary to show most of the pages we see on the Internet,

MySQL is a database, where we can store and consult data that will be displayed on our web pages and PHP is a framework that provides dynamic content to our website through access to the database (among other features).


For this tutorial we will use our Ubuntu virtual machine created in the tutorial How to install Ubuntu in a VirtualBox virtual machine .


We will start by booting the virtual machine to access the Ubuntu desktop and once inside the system, we will open a Terminal (Ctrl + Alt + T) , and perform all the actions from there.

AMP tutorial ubuntu desktop



The package manager that we will use to install all these packages will be " apt ".


We start!



First. Apache


Write in the Terminal:


sudo apt-get update


And later:


sudo apt-get install apache2



The first will update the list of repository packages and the second will install apache2. We will ask for confirmation to install, with what we will have to enter " S " and press " Enter ".


Once it is finished, we will check that the web server works, accessing through our browser to the address http: // our_IP or localhost.

AMP apache it works tutorial



We can try it from the inside by opening the Mozilla FireFox, although the interesting thing would be to access it from one of our network devices.


To see the private IP that our virtual machine has, we can type ifconfig in the Terminal and the following will appear:

Carlos @ tutorial: ~


In the section of Direc.inet we have our IP address.

We can check it from another computer by entering http://192.168.1.49 (insert yours).

If everything went well, we will see the Apache page by default in the browser (we have shown you above).



Second. MySQL


We write in the Terminal:


sudo apt-get install mysql-server php5-mysql


During the installation the script will ask us to choose a password for the administrator of the database.

This is a user that has many privileges, so we have to keep it safe and choose a "strong" password.


Once the installation is complete, we will configure it.

To start we will establish the directory structure of the database, for this we will write in the Terminal:


sudo mysql_install_db


Then we will execute a script that debugs security failures and changes default options.


We wrote:


sudo mysql_secure_installation


Possibly ask us to change the administrator password, although it is not necessary, and we can leave it.


To accept the rest of the parameters by default we simply have to press " Enter ".


Third. PHP


To install it, we will write in the Terminal:


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



This will install us PHP with the default options.

Let's configure the way Apache serves the pages by going to / etc / apache2 / mods-enabled /

and there we will change the dir.conf file.

As you have root permissions, we will have to do a sudo, for example if we want to use the VI editor it would be:


cd / etc / apache2 / mods-enabled /

sudo vi dir.conf


And we change:


DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm


by


DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm



so that it serves the php pages first.


For the changes to take effect we will have to restart Apache:


sudo service apache2 restart


with these actions we will have the necessary components installed.

We are going to do a PHP test.


By default Apache leaves the structure of web files (html, css, js, img, etc ...) in the / var / www / html directory


So let's create a test file called test.php with the following:


cd / var / www / html

sudo vi test.php


and write to the file:


phpinfo ();

?>


we record it and then we access it from the browser to the address http: // our IP / prueba.php


This will give us a page with a lot of PHP information:

AMP infophp tutorial


Once we have tested it, we proceed to eliminate this file:


sudo rm /var/www/html/test.php

This tutorial is essential to install Wordpress (blog), owncloud (private cloud), phpBB (forums), Drupal (CMS), Moodle (LMS).

In the following tutorials we will continue to expand these topics in detail.

Rate this blog entry:
Install Wordpress on ubuntu
How to earn bitcoins by playing

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Guest
Wednesday, 18 September 2019

Captcha Image