Schulung-Teil3-Webserver aufsetzen

From revampedia
Jump to: navigation, search

This training took place on 11-17-2016 and it's the continuation of Teil2. The first virtual machine is going to become a web server (Apache). JR

If there are still questions open after these instructions, please go to "Views" and then "Discussion" to leave your feedback, so I can add more Details to this page. jr

Login to the virtual machine via SSH

On the newly created virtual machine did we create a new username with password and installed sudo. Now we can login to the machine via SSH:

ssh user1@vm1

Install packages for the web server

Since we've just created the virtual machine the package list of apt is up to date. If some time has passed since the creation it would necessary to first enter the command "sudo apt update".

sudo apt install apache2 apache2-bin apache2-utils apache2-doc

After the packages have been installed you can enter the IP address of the virtual machine in a browser. To find out your IP address enter the command "ip a" in your console.

Now we have a web server running.

At this point we had to cancel our training session as the hard drive of the LTSP server crashed.


Infos

On 12-15-16 we had another training session with a different teacher. Unfortunately we lacked the time to to install something new to our server, but we've learned a few things.

With the following command you can find out the IP address of your server in an LTSP system.

sudo arp 

The command also works on other devices where you have sudo rights. With ARP you can see your "neighbors" in an IPv4 network. It does not mean the neighbors in the house or appartement next door, but other devices in the same network. As we've written down the MAC address of our server we can determine the IP address of it. After we've managed to get back on our virtual machines we've learned two new ways to check if the web server is running or not

Option 1

ps -ef | grep apache

The command "ps" shows us active processes on a computer. The parameters "-e" and "-f" (combined to -ef) tell the system that we wish to see all processes and that we wish to see more details. With the pipe symbol we take the output of the command and hand it over to the command "grep". With "grep" we can filter the result. We only want to see processes that contain "apache" and not the whole list.

Option 2

sudo systemctl status apache2

The command "systemctl" is part of systemd. For a beginner this is probably too advanced to go into detail. I myself can only say that I know it exists and our first teacher isn't a big fan of it from what he told me so far.

Option 3

This option we've already used on 11-17-16. We entered the IP address of our VM in the browser and checked if we get the test page.

Management of web sites

On the test page is written that we can find the page at the following place on our system:

/var/www/html/index.html

on our virtual machine with the web server we go to the following directory:

cd /var/www/html/

To look at the content of the file we use the program "less"

less index.html

The file contains the HTML code and the text of the web site. As we're not planing on learning HTML we leave it at that.


If you've read CLI-Teil1 and the in section of Filesystem Hierarchy (Verzeichnisstruktur if I haven't translated the page yet) you can expand the text, that you can see that in /etc/ are configuration files. So, to change the displayed web site you need to go into the sub-directory of Apache in /etc/.

cd /etc/apache2/

To see all the content of the directory you need to use the command ls with the parameters -l (more details) und -a (show everything, even hidden files)

ls -la

Here we have several directories that begin the same but have differnt endings. The two possible endings are -available and -enabled. To manage a web site you work in the directory sites-available and you create a link to sites-enabled. So, to enable or disable a web site you create a link or remove it.


Here's where the training on 12-16-16 ended. At another point we'll probably learn more about web servers and how to set up kivitendo.
,