https://dev.webpages.dk/  
 
The LAMP stack Installation
The LAMP stack installation

This text is showing you in details how to install a complete LAMP stack.
First we install the Linux Mint. And then the Apache webserver, the MySQL database server, then PHP and phpMyAdmin.

The page is with plenty of snaps form the installtion, all from the video about the same subject.

Your new web developing environment

aka

How to Install a complete LAMP stack, step by step

( Also seen as a video @ https://dev.webpages.dk/ )


This tutorial is written to help you with the installation of a LAMP stack.
But what is a LAMP stack anyway?
LAMP will give you a good environment for your developing of webpages.
The whole setup is based on free software. Even the operating system is for free.
In this tutorial I use the “Linux Mint Mate” as an OS to install on the Asus Zenbook, that I want for my developing environment. But there are more than 600 different Linux variants. So go search and find the one that suits you.



Linux was, in first steps, created to handle networking. And it is in present days widely used as server units, running most of the servers on the Internet. But it is also a desktop OS. And a good one.
In the older days you really had to be somewhat of a wizard, doing much work in the terminal. And is was common to compile and install the software to use on the system, from source code, on your own.
Now, here in more recent times the OS is also available for people like myself. Who is more a “Mouse man” than a “Terminal man”. The system is more user friendly and you can really go a long way without having to use the terminal much. Not to say the terminal is not good, it is, in some situations its both simpler and faster. I use the terminal to install the rest of this LAMP stack.
It is, in the software available, now, very useful for people who may not be a terminal wizard, but a more plain user. But in all, and for all, its an awesome piece of engine for your machinery. Also Linux is known to be able to run on anything, or many things. For hardware for the common use, as desktop OS, you can install Linux on much of the available PC hardware. So you can make use of the cheaper offers of some of the widely spread hardware, much that have been made for the MS Windows environment, that is really mass produced and therefor cheaper. But still we need the manufacturers to put labels on the hardware that is compatible with Linux. Some do this but they are too few still.
Well enough philosophy for now. Lets continue...

The “L” in “LAMP” is the operating system, and it is as said Linux. The distro is the Linux Mint, and the chosen windows environment is “Mate”.
Go and find the latest version of Linux Mint Mate (www.linuxmint.com), and download it to your machine. When that is done, (Its about 2.0GB), you now have to prepare a USB stick, or a DVD with the ISO file you have just downloaded.

To prepare the installation DVD, you will have to open your favorite disc burning software. Here you have to start a new project being an “Image” that you want to write to disc. Find and open the .ISO you have just downloaded. Insert a DVD and burn the ISO to the disc. After that is complete you should have a bootable Live! installation media ready.

The system being a LIVE medium, means that you can boot it, and try it in many ways, without having to write anything to disk. So if you want to give it a test even before installing, then you can boot the install USB disk or DVD, and try the programs available in the LIVE medium, and what else you may want to check out.

To make the bootable USB stick you have to do a similar, yet a little different procedure. You will need a small program for making the USB stick bootable with the ISO file written to it. If you dont have a USB stick, you can use a cardreader with a ram card in it. You will need a 4 GB card, or stick to contain the ISO.





When you start your machine press F2 (can differ) after the first logo by your PC manufactor. You will need to be sure that, or change the order of, that devices your target computer should boot from. If you have an OS of any kind installed, then you should be sure that the HDD or SSD in your PC is further down the list than the USB or DVD (depending on you install media). You will need to have your boot medium highest in the list of available mediums (HDD or SSD). If you see a “Boot on LAN”, then you should move that further down, after the HDD/SSD. But simply; put the device you will boot from as the top one.



You may have to get back in here afterwards, and change the boot order back to some other drives, to be the first in the queue, to start up, when booting you PC. Now you have to boot from that DVD or USB stick we just made, and for that you have to boot your target computer with either the DVD drive or USB stick connected. Now the installation should begin. To be guided through the installation go and watch my video here at forbindelse.dk..
But lets take it again, also here in this document.
The first screen when booting the LIVE system is this;



To start the installation, you have to double click on the icon on the desktop saying “Install Linux Mint”.

So now the installation begins and you will be guided through the installation process step by step. Again, if you are in doubt of anything, go and watch that video here..

Here I will list the screens that you go through during the installation;

List of all to be done:
  • Format and write the ISO to USB stick
  • BIOS – Boot order
  • Boot to LIVE screen
  • Begin installation
  • Partition the drives
  • Go through all screens of installation
  • Finish the installation
  • Boot for the first time
  • Install Apache
  • Install PHP
  • Install MySQL
  • Install phpMyAdmin

This is the page where you will prepare the drives. In this example I use a laptop with a 24GB SSD, and a 750GB HDD.
Also I assume that you have nothing you want to keep on those drives. If you do - make backup before this, if you start this partitioning, all content on your drives will be gone for good, when you click the “Install Now”.
So, now, here we see two drives (sda and sdb), we prepare them both by removing the old partitions. Then we setup some new.



Partitioning; delete all current partitions by clicking “-” (minus), then:
“+” on 24GB, setup one part, ext4 set as “/” (Root)
“+” on 750GB, one part, at 8192 Megabytes. Set as “SWAP”
“+” on 750GB, set a partition, at 50 Megabytes. Set as “EFI System Partition”
“+” on 750GB, one partition, all the remaining space. Set as “/home”
Set the partitions to be formatted. ( Checkbox )
“Continue” > Start partitioning and formatting



First we have to prepare the 750GB. Here we will create three partitions one we will make into a “SWAP” partition. Amd one will be for the boot loader.
Its a good rule to make the SWAP at the size of your amount of RAM. So here we will setup an 8GB partition and make it a “SWAP”, that we can select in the dropdown box. A SWAP partition is used by the system as a kind of extra memory. We also have to make a 50MB partition for the boot loader. In the selectbox you can select the “EFI System partition”.
Now we have the rest of the 750GB, and we will create our last partition filling up the space we have left. This we will select to be our “/home” drive. That is where you keep all your documents, and maybe files like photos, videos and music and what you may have.
Now I will select the 24GB and create one partition on the full size. This partition we will choose to be the system drive. So we select the “/” meaning its the “Root” of you new installation. Where the system will rest. Don’t confuse the “Root” of the system drive with the root user in Linux, they are not the same. We will make the new partitions to be of the “ext4” kind, the newest file system for Linux as for now.

The drives will be partitioned and formatted and we continue to the next step in our installation of the LAMP stack. As we will now soon have our “L”.

I, on purpose, selected the manual partitioning of our drives, as that may guide you about managing drives in the installation of Linux. You could maybe have selected one of the other ways to install the OS. If you have an existing OS installed that you may want to erase, or make the new installation a dual boot, so if you f.ex, had a MS Windows installed, then you can make them being dual boot, what means that you at early startup of the computer can select which operating system you want to start. It will be the easiest way to install Linux with an already existing Windows installation. Linux handles this good, what not really can be said about Windows. So if you want to have the choice of which to select at boot, then Install the Linux as the second OS.

So, now the installation preparation is complete, and you will be asked to unplug the install medium and hit “Enter” to reboot. Now you are supposed to startup on the new installation.
If you didnt select the “Login automatically”, then you will now need to write in your password to enter the desktop.



What we now have to do, is to install the rest of the LAMP stack, where the “A” is for Apache. Go online and open the terminal.
We will have to update the repository first though. This is done by executing this command;

$ sudo apt update



After that is completed. Write in this line;
$ sudo apt install apache2



After the download and installation of Apache has finished we can check to see if Apache is working, open you internet browser and aim in on this URL;
http://127.0.0.1/
This should take you to a page, showing that Apache is up and running.



Now I will go to the “P” in “LAMP”, yes I know, but we will get back to the “M” in just a second. First we will install the PHP scripting language for our LAMP stack.
Again in the terminal, write in this;
$ sudo apt install php libapache2-mod-php



So now we have both the webserver and our scripting language. But lets check that. There is a way to check if all is okay with the PHP. In terminal do this;



$ sudo rm /var/www/html/index.html
– This will delete the index.html file from the root of your web installation.
Open a texteditor, f.ex nano, like this;
$ sudo nano /var/www/html/index.php
That will open the small texteditor inside the terminal.
It will show you a blank page. Then now write this line;
<?php phpinfo(); ?>



Try and use the keys; CTRL+X – now you will be asked if you want to save the buffer?“ write “Y” and then hit “Enter”. Then your new index.php file is created with that single line of PHP code.
Now you can check the PHP install by calling that same URL again;
http://127.0.0.1/



(As you might have guessed the path “/var/www/html/” is the path to your web content). Go open the filemanager (Caja) and navigate to that path to see what you have there.
As you see on the page that the browser shows the PHP installation is ready, and at the very top you see the versions number of PHP, as it is, now, on your soon completed “LAMP” stack.

So to continue we will now install the MySQL database.
Again, in the terminal, write this;
First:
$ sudo apt install mysql-server

Secondly:
$ sudo mysql_secure_installation

This will open a page where you now will be guided through the setup of the MySQL database server.

Now that the MySQL database is installed, we just need to finish the user we created during the setup. Again, open your terminal and write in this;
$ sudo mysql
Then..
mysql> CREATE USER 'nickname'@'localhost' IDENTIFIED BY 'Test1234#';

Then insert this following line into the terminal;

mysql> GRANT ALL PRIVILEGES ON * . * TO 'nickname'@'localhost';

Next;

mysql> FLUSH PRIVILEGES;
Then;
mysql> exit



Now you have a user for your database with a password, and the rights to create databases.

Now we need to install “phpmyadmin” that is a database manager written in PHP.
In the terminal, this time, do this;

$ sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl



Try now this, in your webbrowser;
http://127.0.0.1/phpmyadmin/



This will give you a page where you can login. You should login by the username “nickname” and the password “Test1234#”, or what you may have written just above, when setting up the database user.



Icons made by Freepik from www.flaticon.com Here is a tutorial about how to install a complete LAMP stack. Notice that this tut is also available as a video here
13:15:37