1 / 29

Lab 8 Overview

Lab 8 Overview. Apache Web Server. Package Management Systems Groups Scripts. Linux Tricks. Linux Tricks. Packages. Packages. Used to “package” software for Linux distributions Vary by distribution type Debian APT (Advanced Package Management Tool) . deb files Red Hat

aolani
Télécharger la présentation

Lab 8 Overview

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. Lab 8 Overview Apache Web Server

  2. Package Management Systems Groups Scripts Linux Tricks

  3. Linux Tricks Packages

  4. Packages • Used to “package” software for Linux distributions • Vary by distribution type • Debian • APT (Advanced Package Management Tool) • .deb files • Red Hat • RPM (RPM Package Management) • Originally Red Hat Package Management) • .rpm files

  5. Package Management System • Aids in the installation, configuring, upgrading and removal of software packages • Several styles • Debian • dpkg – base tool • apt – cli interface • synaptic – gui interface • Red Hat • yum – base tool • Has a cli • PackageKit – gui interface • Plenty of other systems • Mandriva • MPM under dev. • Drakrpm • Slackware • pkgtool

  6. PMS vs. Installer

  7. Linux Tricks Userids, groups and permissions

  8. Groups and Permissions • Learn the use of groups in file permissions

  9. Overview • Create a text file while logged on with your user ID • Small file 3-5 lines • Change the file’s group • E.g. group01 • Change the file’s permissions to 640

  10. Overview • Try to edit and view the file when logged on with a different ID • e.g. user01 • Note: use01 must belong to group01 • Try to edit and view the file when logged on with a third ID • .e.g. user02 • Note: user02 must belong to another group

  11. Overview • Try changing the file when logged on as root • Optional: • Try deleting the text file as user02 • Try deleting the text file as user01 • Try deleting the text file as root • Remember: • Document text with text, not screen captures • Mainly things done via the CLI

  12. Linux Tricks Scripts

  13. Scripts • Small programs to help the maintaining and configuring of an operating system • Executed by the shell • Syntax dependent on shell • Typical use: • Create a bunch of new users • Configure a services • De facto extension: • .sh

  14. Change terminal color Assume a file named changecolor: #! /bin/bash# script to turn the screen bluesetterm -background blueecho It is a blue day Line 1: specifies which shell should be used to interpret the commands in the script.Line 2: is a comment (has no effect when the script is executed).Line 3: sets the background colour.Line 4: displays a message. To execute if the PWD has this file: ./changecolor If in another directory use the complete name: /home/mydir/utils/changecolor

  15. Simple Menu Script These can be as complex as needed with conditional and loop controls (among many other things) #!/bin/bash OPTIONS="Hello Quit" select opt in $OPTIONS; do if [ "$opt" = "Quit" ]; then echo done exit elif [ "$opt" = "Hello" ]; then echo Hello World else clear echo bad option fi done

  16. Running Scripts Basics • Make sure the first line is a directive of which shell to use (if needed) • Starts with a shebang: #! • For our Debians it is the bash shell • /bin/bash • Make sure it is executable • rwxr-xr–- • User can run, edit and view • Group can run and view • World can view • chmod 754 script.sh • If the shell is in a directory defined in the PATH • echo $PATH • Will show the directories • type: filename • If it is not in PATH but it is in the PWD • type: ./filename • If not in PATH and not in the PWD • type full filename starting with the root: /home/ajkombol/Desktop/script.sh

  17. Script one: netconfig.sh Desired action: stop the NIC, open the interfaces file to edit, restart the NIC, add two nameservers to the resolve.conf file The script: #!/bin/bash NETCONFIGFILE=/etc/network/interfaces RESOLVECONF=/etc/resolv.conf ifdown $1 vi $NETCONFIGFILE #vi $RESOLVECONF ifup $1 echo 'nameserver 172.16.1.245' >> $RESOLVECONF echo 'nameserver 172.16.1.219' >> $RESOLVECONF To execute the script: myprompt#./netconfig.sh eth0

  18. Quick script intro • Parameters passed to a script are denoted by $1, $2, $3, … • $1 is the first parameter, $2 is the second, etc. • $# is the number of parameters passed • Conditionals are done by an if…elif…else…fi structure • The if and elif are followed by command that evaluates to true or false • The elifand else are optional • elifcan be repeated • Only one else may be used, if needed • The if is closed with thefi statement • To stop in the middle of a script use exit n • n = 0 is a normal exit • n = 1 is an error exit • If a value needs to be checked the test command is used • Numbers use conditionals • e.g. –gt, -lt, and –eq • greater than, less than, equal • E.g. test 1 –gt 2 • Strings use operators • e.g. = or != • equal and not equal • test $1 = "opt1" • There are other comparisons that can be done, check the internet • Variables are case sensitive • Are UPPER case by convention for environment variables

  19. Script two: go Disired action: stop the NIC, check option and copy the proper template to interfaces, and finally restart the NIC #!/bin/bash IFILE=/etc/network/interfaces ifdown eth0 if test $1 = "static" ; then cp $IFILE.static $IFILE echo "Static interfaces loaded!" elif test $1 = "dhcp" ; then cp $IFILE.dhcp $IFILE echo "DHCP interfaces loaded!" else echo "Parameter must be static or dhcp" fi ifup eth0 To execute the script: myprompt#./go static … myprompt#./go dhcp

  20. Today's labs scripts summary • Changing network configuration • Script one – editing the interfaces file • stop NIC • edit interfaces • add some additional routing information • start NIC • Script two – alternating interfaces templates • Make two interfaces templates • stop NIC • Copy the desired template • start NIC • You may wish to keep these scripts • Use netconfig.sh to edit the interfaces file • After making appropriate changes • Use go or go2 to switch between • DHCP addresses • Static addresses

  21. Reminder • ALWAYS make a backup copy of a configuration file BEFORE editing it • Will allow the file to be restored • If you mess it up • If something else messes it up • Examples: • cp interfaces interfaces.backup • cp apache2.conf apache2.conf.orig

  22. Main Lab Apache

  23. Apache Web Server • Main Goals • Install Apache • Configure basic system • Configure restrictions • Side goals • Installing packages on a Debian System • Reinforce VM environment • Reinforce use of vi editor

  24. Apache Web Server Overview • Install Apache on your Debian VM • apt-get • Backup: Synaptic Package Manager • No credit for Synaptic install • Check if installation worked • Create new directories • “Install” the web application • Configure Apache to “find” the new “application” • Copy Web page files into proper directories • Hint: assume the Web application is being moved from a different Web server to this machine • Configure Apache for restrictions • Allow directory access • Deny directory access • Browse the application from another machine

  25. Misc. Notes • Debian required for the Apache Server • CentOS recommended for the browsing client • Can be any OS with a browser • Use ifconfig to identify your IP address • Web files (.htm and pics) available on hades.lab • Use browser to locate • class/itis2110/apache • e.g. master.hades.lab/classes/itis2110/apachelab • (172.16.1.245) • In /public directory • Also available • ON website • on thumbdrive • You will need to figure out on your own where the images go to be properly displayed • All web pages except home have an image • A subdirectory is involved!

  26. IMPORTANT!!!! • This Debian VM must be working and saved! • Will be used as the basis for the DNS Lab!

  27. Apache Overview • “Open source” web server • Default browser “root” directory • NOT the same as the host’s root directory! • To access the web server: • Use the IP address or host name • Port 80 • Bonus: • At end of lab add port to browse on port 8080 • Document results

  28. Last minute notes: • Check the links to test1.html and test2.html • They should go to the ITIS2110 directory • If you get an old copy they may point to an ITIS3100 directory • Fix accordingly! • Change reference in the html (best) • -- or -- • Change the directory name • Watch the IP addresses of your VM • DHCP OK this lab • Need to look up address for browsing • If address was assigned • Be sure does not conflict with another machine • Can use machine ID as subnet or host id

  29. Apache Lab • Lab 20 pts

More Related