Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial Shengdong Zhao (some slides are reused/modified from Neil Ernst’s apache tutorial)

Similar presentations


Presentation on theme: "Tutorial Shengdong Zhao (some slides are reused/modified from Neil Ernst’s apache tutorial)"— Presentation transcript:

1 Tutorial Shengdong Zhao http://www.dgp.toronto.edu/~sszhao (some slides are reused/modified from Neil Ernst’s apache tutorial)

2 History Based on Rob McCool’s NCSA web server (left to start Netscape 1994) 1 st release (Apache 0.7.x) on April 1995 based on NSCA 1.3 server Patches created for extensions and bug-fixes (Apache = A-patchy Server) Today – 52.65% of all web server (July 07, www.netcraft.com) www.netcraft.com 2 streams: 1.3.x (very popular) & 2.x (current)

3

4 Apache Architecture http://plg.uwaterloo.ca/~aeehassa/cs746/as1/apache1.htm

5 Apache Architecture Select module handler at install Modules hook into phases in the Core processing cycle via API Apache talks to clients use HTTP protocol –Client request: GET /index.html –Apache maps request to a handler or file –Authenticate –Return content with headers –Modules can hook in at any point during the protocol

6 Headers Check out the LiveHTTPHeaders extension for Firefox: view the entire transaction. Headers usually tell the client the status of the request, the mime-type of the content returned, the length, etc. –Allows the client to decide what to do.

7

8 GET / HTTP/1.1 Host: www.yahoo.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/ png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: … HTTP/1.x 200 OK Date: Tue, 10 Jul 2007 20:47:16 GMT P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV" Cache-Control: private Vary: User-Agent Set-Cookie: FPCM=deleted; expires=Mon, 10 Jul 2006 20:47:15 GMT; path=/ Set-Cookie: … Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 Content-Encoding: gzip

9 Modules The power of Apache is its modules –mod_ssl: Secure internet transactions –mod_rewrite: redirect agents elsewhere –mod_perl: PERL language interface –mod_log_config: logging –mod_include: filter other modules

10 Apache on CDF We run instances of the Apache server daemon (httpd) using our own config files (no install!) – version 2.0.52 1 – course web page student guide Apache and follow the instructions 2 – download the tar file apache.tar.gz 3 – save it and untar it to a suitable folder, e.g. ~/309/ (tar –xvzf apache.tar.gz) 4 – cd ~/309/apache/bin;./start.sh This starts the server; stop it using./stop.sh 5 – verify: ps –u | grep httpd 6 – view: lynx http://localhost: /

11

12

13

14 Directory Structure Bin: the start and stop programs Conf: the config file for your server instances Cgi-bin: put executable scripts here Logs: error_log is any errors the server gets (404, 403), and access_log all accesses the server deals with htdocs: html files E.g. – see examples in each directory and play around

15 Configure Apache Shouldn’t need to change much in the /conf directory (mainly httpd.309.conf) Can set your DocumentRoot in httpd.conf: –DocumentRoot /where/you/want/to/put/your/docs Can set your web admin e-mails –ServerAdmin you@your.addressyou@your.address

16 Demo

17 Work at home 1. Install and config Cygwin http://www.cdf.toronto.edu/workathome/print.php3?id=76 2. Double click Cygwin icon to start 3. Type “startx” to start x window 4. At the popup xterm, type “ssh -X youraccount@cdf.utoronto.ca” to login to your account youraccount@cdf.utoronto.ca”

18 FAQs Can I run this all at home, on Windows/Mac? –Sure. Apache even runs on Xbox. However, we mark assignments on CDF How do I view my server on the internet? –http://.cdf.toronto.edu: –http://.cdf.toronto.edu: in the labs My start/stop aren’t working? –Always start/stop directly in apache/bin to make sure paths work properly

19 Other references The student guide on the course site httpd.apache.org (e.g.) –http://httpd.apache.org/docs/1.3/howto/htaccess.htmlhttp://httpd.apache.org/docs/1.3/howto/htaccess.html –http://httpd.apache.org/docs/1.3/howto/auth.html#basi chttp://httpd.apache.org/docs/1.3/howto/auth.html#basi c Refcards.com – Apache 1.3 reference card for printing (also other useful cards) http://refcards.com/docs/forda/apache/apache- refcard-a4.pdf http://refcards.com/docs/forda/apache/apache- refcard-a4.pdf

20 .htaccess files Use.htaccess files –These are read per-directory (affect subs) by the server and can contain many things Security restrictions Redirects URL rewrites

21 .htaccess files: sample format order allow, deny deny from 123.45.6.7 deny from 012.34.5 Allow from all AuthUserFile / user/local/you/safedir/.htpasswd AuthGroupFile /dev/null AuthName EnterPassword AuthType Basic Require user wsabstract


Download ppt "Tutorial Shengdong Zhao (some slides are reused/modified from Neil Ernst’s apache tutorial)"

Similar presentations


Ads by Google