Apache Webserver

Download Report

Transcript Apache Webserver

Unix Tools

Getting Around

• pwd – – Print Working Directory Tells you where you are on the remote computer

Getting Around

LS – Lists directory contents L flag for ‘long list’

Getting Around

W = writable R = readable X = executable owner size date name

• cd

Getting Around

Go to the root of the server From there, go to the folder called ‘afs’ Now you’re in /afs

Operations

• Chown – Changes ownership of a file or folder chown [user] [file] chown gillw3 /var/logs chown –R gillw3 /var/logs Changes ownership of the folder ‘logs’ Changes ownership of the folder ‘logs’ and everything in it

Operations

• chmod – Modifies access rules for a file chmod [usertype] = [rights] [file] [usertype] can be one of u, g, or o (current owner, anyone in the owners group, anyone) [rights] can be r, w or x (read, write, execute)

Operations

• chmod chmod u=rwx somefile.txt

Operations

• cp – Copies a file cp [source] [destination] cp somefile.txt somefile_copy.txt

Operations

• mv – Moves a file mv [source] [destination] mv somefile.txt newname.txt (renames) mv somefile.txt /var/www/somefile.txt

(moves)

• rm – Removes a file

Operations

rm [file] rm somefile.txt

Operations

• wget – Gets a file (or more) from a web resource wget [url] wget http://www.rpi.edu/index.html (gets file, saves it to current directory as index.html) wget –O rpihome.html http://www.rpi.edu/index.html

(gets file, saves it to current directory as rpihome.html)

.sh files

• • Put shell commands in a file Call the file, all the commands run The following should be the top line of the file: #!/bin/sh

Operations

• • cron – allows users to set timers for operations to be exicuted crontab – A file that specifies what should be done when

Operations

• Crontab – Crontab –e (edits file) [min] [hour] [day of month] [month] [day of week] [command] [0-59, *] [0-23, *] [1-31, *] [1-12, *] [0-6, *] [command] 0,5,10,15,20,25,30,35,40,45,50,55 * * * * update-rss-feeds.sh

0 3 * * * managelogs.sh

Apache Webserver

Apache Webserver = httpd

• • • Hypertext transfer protocol daemon – Daemons are applications that run all the time listening for a request. When a request is made they do something.

Developed in 1995 Serves 50% of websites

HTTPD is Modular

• • • mod_php is added to allow php to be processed….

Modules may be added when the application is complied Modules may be dynamically added after the application is complied – apxs is a tool for managing dynamic modules – http://httpd.apache.org/docs/2.2/programs/apxs.html

Modules in httpd.conf

Modules

• • • mod_auth_cas – http://www.ja-sig.org/wiki/display/CASC/mod_auth_cas mod_auth_ldap – http://httpd.apache.org/docs/2.0/mod/mod_auth_ldap.html

mod_proxy_fcgi – http://mproxyfcgi.sourceforge.net/

Configuring in httpd.conf

• • • Httpd.conf is read when httpd starts Restart httpd every time you edit httpd.conf

At all times, refer to the apache documenation – http://httpd.apache.org/docs/2.2/

httpd.conf

• • • • – Rules for a folder on the server – Rules for a url – Directive that creates additional hosts on your httpd instance.

– Tests of a module is loaded before you attempt to configure the module

Allows server side includes in the specified folder Instructs httpd to follow shortcuts in the filesystem, to ignore .htaccess files, do not serve any content

Requires AFS login to any URL that has an /AFS in the path

Creates a virtual host, alert.rpi.edu

Only runs the re-write rules if mod_rewrite is loaded

.htaccess

• • Contains instructions, like those found in httpd.conf

File is parsed every time the server requests a resource in that folder, or a downstream folder

In Class Work

• • Using mod_rewrite to – Proxy – Make neato urls Create a httpd servable directory named ‘rewrite’

In Class Work

• • Allowing .htaccess files in httpd.conf

Add the following to httpd.conf

AllowOverride All Restart httpd

In Class Work

• • Create a file named .htaccess in ‘rewrite’ Add: RewriteEngine on RewriteBase /rewrite/ RewriteRule ^(.*)$ http://www.cnn.com/ [P]

In Class Work

• • • Go to http://localhost/rewrite Rename .htaccess to example1.txt

Create another file named .htaccess

RewriteEngine On RewriteRule /(.*) index.php?input=$1

In Class Work

• Create index.php

1. echo $_GET[‘input’]; 2. Use ‘explode’ on $_GET[‘input’] to break the input into value key pairs