1.3 html and 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:
- On the raspberry pi, run the following commands:
- sudo apt-get update (this updates your computer)
- sudo apt-get install apache2 -y (this installs apache web server on your computer, answering yes to all prompts)
- Go your browser and enter 127.0.0.1 (which means "me" on the internet)
- Now type ifconfig in
progressyour terminal and look forAppleyourWikiinternet address, which should start with 10.14.x.y - Look at this address using your browser
Setup your web folder, edit a page:
- changing the home page, which is always index.html on any web server:
- Next we have to fix the permissions:
- the directory where all of your web pages are stored is /var/www/html
- we need to "open" the directory so you can play in it, and not have to be sudo to change stuff (for now)
- to change the permissions on a file, we use chmod, short for "change the mode"
- permissions are in sets of three: read (4), write (2), execute (1) (to run a program)
- add them all up to get 7 to do everything
- so chmod 777 means read this file, write to this file and execute it
- you might also see these in ls -la as rwx for read, write, execute for owner, group, everyone
- so 777 would look like rwx, rwx, rwx (look with ls -la)
- type chmod 755 -R /var/www/html
- this makes everything in the html directory read and writable to you and anyone can read
- the index.html page
M9n9_4y.is the default that every web browser looks for FIRST - you can specify other names in your browser to look around
- listing the files in a directory is very useful, but also dangerous for hackers
More on permissions:
- 755: Owner (rwx), Group (r-x), Others (r-x) - Standard for scripts/folders.
- 644: Owner (rw-), Group (r--), Others (r--) - Standard for files.
- 777: Owner (rwx), Group (rwx), Others (rwx) - Public
- -R means recursive, or all folders and files below this point
HTML Challenge: Part 1: Making a new web page:
- cd to the /var/www/html directory and look around (ls -la)
- Using either nano create a new page:
- sudo nano test.html
- You'll notice this is blank.
- Add the following to your new web page:
<html>
<head>
test
</head>
<body>
Wow, this is really easy,I am now a true webmaster!Beware my awesome computer skills!
</body>
</html>
- remember to overwrite (ctrl-o), return to save, and exit (ctrl-x)
- Now go to your browser and enter http://127.0.0.1/test.html
- What do you see?
- Create your own pages in your html folder and test
- checklist: test.html with your text in it seen from the browser at your web address: http://victim.hpa.edu for example
HTML Challenge: Part 2: Create folders so you can browse your files:
- cd to the /var/www/html directory and look around (ls -la)
- make a new folder using mkdir mystuff
- cd into that folder and use sudo nano to create a new file called secret.txt
- go back to your browser and go to http://127.0.0.1/mystuff/
- look for the secret.txt file and open it with your browser
- cool! you can now download photos, images, screenshots, any file you like into your web server!
- checklist: folder inside your website
HTML Challenge: Part 3: Using a text editor to edit and create pages: (may need permissions changed to 777 see above)
- use the folder browser to navigate to the /var/www/html folder
- open a text editor and create a page called test2.html
- add code as you did with the nano editor
- save and test
- create a new folder on your web server
- create a document there with secret content
- challenge your friends to find this page
- checklist: show me the hidden folder in any browser
HTML Challenge: Part 4: Remote web page creation:
- ssh into 10.14.84.20 or victim.hpa.edu
- navigate to the /var/www/html folder
- create a folder with your name (short version all lowercase, no spaces)
- create a document in html inside the folder
- browse from your station to verify your new web site!
- challenge your friends to read your secret message
- checklist: a folder on the http://victim.hpa.edu website in your name, with an html document inside
Next steps: https://www.w3schools.com/
HTML and w3schools challenge
- create some pages using the w3schools tutorials: must include:
- headings
- paragraphs
- links
- images
- list format
- copy this code into your local web server, test
- copy this code into the victim.hpa.edu server, test
- checklist: seeing your code on the http://victim.hpa.edu website
- external access: http://sensor.hpa.edu:8090
Examples: copy these html codes into your computer using nano and separate name and check the pages with your browser:
(to find your hard drive on the mac, click on the desktop, hold command-comma and select hard drive and connected servers)
From Leo: leo.html
<!DOCTYPE html>
<html>
<body>
<h1> Hello World </h1>
</body>
</html>
<html>
<body>
<h1> Hello World </h1>
</body>
</html>
From Ana Sofia: ana.html
<!DOCTYPE html>
<html>
<head>
<title> This is my homework!! </title>
</head>
<body>
<h1>This is the first heading of my homework :p</h1>
<p>And this is the first paragraph, helloo Dr. Bill</p>
</body>
</html>
<html>
<head>
<title> This is my homework!! </title>
</head>
<body>
<h1>This is the first heading of my homework :p</h1>
<p>And this is the first paragraph, helloo Dr. Bill</p>
</body>
</html>
From Dominik: dominik.html
<!DOCTYPE html>
<html>
<head>
<title>Dominik's Page</title>
</head>
<body>
<h1>Welcome to my webpage</h1>
<p>Hey, I am Dominik, and I have a dachshund named Luna</p>
</body>
</html>
<html>
<head>
<title>Dominik's Page</title>
</head>
<body>
<h1>Welcome to my webpage</h1>
<p>Hey, I am Dominik, and I have a dachshund named Luna</p>
</body>
</html>
here's one that does not work: find out why and repair this cool page:
From Rella: rella.html
<!DOCTYPE html>
<html>
<head>
<title> Rella’s wed page/ title>
</head>
<body>
<h1>Welcome to Rella’s web page</h1>
<p>I am a student at Hawaii Preparatory Academy.</p>
<h2>About Me</h2>
<p>I like cheerleading and listening music.</p>
<h2>My Favorite Things</h2>
<ul>I’m
<li>Cheerleading</li>
<li>Music</li>
<li> Spending time with my family</li>
</ul>
<p>This is my first HTML page!</p>
</body>
</html>
<html>
<head>
<title> Rella’s wed page/ title>
</head>
<body>
<h1>Welcome to Rella’s web page</h1>
<p>I am a student at Hawaii Preparatory Academy.</p>
<h2>About Me</h2>
<p>I like cheerleading and listening music.</p>
<h2>My Favorite Things</h2>
<ul>I’m
<li>Cheerleading</li>
<li>Music</li>
<li> Spending time with my family</li>
</ul>
<p>This is my first HTML page!</p>
</body>
</html>
Migrated from Apple Server Wiki. Original page ID: M9n9_4y