Lab 8 Overview Apache Web Server. SCRIPTS Linux Tricks.

Slides:



Advertisements
Similar presentations
ITR3 lecture 7: more introduction to UNIX Thomas Krichel
Advertisements

Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
A Guide to Unix Using Linux Fourth Edition
Chapter Apache Installation on Linux. Acknowledgement The contribution made by Darrin Morison is acknowledged.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Lab 5 Overview DNS. DNS name server Set up a local domain name server The 302 lab’s TLD (top level domain) is hades.lab Lab 5 will create and configure.
Chapter Apache Installation in Linux- Mandrake. Acknowledgment The following information has been obtained directly from
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
Apache : Installation, Configuration, Basic Security Presented by, Sandeep K Thopucherela, ECE Department.
Shell Programming 1. Understanding Unix shell programming language: A. It has features of high-level languages. B. Convenient to do the programming. C.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Linux Operations and Administration
Shell Programming, or Scripting Shirley Moore CPS 5401 Fall August 29,
Web Server Configuration Alokes Chattopadhyay Computer & Informatics Centre IIT Kharagpur.
Introduction to Shell Script Programming
Objectives Define IP Address To be able to assign an IP address with its Subnet Mask and Default Gateway to a PC that operates using Windows 7 or Fedora.
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
8 Shell Programming Mauro Jaskelioff. Introduction Environment variables –How to use and assign them –Your PATH variable Introduction to shell programming.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Chapter 5 Bourne Shells Scripts By C. Shing ITEC Dept Radford University.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
July 17, 2003Serguei A. Mokhov, 1 Shells and Shell Scripts COMP 444/5201 Revision 1.3 January 25, 2005.
Shell Script Programming. 2 Using UNIX Shell Scripts Unlike high-level language programs, shell scripts do not have to be converted into machine language.
Linux+ Guide to Linux Certification, Third Edition
Linux Operations and Administration
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 11: Shell.
Shell Scripting AFNOG IX Rabat, Morocco May 2008.
#!/bin/sh echo Hello World cat Firstshellscript.sh Firstshellscript.sh.
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
This slide deck is for LPI Academy instructors to use for lectures for LPI Academy courses. ©Copyright Network Development Group Module 9 Basic Scripting.
Shell Programming. Creating Shell Scripts: Some Basic Principles A script name is arbitrary. Choose names that make it easy to quickly identify file function.
Chapter 10: BASH Shell Scripting Fun with fi. In this chapter … Control structures File descriptors Variables.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
Lab 11 Overview Windows Server Last Labs Lab 12  Cisco Firewall.
Writing Scripts Hadi Otrok COEN 346.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Xuan Guo Chapter 5 The Bourne Shell Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Notes by Michael.
Lab 10 Overview DNS. DNS name server Set up a local domain name server . is the root domain .lab is the WH302 lab’s TLD (top level domain)  hades.lab.
Introduction to Scripting Workshop October
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
Presented by Lonnye Bower Fardin Khan Chris Orona APACHE WEB SERVER.
Sed. Class Issues vSphere Issues – root only until lab 3.
Lab 8 Shell Script Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook
Linux+ Guide to Linux Certification, Second Edition
Assigning Values 1. $ set One Two Three [Enter] $echo $1 $2 $3 [Enter] 2. $set `date` [Enter] $echo $1 $2 $3 [Enter] 3. $echo $1 $2 $3 $4 $5 $6 [Enter]
Chapter 5 The Bourne Shell Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, Notes by Michael Weeks.
1 Week 8 Creating Simple Shell Scripts. 2 Chapter Objectives  In this chapter, you will :  Learn how to create Shell Scripts  Commenting / Making Portable.
Linux Administration Working with the BASH Shell.
 Prepared by: Eng. Maryam Adel Abdel-Hady
Introduction to Scripting Workshop February 23, 2016.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Lab 11 Overview Windows Server Last Labs wk14
Using Linux Kaya Oğuz Room: 310.
Bash Scripting CIRC Summer School 2016 Baowei Liu CIRC Summer School 2016 Baowei Liu.
Bash Shell Scripting 10 Second Guide.
Network Configuration
CIRC Winter Boot Camp 2017 Baowei Liu
NTP, Syslog & Secure Shell
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
Labs 5 and 8 combined Monday March 21, 2016 labs only.
The Linux Operating System
Lab 10 Overview DNS.
LING 408/508: Computational Techniques for Linguists
Linux Shell Script Programming
Presented by, Mr. Satish Pise
Introduction to Bash Programming, part 3
Bash Scripting CS 580U - Fall 2018.
Presentation transcript:

Lab 8 Overview Apache Web Server

SCRIPTS Linux Tricks

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 service De facto extension: .sh

Change terminal color #!/bin/bash # script to turn the screen blue setterm -background blue echo 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. Assuming the file is executable: To execute if the PWD has this file: Assume a file named changecolor:./changecolor If in another directory use the fully qualified name: /home/mydir/utils/changecolor

Simple Menu Script #!/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 These can be as complex as needed with conditional and loop controls (among many other things)

Running Scripts Basics Make sure the first line is a directive of which shell to use (if needed)  Starts with a shebang: #!  For Debian 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

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

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 Variables are case sensitive  Environment variables Used by the system in general Are UPPER case by convention

Quick script intro (cont.) Conditionals are done by an if…elif…else…fi structure  if and elif are followed by a command that evaluates to true or false  elif and else are optional elif can be repeated Only one else may be used, if needed  if is closed with the fi statement  To stop in the middle of a script use exit n n = 0 is a normal exit If n is not specified it is assumed 0 n = 1 is an error exit Actually any non 0 value is an error  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 EX: test 1 –gt 2 Strings use operators e.g. = or !=  equal and not equal EX: test $1 = "opt1"  There are other comparisons that can be done, check the internet

Script two: go #!/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 Desired action: stop the NIC, check which option copy the proper template to interfaces, restart the NIC Note: eth0 is assumed to be the NIC name To execute the script: myprompt#./go static … myprompt#./go dhcp

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

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 Make a copy of a line to be changed in a file and comment it out before changing the original  Example: # This is the original line This is the changed line

APACHE Main Lab

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

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

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 /apachelab e.g. lab302-web.hades.lab/classes/apachelab  ( )  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!

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

Apache Overview “Open source” web server Default browser “root” directory  NOT the same as the host’s root directory!  Location: /var/www /var/www/htdocs  Depends on distribution 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

Last minute notes: Check the links to  test1.html  test2.html  They should go to the ITIS2110 directory 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 Can use your subnet (see listing on post)

Apache Lab Lab 20 pts