Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First I need to do this: The project team is ready to create the directory struc

ID: 3570886 • Letter: F

Question

First I need to do this:

The project team is ready to create the directory structure for the Web site. You are tasked with creating the directories and implementing the security mechanism. For this assignment, you need to create the following directory structure and permissions:

Ensure that you are starting in your individual Home directory:

+- apache/
|
|- bin/
|
|- conf/
|
|- lib/
|
+- www/
|
| - html/
|
| - cgi-bin/
|
| - ftp/

The following file permission should be enabled for the directories:

The owner can read, write and execute All.

The group can read and execute All Directories.

Everyone else can only read and execute the files in Apache only (and no permissions in www).

Change the www tp directory to allow the User and group to read, write, and execute, but everyone else to only write to the directory.

In addition, create the following empty files and set the following file permissions:

apache/bin/httpd - 755
www/html/index.html - 644
www/cgi-bin/process.pl - 711

Finally, create a file called apache/conf/httpd.conf, and add the following lines to the file:

#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.

# Do not add a slash at the end of the directory path.
#
ServerRoot "/usr"

#
# DocumentRoot: The directory out of which you will serve your documents.
#
DocumentRoot "/Library/WebServer/Documents"

Save the file and exit the editor. Set the file permission for this file to be: 664.

Show the command used to show content of the file and the content of the file.

Using the grep command, write comment to find the line containing the word(s) ServerRoot and DocumentRoot in the httpd.conf file.

Write a sed command that will change the ServerRoot value from /usr to the absolute directory patch for your apache directory.

Write a sed command that will change the Document value from /Library/WebServer/Documents to the absolute directory patch for your www directory.

Write an awk command that will print only the comment field and the login id of all users in the /etc/passwd file in this format: <Comment Field> - <login id>.

Next I need to do this:

You have created the directory structure and some base files to be used by the Web server and Web site. For the Web site to be created in a production environment, you need to package your commands in a script so that the patching team can run them on the production environment. Your task for this assignment is the following:

Create a Bourne shell script. The script should do the following:

Explain what the script will do and who is the author in a comment area.

cd to your home directory

Show your current working directory.

List the contents of the current directory.

Create the directory structure and create the files as defined in the previous Individual Project.

For each directory and file, test to see if the file or directory already exists; if it does exist, do not recreate; if it is missing, create it.

In the end, generate a directory listing showing the structure and content of the new directories.

At the beginning of the script, set a variable called INSTALL_DIRECTORY that will contain the location of the directory into which the Web server will be installed. At the end of the script, display the contents of this variable along with a message to the installer about the location in which the directories were created.

A small hint for creating the content of the httpd.conf file: use the echo command in your script. The script is not interactive and should create all objects automatically. Also, the ServerRoot and DocumentRoot should contain correct values based on your directory names.

If you need to test that directories are created or not based on them already existing, remove files and directories ahead of time to ensure you know the exact state of your environment.

Explanation / Answer

Week 4 tasks:
mkdir apache
mkdir apache/bin
mkdir apache/conf
mkdir apache/lib
mkdir www
mkdir www/html
mkdir www/cgi-bin
mkdir www/ftp

chmod -R 755 apache
chmod -R 750 www

chmod -R 771 www/ftp

touch apache/bin/httpd
chmod 755 apache/bin/httpd

touch www/html/index.html
chmod 644 www/html/index.html
chmod 711 www/cgi-bin/process.pl

cat > apache/conf/httpd.conf <<-EOF

#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.

# Do not add a slash at the end of the directory path.
#
ServerRoot "/usr"

#
# DocumentRoot: The directory out of which you will serve your documents.
#
DocumentRoot "/Library/WebServer/Documents"
EOF

chmod 664 apache/conf/httpd.conf

cat apache/conf/httpd.conf

grep -e"ServerRoot" -e"DocumentRoot" apache/conf/httpd.conf

cd www
sed "s_/Library/WebServer/Documents_`pwd`_g" apache/conf/httpd.conf

awk -F":" '{print $1 - $2}' /etc/passwd

Week 5 tasks (Bash script):

#!/bin/bash
INSTALL_DIRECTORY=`pwd`;
function chkmkdir(){
dir=$1
if [ ! -d $dir ]; then
mkdir $dir
fi
}

function chkmkfile(){
file=$1
if [ ! -f $file ]; then
touch $file
fi
}

cd ~
pwd
ls -l
chkmkdir apache
chkmkdir apache/bin
chkmkdir apache/conf
chkmkdir apache/lib
chkmkdir www
chkmkdir www/html
chkmkdir www/cgi-bin
chkmkdir www/ftp
chmod -R 755 apache
chmod -R 750 www
chmod -R 771 www/ftp
chkmkfile apache/bin/httpd
chmod 755 apache/bin/httpd
chkmkfile www/html/index.html
chmod 644 www/html/index.html

chmod 711 www/cgi-bin/process.pl

if [ ! -f  apache/conf/httpd.conf ]; then

cat > apache/conf/httpd.conf <<-EOF
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.

# Do not add a slash at the end of the directory path.
#
ServerRoot $INSTALL_DIRECTORY

#
# DocumentRoot: The directory out of which you will serve your documents.
#
DocumentRoot "$INSTALL_DIRECTORY/Library/WebServer/Documents"
EOF

fi

# to see the list of files and directories in the current folder
find .

echo The webserver is installed in $INSTALL_DIRECTORY folder.