390 likes | 805 Views
CSI 227. Apache. introduction. W hat is apache? G etting it Installing it Configuring it Apache log files. what is Apache?. open source Runs on 160 + varieties of unix ? Runs on Windows too! 56% of web servers? used to be more!. get. www.apache.org/dist
E N D
CSI 227 Apache
introduction • What is apache? • Getting it • Installing it • Configuring it • Apache log files
what is Apache? • open source • Runs on 160+ varieties of unix? • Runs on Windows too! • 56% of web servers? used to be more!
get • www.apache.org/dist • some prebuilt versions with added value • Some provide support at a price • mirrored all over the world
windows • Use an installer
linux • Yum, similar tools for very simple installs • Example: yum install apache2
from source • Get source file (something like apache.tar.gz) • gunzip apache2.tar.gz • tar xf apache2.tar • cd apache2 • ./configure • make • make install • make clean
from source • gunzipor bunzip2 apache2.tar.bz2 apache2.tar.gz
default build vs custom build • adding and removing modules • built-in or loaded You can select at build time to remove modules you don’t need or add others that are not included by default
configuration is through a text file • httpd.conf • When you change settings with a text editor, you must then restart the server • no GUI • hundreds of directives
conf files • httpd.conf • srm.conf • access.conf primary
Is Apache running? • # ps –ef|grephttpd Look for processes with this name Ask what’s running
Starting Apache • apachectl start
Restarting Apache • apachectl restart
Stopping Apache • apachectl stop
Syntax Checking • checking syntax with apachectl -configtest
pre-forked or multi-threaded • Pre-forked on unix (variable number of processes) • Multi-threaded on windows (2 processes)
virtual hosts • Allows you to support hundreds of web sites on a single system
content negotiation • apache can select the correct language to use if you have language-specific versions of pages • It can also send the preferred image format -- gif jpeg
scripts etc. • run-time execution of scripts possible • SSIs allow pages to be modified at run-time before they are sent • java servletmodules are available • SSL-enabled versions are available
logs • access • error • Can set up a separate log for each virtual host or one set of logs for the entire server • can be customized
directives • Configuration settings are done through what are termed “directives”
Listen • Listen 192.168.0.1:80 • Listen 80 • Listen *:80
User and Group • Set the username and user group under which the Apache processes will run
ServerName • The name reported by Apache
ServerRoot • The location of Apache’s files (server executables, configuration file, etc. – not the site contents) • The locations in httpd.conf will be relative to the ServerRoot
DocumentRoot • The web space (where the web pages are stored)
DirectoryIndex • The list of default documents
Options indexes • generates directory listing (indexes) when no matching default document s areavailable
IndexOptions • provides a list of options to set various features of the index listing
Alias • map a URL to a location outside document tree
ErrorLog • sets logging options (e.g., LogLevel can be debug, info, notice, warn, error, crit, alert or emerg
ErrorDocument • sets customized error pages • ErrorDocument 404 /error.html • ErrorDocument 500 "oops"
Errors • 400 Bad Request – HTTP_BAD_REQUEST • 401 Authorization Required – HTTP_UNAUTHORIZED • 402 Payment Required – HTTP_PAYMENT_REQUIRED • 403 Forbidden – HTTP_FORBIDDEN • 404 Not Found – HTTP_NOT_FOUND • 405 Method Not Allowed – HTTP_METHOD_NOT_ALLOWED • 406 Not Acceptable – HTTP_NOT_ACCEPTABLE • 407 Proxy Authentication Required – HTTP_PROXY_AUTHENTICATION_REQUIRED • 408 Request Time-out – HTTP_REQUEST_TIME_OUT • 409 Conflict – HTTP_CONFLICT • 410 Gone – HTTP_GONE • 411 Length Required – HTTP_LENGTH_REQUIRED • 413 Request Entity Too Large – HTTP_REQUEST_ENTITY_TOO_LARGE • 414 Request-URI Too Large – HTTP_REQUEST_URI_TOO_LARGE • 500 Internal Server Error – HTTP_INTERNAL_SERVER_ERROR • 501 Method Not Implemented – HTTP_NOT_IMPLEMENTED • 503 Service Temporarily Unavailable – HTTP_SERVICE_UNAVAILABLE • 505 HTTP Version Not Supported – HTTP_VERSION_NOT_SUPPORTED • others ...
Directory • set options for specific directories • <Directory /path> • Options Indexes FollowSymLinks • AllowOverrideAll • </Directory>
FilesMatch • restrict access to certain files • <FilesMatch "^\.ht"> • Order allow,deny • Deny from all • </FilesMatch>
Files • same as FilesMatch by regular expressions must be preceded by ~ • <Files ~ "\.(gif\jp?g\png)$"> • Order allow,deny • Allow from 192.168.0.1 • </Files>
mime.types • Associate server action with a file type requested by client • requires mod_mime.so • LoadModule mime_module /modules/mod_mime.so • DefaultType text/plain • TypesConfig conf/mime.types