1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

23
1 John Magee John Magee 9 November 2012 9 November 2012 CS120 Lecture 17a: CS120 Lecture 17a: Publishing Web Publishing Web pages pages

Transcript of 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

Page 1: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

11

John MageeJohn Magee9 November 20129 November 2012

CS120 Lecture 17a:CS120 Lecture 17a:

Publishing Web pagesPublishing Web pages

Page 2: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

22

Overview/QuestionsOverview/Questions

– So I got some HTML pages and stuff. So I got some HTML pages and stuff. How do I make them show up on the How do I make them show up on the web?web?

– What are web servers, anyway?What are web servers, anyway?– How do we transfer files to a web How do we transfer files to a web

server?server?– Who can see my pages?Who can see my pages?– URLs, absolute path, and relative path URLs, absolute path, and relative path

revisited.revisited.

Page 3: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

33

How to Publish a Web PageHow to Publish a Web Page

Create HTML document, locate Create HTML document, locate ancillary files (e.g images).ancillary files (e.g images).

Transfer files to web serverTransfer files to web server Set permissions for read accessSet permissions for read access Test the URL in your browserTest the URL in your browser

Page 4: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

44

Recall: Displaying a WWW Recall: Displaying a WWW PagePage

Page 5: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

55

What’s a Web Server?What’s a Web Server?

Is it hardware?Is it hardware? yes!yes!

Is it software?Is it software? yes!yes!

How is it both?How is it both?What hardware is needed?What hardware is needed?

What software is needed?What software is needed?

Page 6: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

66

What’s a Web Server?What’s a Web Server?

Web server: a software application Web server: a software application which waits for /responds to HTTP which waits for /responds to HTTP requests.requests.

Tim Berners-Lee wrote 2 applications to Tim Berners-Lee wrote 2 applications to make the web:make the web:– A web browser called WorldWideWebA web browser called WorldWideWeb– A server called HTTPdA server called HTTPd

The first WWW Server at CERN.

Page 7: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

77

What’s a Web Server?What’s a Web Server?

Today’s web servers Today’s web servers use high-performance use high-performance hardware like this:hardware like this:

(fast network and disk (fast network and disk access)access)

Pictured: IBM Blade Servers hosting Pictured: IBM Blade Servers hosting files.myopera.com, photo from Wikipediafiles.myopera.com, photo from Wikipedia

Page 8: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

88

What’s a web server?What’s a web server?

The Apache HTTP Server is the most The Apache HTTP Server is the most popular web server (since 1996).popular web server (since 1996).

Roles:Roles:– Processing HyperText Transfer ProtocolProcessing HyperText Transfer Protocol– LoggingLogging– Delivering static content from the file Delivering static content from the file

systemsystem– Running scripts to deliver dynamic contentRunning scripts to deliver dynamic content

Page 9: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

99

LAMP ModelLAMP Model

The most common structure for web The most common structure for web applications uses this configuration:applications uses this configuration:

LinuxLinux operating system for a server operating system for a serverApache Apache web server softwareweb server softwareMySQL MySQL database softwaredatabase softwarePHP/Perl/Python PHP/Perl/Python scripting language to scripting language to create dynamic HTMLcreate dynamic HTML

Page 10: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1010

How a Web Server WorksHow a Web Server Works

Receives HTTP RequestReceives HTTP Request Search for resource (file) on diskSearch for resource (file) on disk Send HTTP Response (status code + Send HTTP Response (status code +

data)data)– If not found: status 404 (NOT FOUND)If not found: status 404 (NOT FOUND)– If not permitted: status 403 (FORBIDDEN)If not permitted: status 403 (FORBIDDEN)– ……– Else: status 200 (OK) + send dataElse: status 200 (OK) + send data

Page 11: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1111

cs-people.bu.educs-people.bu.edu

Our WWW server is Our WWW server is www.cs.clarku.eduwww.cs.clarku.edu..

The web server has a file system which it The web server has a file system which it searches for a URI (resource pathnames). searches for a URI (resource pathnames).

– Subdirectories for individual users:Subdirectories for individual users: http://www.cs.clarku.edu/<username>http://www.cs.clarku.edu/<username>

– Example:Example: http://www.cs.clarku.edu/~jmageehttp://www.cs.clarku.edu/~jmagee

Page 12: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1212

Your UNIX Home DirectoryYour UNIX Home Directory

With the CS UNIX account, each user has a With the CS UNIX account, each user has a “home” directory:“home” directory:General form:General form:/home/<username>//home/<username>/

Example:Example:/home/jmagee//home/jmagee/

This has a UNIX pseudonym ofThis has a UNIX pseudonym of ~. ~.

Page 13: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1313

Your WWW DirectoryYour WWW Directory

The web server will map this URL:The web server will map this URL:http://www.cs.clarku.edu/~<username>/

to your CS UNIX’s account’s to your CS UNIX’s account’s ~/public_html/~/public_html/ directory directory

Page 14: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1414

Locate files in Locate files in Finder/Windows ExplorerFinder/Windows Explorer

Find your files on your local computerFind your files on your local computer

Page 15: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1515

How to Transfer Files How to Transfer Files to to csgateway.clarku.educsgateway.clarku.eduUse a file transfer client-program:Use a file transfer client-program:– Fetch (Mac)Fetch (Mac)

http://fetchsoftworks.com/ (a free academic license is available)(a free academic license is available)

– WinSCP (Windows)WinSCP (Windows)http://winscp.net/eng/index.php (also free)(also free)

- SSH Secure Shell (Windows)- SSH Secure Shell (Windows)

Page 16: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1616

Connecting by WinSCP:Connecting by WinSCP:

– Hostname: Hostname: csgateway.clarku.educsgateway.clarku.edu– Be sure to use the “SFTP” protocolBe sure to use the “SFTP” protocol

Page 17: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1717

WinSCP to WinSCP to csa2.bu.educsa2.bu.edu

After you After you connect, connect, transfer files transfer files by by drag’n’drop. drag’n’drop.

Then right-Then right-click to set click to set permissions.permissions.

Page 18: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1818

File PermissionsFile Permissions

File PermissionsFile PermissionsEach file has its own set of permissions Each file has its own set of permissions for:for:

– Reading, writing or executingReading, writing or executing– Owner, group, or others Owner, group, or others – This leads to a 3x3 matrix of This leads to a 3x3 matrix of

permissions:permissions:

Page 19: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

1919

Setting Permissions by Setting Permissions by WinSCPWinSCP

Right-click to open this dialogRight-click to open this dialog

Set the permissions to 644Set the permissions to 644

Page 20: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

2020

Transferring File by FetchTransferring File by Fetch

Use drag’n’drop interface to transfer files…Use drag’n’drop interface to transfer files…

Then use the Get Info button to set Then use the Get Info button to set permissions.permissions.

Page 21: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

2121

Setting Permissions by Setting Permissions by FetchFetch

Set permissions to 644Set permissions to 644

Page 22: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

2222

Testing the Webpage:Testing the Webpage:

After uploading the files, test in your After uploading the files, test in your browser:browser:

There are two special filenames that There are two special filenames that the web server looks for the web server looks for automatically:automatically:– home.htmlhome.html– index.htmlindex.html

Page 23: 1 John Magee 9 November 2012 CS120 Lecture 17a: Publishing Web pages.

2323

Take-Away PointsTake-Away Points

– Web serverWeb server– UNIX home directoryUNIX home directory– File Transfer ProtocolFile Transfer Protocol– UNIX File PermissionsUNIX File Permissions