Web servers

Lecture content

The presentation

A presentation about the web and web servers

Resources

Demos - Apache

Resources

https://httpd.apache.org/docs/2.4/

Installing Apache2

  • Install Apache
    sudo apt-get update
    sudo apt-get install apache2
  • Configure the firewall, use sudo ufw app list to see the names of install services
    sudo ufw allow 'Apache Full'
    sudo ufw allow OpenSSH
    sudo ufw enable
    sudo ufw status
  • Control Apache
    • Apache status systemctl status apache2
    • Stop Apache service sudo systemctl stop apache2
    • Start Apache service sudo systemctl start apache2
    • Restart Apache, connections to the web server will be lost sudo systemctl restart apache2
    • Reload configuration, reload without dropping connections sudo systemctl reload apache2
    • Disable the Apache service to start up at boot sudo systemctl disable apache2
    • Re-enable the service to start up at boot sudo systemctl enable apache2

Configure Apache 2

  • Create the Directory Structure and permissions
    sudo mkdir -p /var/www/jl222gk.devopslab.xyz/public_html
    sudo mkdir -p /var/www/test.jl222gk.devopslab.xyz/public_html
    sudo chown -R $USER:$USER /var/www/jl222gk.devopslab.xyz/public_html
    sudo chown -R $USER:$USER /var/www/test.jl222gk.devopslab.xyz/public_html
    sudo chmod -R 755 /var/www
  • Create Demo Pages for the sites
    • nano /var/www/jl222gk.devopslab.xyz/public_html/index.html
      <html>
      <head>
      <title>Welcome to jl222gk's page!</title>
      </head>
      <body>
      <h1>Success! jl222gk's page is working!</h1>
      </body>
      </html>
    • nano /var/www/test.jl222gk.devopslab.xyz/public_html/index.html
      <html>
      <head>
      <title>Welcome to jl222gk's Test page!</title>
      </head>
      <body>
      <h1>Success! jl222gk's Test page is working!</h1>
      </body>
      </html>
  • Create New Virtual Host Files
    • Copy the default config sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/jl222gk.devopslab.xyz.conf
    • Edit the config for the first site sudo nano /etc/apache2/sites-available/jl222gk.devopslab.xyz.conf
      <VirtualHost *:80>
      ServerAdmin admin@jl222gk.devopslab.xyz
      ServerName jl222gk.devopslab.xyz
      ServerAlias www.jl222gk.devopslab.xyz
      DocumentRoot /var/www/jl222gk.devopslab.xyz/public_html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
    • Setup the second site by coping the first sudo cp /etc/apache2/sites-available/jl222gk.devopslab.xyz.conf /etc/apache2/sites-available/test.jl222gk.devopslab.xyz.conf
    • Edit the config for the first site sudo nano /etc/apache2/sites-available/test.jl222gk.devopslab.xyz.conf
      <VirtualHost *:80>
      ServerAdmin admin@test.jl222gk.devopslab.xyz
      ServerName test.jl222gk.devopslab.xyz
      ServerAlias www.test.jl222gk.devopslab.xyz
      DocumentRoot /var/www/test.jl222gk.devopslab.xyz/public_html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
      </VirtualHost>
  • Enable the new sites with a2ensite
    sudo a2ensite jl222gk.devopslab.xyz.conf
    sudo a2ensite test.jl222gk.devopslab.xyz.conf
  • Disable the default site with sudo a2dissite 000-default.conf
  • Restart Apache 2 sudo systemctl restart apache2

Nginx configuration

Resources

Demo - Getting started

Demo - Node.js web apps

Denna video visar hur man installerar node.js och kör igång en enkel node-applikation på en Ubuntu 18.04. Videon har ett litet abrupt slut då den är uppdelad i två delar.

Demo - Reversed proxy/Load balancer

För mer information om att konfigurerar nginx:n kolla denna artikel: https://www.digitalocean.com/community/tutorials/understanding-nginx-http-proxying-load-balancing-buffering-and-caching

Välkommen till CoursePress

en utav Linnéuniversitets lärplattformar. Som inloggad student kan du kommunicera, hålla koll på dina kurser och mycket mer. Du som är gäst kan nå de flesta kurser och dess innehåll utan att logga in.

Läs mer lärplattformar vid Linnéuniversitetet

Studentkonto

För att logga in behöver du ett studentkonto vid Linnéuniversitet.

Läs mer om att hämta ut studentkonto

Inloggning LNU