Wednesday, September 27, 2017

Debian Linux Stretch - Installing The LAMP Stack

This Linux Thing is no more difficult than your Windows Thing.  Let that sink in.

It's an operating system.  You have probably been using Windows since you were a wee brat.  That is bound to be years and years of training.  I've been using Linux since the mid 1990s, probably earlier.

Oh and I am still learning.  I like to learn so that's why I keep coming back.

One very important point - It's all about how good you are at finding the Correct Instructions.  

I spent three hours going through some instructions that were from the Debian Wiki until I hit a road block.  That led me to realize that the Debian Wiki has an incomplete article on how to install the LAMP Stack on an older version of the operating system.  Even if I had read it through top to bottom first, I would not have found that out until I actually started using it.

LAMP is what you are installing.

  • L is Linux.  If you got here, you have it or are researching it.  Debian, or a derivative like Ubuntu.
  • A Is Apache.  That is the actual web server.  You can write basic web pages if you have this installed.
  • M is MySQL or MariaDB.  It's the database so you can write data driven pages.
  • P is PHP or it could be Python or Perl.  That's your scripting language.

"Yeah, I know, me too."  That was basic stuff for people just learning.

At any rate, I went back to the web and found another page from which I am using for my own instructions.  If something isn't quite right with what I am writing below, then check back there.

This is a recipe so I can come back later when I get interested in trying this on another machine.

Importantly, there is a design strategy called "Don't Break Debian".  Don't install anything outside of Debian's Repositories or you may end up with a broken install.  While that is a bit impractical in many cases, and I have gone "outside" Debian, things do sometimes not work or they work strangely. 

If you find an install somewhere that says add a repository, then your caution flags should go up.

On the other hand, it also implies that you should use Debian's information first before you go outside to another site.  Since i am writing this, it shows that I don't agree.  Their info was flawed.

Here are the instructions, as brief as possible:
All commands are done from Terminal as Root.

Prep - Get the Computer up to date.:
  • apt update
  • apt upgrade
  • apt dist-upgrade

  • apt install mariadb-client mariadb-server
  • mysql -u root -p   (add a root password)
  • CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
  • GRANT ALL PRIVILEGES ON newdb.* to 'bill'@'localhost';
  • quit

  • apt install php7.0 php7.0-mysql

  • apt install apache2 apache2-mod-php7.0

Testing the Server
  • mousepad /var/www/html/index.php
  • enter this on the first line, save, and quit:  <? php phpinfo( ) ?>
  • firefox localhost/index.php 
  • Result is you will see information about your system in Firefox, or chrome if you must.

  • apt install phpmyadmin
Answer following questions by hitting space and then tab to OK and enter:
  • Web Server: Apache2
  • MySQL Application Password - same as you created earlier
Test with the following to get to the PHPMyAdmin login page:
  • firefox localhost/phpmyadmin

That's it.  You're done.  Took me less time than installing the operating system which was under a half hour.  Granted I'm on a fast computer and reasonable internet speeds.

There is one more thing to consider.  I am not worried about anyone hacking my server because this is not exposed to the internet.  If you are going to proceed with this server serving pages to the world, you will most certainly need to get the security brought up to date.  I don't believe that this server even has a firewall active at this point.

No comments:

Post a Comment