Professional Documents
Culture Documents
Meeting 3: Advanced Apache Topics: Rutgers University Internet Institute Instructor: Chris Uriarte
Meeting 3: Advanced Apache Topics: Rutgers University Internet Institute Instructor: Chris Uriarte
Meeting 3: Advanced Apache Topics: Rutgers University Internet Institute Instructor: Chris Uriarte
Virtual Hosting
General term used when you run more than one website on a single system. Allows ISPs and hosting providers to make money by sharing resources among clients. Allows companies and individuals to save time and money - a single machine can host many websites.
NIC
Required for each Virtual Host website your are usingtherefore your httpd.conf can have multiple <VirtualHost> blocks.
Web Technology Web Server Setup : Chris Uriarte
The key: Vitual hosts will have their own unique DocumentRoot different content for different sties.
Web Technology Web Server Setup : Chris Uriarte
Which tells Apache the single IP address you will use for all your websites. Now simply add <VirtualHost> blocks for each of your website domains.
Name-Based VH Examples
NameVirtualHost 165.230.30.68 <VirtualHost www.yoursite.org> DocumentRoot /home/www/yoursite/htdocs ServerAdmin you@yoursite.com ServerName www.yoursite.com ErrorLog logs/yoursite-error_log </VirtualHost> <VirtualHost www.mysite.com> DocumentRoot /home/www/mysite/htdocs ServerAdmin me@mysite.com ServerName www.mysite.org ErrorLog logs/mysite-error_log </VirtualHost>
Server-Side Includes
Server-side includes are directives that can be placed in HTML documents to execute other programs or to output data. Requires mod_include. To enable SSI, make the following modifications to httpd.conf:
Options Includes (or IncludesNOEXEC)
The options directive only works within a specific Directory or VirtualHost container.
These lines are usually commented out by default, so you just need to uncomment them. All files with indicated extension(s) will be parsed by Apache server prior to being transmitted to the client, e.g. web page files that end with .shtml can contain SSIs.
<!echo var=LAST_MODIFIED-->
Prints the last time your HTML file was modified.
CGI
CGI (Common Gateway Interface) is a protocol for getting, processing, and returning information through Web pages. CGI programs or scripts can be written in a variety of languages including Perl, Python, VB Script, JavaScript, and C. CGI scripts are generally triggered by data supplied by the client.
Enabling CGI
There are two ways to enable Apache to recognize CGI scripts:
To allow CGI scripts in one system-wide directory outside of the document root (All CGI programs must be placed in one directory):
ScriptAlias /cgi-bin /home/students/<username>/apache/cgibin/
Within a container:
Options ExecCGI <other options> SetHandler cgi-script
To enable files with only specific extensions as CGI scripts use AddHandler instead of
SetHandler: AddHandler cgi-script .cgi
Web Technology Web Server Setup : Chris Uriarte
CGI: Examples
http://blender.rutgers.edu/~chrisjur/cgi-bin/test.cgi - CGI script written in Perl, simply outputs current time and the end-users browser type (source at /home/staff/chrisjur/public_html/cgi-bin/test.cgi) http://blender.rutgers.edu/~chrisjur/cgibin/shell.cgi - Written as a shell script in, prints current date/time and lists files in its directories (source at /home/staff/chrisjur/public_html/cgibin/shell.cgi)
Web Technology Web Server Setup : Chris Uriarte