Install LAMP (Linux, Apache, MySQL & PHP) on Ubuntu 17.10

LAMP

Good morning, this time I will show you how to install LAMP (Linux, Apache, MySQL & PHP), this great set of tools open source that allow us to run and host web applications on our computer.

By which is still an excellent option if you want to start with what is web application development or start writing your first web programming projects.

From the first instance we must update all the packages of our system, for this we must execute the following commands in the terminal.

sudo apt update
sudo apt upgrade

How does iInstall LAMP on Ubuntu 17.10?

Now from now on we must install the applications that build LAMP, as previously described, first-hand iWe will install Apache on our system.

Install Apache web server

apache 2

The package apache2-utils it will install some utilities like Apache HTTP Server Benchmarking Tool.

To install it, we do it with the following command:

sudo apt install -y apache2 apache2-utils

After it is installed, Apache should start automatically. We must verify with systemctl.

sudo systemctl start apache2
sudo systemctl enable apache2

Now we must enter our ip or we must only write localhost or 127.0.0.1 in the address bar of our browser to check that the Apache server is running correctly on our computer.

After this we just have to execute the following command:

sudo chown www-data: www-data /var/www/html/ -R

Install the MariaDB database server

MariaDB is a direct replacement for MySQL, to install this database we must execute the following command:

sudo apt install mariadb-server mariadb-client

After it is installed, the MariaDB server should run automatically.
If it is not running, we will start it with this command:

sudo systemctl start mariadb

To allow MariaDB to start automatically at boot time:

sudo systemctl enable mariadb

Now we need to run the post-install security script.

sudo mysql_secure_installation

During this process it will ask us to assign a password to the root user in the database, once this is done we proceed to the next step.

Then we must press Enter to answer all the remaining questions, which will remove the anonymous user, it will disable the root login and remove the test database.
This step is a basic requirement for the security of the MariaDB database.

By default, the MaraiDB package in Ubuntu uses unix_socket to authenticate the user login, which basically means that you can use the operating system username and password to login to the MariaDB console.

Install PHP on Ubuntu 17.10

php 7.1

En at the moment the stable version of PHP is 7.1 So if you use this tutorial to versions later than this, you only have to change the dependencies and packages required here by their current versions.
To install it we just have to run:

sudo apt install php7.1 libapache2-mod-php7.1 php7.1-mysql php-common php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-readline

Now dYou must enable the Apache php7.1 module and then restart the Apache web server.

sudo a2enmod php7.1
sudo systemctl restart apache2

Now what we can do is create a file that shows us all the PH informationQ, to test the PHP scripts with the Apache server, we need to create an info.php file in the root directory of the document.

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

Add the following PHP code to the file.

<? php phpinfo (); ?>

Save and close the file.

Now in the address bar of the browser, enter 127.0.0.1/info.php or localhost / info.php .

They should see your server's PHP information. This means that PHP scripts can run successfully with the Apache web server.

I just have to remind you that always the address on which you will work is that of "localhost" or "127.0.0.1", which is the one that you will put in your web browser, from there you only have to place the path of your projects.

And that's it, we already have the necessary tools installed to start running our web applications on our computer.
Without further ado, it only remains for you to start using it, you can install WordPress, Joomla or some other tool to do your local tests.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Pablo said

    The guide is very good, just a comment, in the command: sudo chown www-data: www-data / var / www / html / -R, it should remove the white spaces, very dangerous; it should be: sudo chown www-data: www-data / var / www / html / -R. With the blank spaces, being root, who executes it, will change the owner and group of the root (/) and all the child folders.

    Also in: ; not so dangerous, like the previous one, it should be:

    1.    Noe said

      Hello Pablo, I made the mistake of copying and pasting please if you could help me from this error

      sudo chown www-data: www-data /var/www/html/ -R

      I copied it with the spaces and now I cannot run any application I do not have and neither does it accept the password to access as root

      i am new to linux.

  2.   Alejandro Suarez said

    Hello friend, thanks for your great contribution, do all the steps with satisfaction, the only thing is that when making the verification «localhost / info.php» the page remains blank and does not show anything, hopefully it is not a problem .

    1.    David yeshael said

      Hello Alejandro.
      The safest thing is that you have blocked the function in your php.ini
      In it you can configure several parameters, test on the terminal with
      php –ini

    2.    asdasd said

      Hello Alejandro, because it is due to the spaces between