Skip to main content

Module 4: web servers

Migration

Module 4: web server and web pages (html)

see also https://elab.hpa.edu/cs/TC/TC%205.0%20HTML.pdf

Background:

  • html stands for hypertext markup language
  • it is a markup language, not really programming like python or C
  • it manages how information is presented ("marked up") for viewers
  • others include xml and xhtml, both managing data as well as format (more on this soon)

Installing a web server:

  1. On the raspberry pi, run the following commands:
  2. sudo apt-get update (this updates your computer)
  3. sudo apt-get install apache2 -y (this installs apache web server on your computer, answering yes to all prompts)
  4. Go your browser and enter 127.0.0.1 (which means "me" on the internet)
  5. Now type ifconfig in progressyour terminal and look for Appleyour Wikiinternet address, which should start with 10.14.x.y
  6. Look at this address using your browser

Setup your web folder, edit a page:

  1. On the terminal, navigate to the following directory:
  2. cd /var/www/html/
  3. run the ls command, you should see a file called index.html
  4. You can edit this, either by using the nano command (cooler) or later using text editor (simpler)
  5. sudo nano /var/www/html/index.html
  6. This is a complex bit of html, so just look for something you recognize from the 127.0.0.1 test and change it
  7. nano is a text editor, so ctrl-o means overwrite, and ctrl-x means exit
  8. If you are using a text editor, it might not let you save.
  9. Back to permissions----
  10. type chmod 770 /var/www/html
  11. which makes everything in the html directory read and writable to everyone (including you)
  12. the index.html page w2Z0s3H0A.is the default that every web browser looks for FIRST
  13. you can specify other names in your browser to look around
  14. listing the files in a directory is very useful, but also dangerous for hackers

Making a new web page:

  1. cd to the /var/www/html directory and look around (ls -la)
  2. Using either nano create a new page:
  3. sudo nano /var/www/html/test.html
  4. You'll notice this is blank.
  5. Add the following to your new web page:

<html>
<head>
test
</head>
<body>
Wow, this is really easy
</body>
</html>

  1. remember to overwrite (ctrl-o) and exit (ctrl-x)
  2. Now go to your browser and enter http://127.0.0.1/test.html
  3. What do you see?
  4. Create your own pages in your html folder and test
Using a text editor to edit and create pages:
  1. use the folder browser to navigate to the /var/www/html folder
  2. open a text editor and create a page called test2.html
  3. add code as you did with the nano editor
  4. save and test
  5. create a new folder on your web server 
  6. create a document there with secret content
  7. challenge your friends to find this page
Remote web page creation:
  1. ssh into 10.14.88.81 (pi-alpha.hpa.edu) as pi/papaya77
  2. navigate to the /var/www/html folder
  3. create a folder with your name (short version all lowercase, no spaces)
  4. create a document in html inside the folder
  5. browse from your station to verify your new web site!
  6. challenge your friends to read your secret message 

  1. create some pages using the w3schools tutorials
  2. copy this code into your local web server, test
  3. copy this code into the pi-alpha server, test



Migrated from Apple Server Wiki. Original page ID: w2Z0s3H0A