1 / 21

Tutorial

Tutorial. Shengdong Zhao http://www.dgp.toronto.edu/~sszhao. (some slides are reused/modified from Neil Ernst’s apache tutorial). 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

hashim
Download Presentation

Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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) • 1st 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) • 2 streams: 1.3.x (very popular) & 2.x (current)

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

  4. 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

  5. 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.

  6. 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

  7. 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

  8. 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 <portnum> This starts the server; stop it using ./stop.sh 5 – verify: ps –u <user> | grep httpd 6 – view: lynx http://localhost:<portnum>/

  9. 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

  10. 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 • ServerAdminyou@your.address

  11. Demo

  12. 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 -Xyouraccount@cdf.utoronto.ca” to login to your account

  13. 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://<XXXwolf>.cdf.toronto.edu:<portnum> • http://<localmachine>.cdf.toronto.edu:<portnum> in the labs • My start/stop aren’t working? • Always start/stop directly in apache/bin to make sure paths work properly

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

  15. .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

  16. .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

More Related