CTEC1863/2017F Lab #11, Part 1 Page 1 of 11. In this lab, we will be installing a popular solution for database-driven web sites.

Similar documents
CSN09101 Networked Services. Module Leader: Dr Gordon Russell Lecturers: G. Russell

L.A.M.P. Stack Part I

Apache + PHP + MySQL. bdnog November 2017 Dhaka, Bangladesh

Apache Web Server Administration for Windows

SETTING UP 3 WORDPRESS SITES ON APACHE AND UBUNTU BY RAMI

A PAtCHy server: developed by the Apache group formed 2/95 around by a number of people who provided patch files for NCSA httpd 1.3 by Rob McCool.

[UNIT 1 <Continued>]: <Understanding Apache>

Securing Apache: Step-by-Step by Artur Maj last updated May 14, 2003

Configuring Multiple Instances of Railo on Linux

Apache Install Instructions Win7 7 Php Mysql. Phpmyadmin Linux >>>CLICK HERE<<<

Configure Wildcard-Based Subdomains

HTTP HyperText Transfer Protocol

LAMP Stack with VirtualHosts On Centos 6.x

DEPLOYMENT GUIDE Version 1.0. Deploying F5 with Apache Web Servers

Apache Httpd Manual Conf Virtualhost Redirect

Fachgebiet Technische Informatik, Joachim Zumbrägel

Install WordPress 3.X In Multi Blog / Multi user mode On localhost

Mac OS X Server Web Technologies Administration. For Version 10.3 or Later

Global Servers. The new masters

Linux Network Administration. Apache Web Server COMP1071 Summer 2017

Linux Systems Administration Getting Started with Linux

This material is based on work supported by the National Science Foundation under Grant No

Preparing Your Working Environment

Tungsten Dashboard for Clustering. Eric M. Stone, COO

Apache, Php, MySql Configuration

IBM Education Assistance for z/os V2R2

How to Create a NetBeans PHP Project

LING 408/508: Computational Techniques for Linguists. Lecture 20

Illustrated Steps to create greggroeten.net with AWS

Introduction to Linux

macos High Sierra Apache Setup: Multiple PHP Versions First part in a multi-part blog series for Mac developers

Managing Xen With Xen-Tools, Xen-Shell, And Argo

CustomLog /var/www/vhosts/example.com/statistics/logs/access_log common

MassTransit Enterprise Web Configuration

Setting Up PHPlist (Open-Source Newsletter Manager)

Linux Essentials Objectives Topics:

Introduction to the shell Part II

Big Brother HowTo robin 12apr2001

Read Source Code the HTML Way

Bitnami Re:dash for Huawei Enterprise Cloud

Installing mod_perl 1.0 in Three Steps

Install Apache, PHP And MySQL On CentOS 7 (LAMP)

VCP-DCV5, OCP (DBA), MCSA, SUSE CLA, RHCSA-7]

Certification. The HTTP Service

Chapters. Web-Technologies I 1

1 Installation 2 "Add New Printer"... Window 3 "Device for" Window "Device URI for"... Window. 7 Specify Printer... Model

ViMP 2.0. Installation Guide. Verfasser: ViMP GmbH

CSCI 201 Lab 1 Environment Setup

WA2572 Introduction to Responsive Web Development for Mac. Classroom Setup Guide. Web Age Solutions Inc.

User Manual. version 1.6-r1

Bitnami OroCRM for Huawei Enterprise Cloud

CS101 Lecture 04: How the Web Works Publishing Web pages. What You ll Learn Today

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Course Wiki. Today s Topics. Web Resources. Amazon EC2. Linux. Apache PHP. Workflow and Tools. Extensible Networking Platform 1

Bitnami Ruby for Huawei Enterprise Cloud

[ Due: N.A ] [ Points: PRICELESS ] [ Date: 2/9/2016] [ Goings, Jesse ] Computer Network Specialist Center For Arts and Technology College Kelowna BC

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Apache MySQL PHP PHPAdmin Install

Apache Web Server Administration for Linux

TPF : Support : Tools : SOAP

Your Apache ssl.conf in /etc/httpd.conf.d directory has the following SSLCertificate related directives.

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Introduction to Lab Practicals (Lab Intro 3) Access Control, Synchronisation and Remote Access

SELinux Workshop Redux Jamie Duncan, Red Hat RVaLUG 19 April 2014

SOFTWARE INSTALLATION README

Aware IM Version 8.1 Installation Guide

VERITAS Volume Manager Installation Guide

9.2 Linux Essentials Exam Objectives

Lab 3.4.2: Managing a Web Server

Zend Core TM. Installation and Maintenance Guide. Zend Core for Oracle. By Zend Technologies, Inc. w w w. z e n d. c o m

GMU Specifications And Installation Procedures Page 1 04/04/08. JBM Gateway Management Utility Server Specifications And Installation Procedures

How To Start Mysql Use Linux Command Line Client In Xampp

Setting up VPS on Ovh public cloud and installing lamp server on Ubuntu instance

Lab #10: Using Linux with Microsoft Windows

K-RATE INSTALLATION MANUAL

D, E I, J, K. Generalized Regular Expression Parser (GREP), 110 Generic 105 key (Intl) PC, 29 git command, 242

FUJITSU Cloud Service S5 Installation and Configuration of MySQL on a CentOS VM

Observium Enable your new virtual host 4

Xcalar Installation Guide

D x R. nursing INSTRUCTOR MANUAL STUDENT MANUAL TECHNICAL APPENDIX

(Worth 50% of overall Project 1 grade)

The Unix Shell & Shell Scripts

CentOS 6.7 with Vault MySQL 5.1

Linux Essentials. Smith, Roderick W. Table of Contents ISBN-13: Introduction xvii. Chapter 1 Selecting an Operating System 1

3 Installation from sources

This guide consists of the following two chapters and an appendix. Chapter 1 Installing ETERNUSmgr This chapter describes how to install ETERNUSmgr.

Setting up a Chaincoin Masternode

Installing MyDNS And The MyDNSConfig Control Panel On Fedora 8

CHAPTER 2. Troubleshooting CGI Scripts

Providing HTTP Service on a Port

Installing and Upgrading Cisco Network Registrar Virtual Appliance

IBM z Systems Development and Test Environment Tools User's Guide IBM

Install latest version of Roundcube (Webmail) on CentOS 7

Apparo Fast Edit. Installation Guide 3.1

User authentication, passwords

Linux Command Line Primer. By: Scott Marshall

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

This document is intended for use by Nagios XI Administrators who need a boost in I/O performance.

Apache Httpd Manual Conf Listen Ipv6 >>>CLICK HERE<<<

4 Installation from sources

Transcription:

CTEC1863/2017F Lab #11, Part 1 Page 1 of 11 Lab #11: LAMP In this lab, we will be installing a popular solution for database-driven web sites. This configuration is known as LAMP, an acronym standing for Linux (the operating system), Apache (the web server software), MySQL (the database server), and Programming (the code used to connect the database to a web page.) The "P" usually also stands for Perl, PHP, or Python -- the three most popular programming languages for web sites that are not based on a Microsoft Windows platform. We will be using PHP which stands for (recursively) PHP Hypertext Preprocessor -- consisting of both a programming language and an Apache add-in module. In this lab, we will be building a custom LAMP stack, with the recent versions of Apache and PHP (newer versions may have been released since the time of this writing.) Most Linux distributions offer a complete LAMP stack or components thereof as part of the software installation mechanisms, and will provide updates. However, the distribution updates usually lag behind the Apache and PHP projects slightly. For simplicity, we will be using the CentOS distribution version of MariaDB. Part 1: Apache Web Server The Apache HTTP (WWW) server is a powerful tool for publishing documents, images, forms, and other content on the Internet (or other TCP/IP networks). It is also the most popular web server software on the Internet today, used for over two-thirds of web sites worldwide! Although Apache contains many complex features, setting up and starting a basic Apache Web server in UNIX or Linux is fairly easy. After your web server is up and running, you need to add the web content you want to share and watch log files. Directives in Apache configuration files can continue to be modified to make sure that your server has enough resources to handle the demand and to suit the level of security you are comfortable with. NOTE: The following information (pages 1 to 6) are background material on Apache. You can skip right to the lab procedure on page 7 and read later.

CTEC1863/2017F Lab #11, Part 1 Page 2 of 11 Configuring Apache The httpd.conf file (typically located in your /usr/local/apache/conf directory) is the centre of Apache web server configuration. This is a plain text file consisting of about 1000 lines of information. Most of that information is in the form of comments that are either descriptions of a directive or actual lines you could use by removing comment characters (#) from the beginning of each line. NOTE: The current 2.4.x branch of Apache has split httpd.conf into multiple files. The other files are stored in the extra subdirectory. For example, release 2.4.3 has the following extra files: httpd-autoindex.conf httpd-languages.conf httpd-ssl.conf httpd-dav.conf httpd-manual.conf httpd-userdir.conf httpd-default.conf httpd-mpm.conf httpd-vhosts.conf httpd-info.conf httpd-multilang-errordoc.conf proxy-html.conf For basic Apache configuration, all of the relevant settings are in httpd.conf., so all of the extra files do not need to be modified. Because httpd.conf is a plain text file, you can change its contents by simply editing that file. Any directives you change take effect when the web service (actually the HTTP daemon -- httpd) restarts. The rest of this part describes ways in which you can change httpd.conf to better suit your needs. It highlights directives that you might need or want to change; however, you should take the time to read through the entire httpd.conf file so you get a more complete understanding of its contents. So, to get started: 1. Make a copy of your httpd.conf file: cp httpd.conf httpd.conf.orig (Also do this for any extra.conf file that you need to change.) 2. Open httpd.conf in a text editor. 3. Step through the following sections on changing the httpd.conf file. Identifying File Locations You can change the location of the files and directories used by the Apache web server. Many of these locations are set using the full path, while others are set relative to the value of the ServerRoot directive. This section shows the default values set for the files and directories that Apache uses.

CTEC1863/2017F Lab #11, Part 1 Page 3 of 11 The following is how the ServerRoot directive is set in the httpd.conf file: ServerRoot "/usr/local/apache" This line indicates that any path defined in the httpd.conf file that doesn't begin with a slash (/) has /usr/local/apache prepended to it. The location of the documents that your web server shares with others on the network is set using the DocumentRoot directive. The following value of DocumentRoot causes all documents in the directory (and its subdirectories) to be made available via a URL: DocumentRoot "/usr/local/apache/htdocs" The DocumentRoot directory maps into the "root" (/) directory for the web site i.e., the "top" of the web site. Errors encountered by the Apache web server are copied to the log file identified by the ErrorLog directive. The following global directive is set to cause Apache error messages to be copied to /usr/local/apache/logs/error_log: ErrorLog logs/error_log (because the ServerRoot [/usr/local/apache] is prepended to logs/error_log). You can customize how information from Apache server activities is logged. There is one CustomLog directive set, by default, to output formatted information to a specific log file each time someone accesses content on your web server: CustomLog logs/access_log common Besides those directives that are already noted, there are other directives that set locations of specific types of content within the directory structure that contains the web server content. Take your time and review the entries in the httpd.conf file. Allocating Resource Usage Heavy traffic to your web server can place heavy demands on your system. There are several directives you can use to limit the amount of system resources that can be consumed by Apache processing.

CTEC1863/2017F Lab #11, Part 1 Page 4 of 11 By allowing persistent connections to your web server (i.e., ones that let a client request more than one item with each request) your web server can operate more efficiently. The persistent connection feature is turned on by default with the KeepAlive directive as follows: KeepAlive On With KeepAlive set to On, you can set two directives that impact how persistent connections behave. MaxKeepAliveRequests is set to allow up to 100 requests for content from a single connection. KeepAliveTimeout is set to wait 15 seconds on a connection from the same client for additional requests before dropping the connection. The following shows how those values are set: MaxKeepAliveRequests 100 KeepAliveTimeout 15 The number of httpd server processes that are running on your system can have an impact on its performance. Apache tries to adapt to the demands on your server by dynamically creating more server processes (via the fork() system call) if the load requires more servers to handle the processing. The following are several directives that affect the number of server processes available on your system: MinSpareServers 5 MaxSpareServers 10 StartServers 5 With these settings, if there are fewer than five server processes waiting for a request (MinSpareServers), then a new server process is started. If there are more than ten servers idle (MaxSpareServers), extra server processes are stopped. Five servers are started initially (StartServers). Because the maximum number of servers running indicate the maximum number of clients that can be connected to your server at any one time, having enough server processes is important to prevent access from being denied. Conversely, allowing more servers than your computer can handle can result in too much demand, taking down your server. The following directive can be used to adjust the availability of resources to clients from your server: MaxRequestWorkers 150

CTEC1863/2017F Lab #11, Part 1 Page 5 of 11 Up to 150 clients (MaxRequestWorkers) can be served at the same time by default. If your server is under greater demand, you can increase the number, provided that your hardware can handle the additional load. The rule of thumb for configuring Apache is taken from the "Apache Performance Notes" web page (http://httpd.apache.org/docs/misc/perf-tuning.html): "The single biggest hardware issue affecting webserver performance is RAM. A webserver should never ever have to swap, swapping increases the latency of each request beyond a point that users consider "fast enough". This causes users to hit stop and reload, further increasing the load. You can, and should, control the MaxRequestWorkers setting so that your server does not spawn so many children it starts swapping. "Beyond that the rest is mundane: get a fast enough CPU, a fast enough network card, and fast enough disks, where 'fast enough' is something that needs to be determined by experimentation." Setting Up Web Server Content Based on values in httpd.conf, there is some structure already in place to contain your web server's content. As noted earlier, the default locations for you to place the content that is made available by your web server are: 1. /usr/local/apache/htdocs - This is the primary location of files served by your web server. This location is set by the value of DocumentRoot in the httpd.conf file. 2. ~user/public_html - Users can create their own public_html directories within their home directories. For example, if someone tries to access a user's personal web page by typing something like http://www.whatever.tld/~chris then Apache accesses the public_html directory content in user chris's home directory, such as /home/chris/public_html/index.html For users to allow access to their public_html directories, they probably need to change access permissions to their home directory. For example, the user named chris could type chmod 755 $HOME to open her directory for web server access.

CTEC1863/2017F Lab #11, Part 1 Page 6 of 11 Though you can set up the structure of your htdocs directory tree as you please, there is some structure already in place. Of course, using directives in the httpd.conf file, you can change the locations of these elements. The following is a list of the default locations used to contain your web server content: /usr/local/apache/cgi-bin/ This directory is set up to contain server CGI (Common Gateway Interface) scripts. /usr/local/apache/icons/ This directory contains icon graphics that are distributed with the Apache server and can be used freely with web content. When a client opens a URL to connect to your web site, instead of seeing a listing of files in the directory requested, the Apache server looks for a file in that directory based on the value of the DirectoryIndex directive. The following is how that directive is set by default: <IfModule mod_dir.c> DirectoryIndex index.html </IfModule> A more flexible setting may allow for alternate names or forms of index documents. For example, DirectoryIndex index.php index.cgi index.html default.htm With the preceding line, if an index.php (a PHP script) file is found, the contents of that file are processed and the output is returned to the client. Otherwise, the server looks for an index.cgi (typically, a Perl CGI script), and index.html (the default for Apache) and default.htm (the default for classic Microsoft IIS) in that order to find a page to display. So, if you are setting up your own web server from scratch, the first file you want to replace is the index.html file in the /usr/local/apache/htdocs directory. Or you can remove that file and replace it with one of the other index files. By default on UNIX, Apache runs as the nobody user and the nobody group. This is to provide security, so that the web server software is not running as root, preventing any crackers from exploiting any security holes. (Because nobody and nobody are very general, we can create a user and group specific to the web server, that have the same lack of privileges.)

CTEC1863/2017F Lab #11, Part 1 Page 7 of 11 Installing Apache NOTE: These instructions are intended for CentOS 7. To start, download Apache from the course web site. The latest version can always be downloaded from http://httpd.apache.org/ The three files that are needed: apr-1.6.2.tar.bz2 apr-util-1.6.0.tar.bz2 httpd-2.4.27.tar.bz2 I have bundled all three of these (plus PHP [php-5.6.31.tar.xz] for Part 3) into one tarball: lab11src.tar.xz (This tarball uses xz compression, which is presently one of the most compact forms available on Linux.) From the command line, the wget tool is useful: 1a) Download the tarball to the c.w.d.: wget http://192.197.62.35/courses/ctec1863/labs/lab11/lab11src.tar.xz 1b) Extract the contents of the tarball into the c.w.d.: tar Jxf lab11src.tar.xz or 2) Download and extract the tarball in one command: wget -O - http://192.197.62.35/courses/ctec1863/labs/lab11/lab11src.tar.xz tar Jxf - or... continued...

CTEC1863/2017F Lab #11, Part 1 Page 8 of 11... Download instructions continued... 3a) Use Firefox (or another web browser) to download the tarball; typically, it will be downloaded into your Downloads directory. 3b) Extract the browser-downloaded tarball into the c.w.d.: tar Jxf ~/Downloads/lab11src.tar.xz All of these tar commands will create and extract lab11 in the c.w.d. Run pwd so you remember what that directory is. su - Become root cd dir/lab11/ cd scripts/ it should be there I have written several shell scripts to save you typing Update CentOS and Install Additional Linux Software Required Before Building./update_centos./install_prereqs Build and Install Apache HTTP Server./build_apache Your Local Installation Before running Apache, for the first time, edit the main Apache configuration file, httpd.conf, found in the /usr/local/apache/conf directory. Since we are not running Apache "live" on the Internet with a fully-qualified domain name (FQDN) and our own DNS server, we need to change the ServerName directive so that Apache does not complain on start up.

CTEC1863/2017F Lab #11, Part 1 Page 9 of 11 Uncomment the ServerName line, i.e., remove the # at the start of the line if it is commented out, and change the setting to your current IP address. (The other setting is your email address.) For example: Save the file. Whenever you make changes to httpd.conf, you should check to make sure that the changes you made are acceptable: /usr/local/apache/bin/apachectl configtest You should see the "Syntax OK" message. If not, you need to correct your httpd.conf file. Procedure to edit and test Apache configuration; then start, test, and stop Apache: cd /usr/local/apache/conf/ vi httpd.conf (Don't actually use vi, use pico, nano or gedit!)../bin/apachectl configtest../bin/apachectl start ps -ef grep httpd cd../logs/ cat error_log cat access_log

CTEC1863/2017F Lab #11, Part 1 Page 10 of 11 wget -q -O - http://localhost/ cat access_log../bin/apachectl stop cat error_log../bin/apachectl start Improving the Web Site Content With a text editor, edit the index.html, convert it to proper HTML5, and put your name in the <title> section: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>mike Boldin's Web Site</title> </head> <body> <h1>it works!</h1> </body> </html> Viewing Web Pages Test URLs in Firefox on CentOS using your hostname. (Use your IP address from another computer [Linux or Windows] connected to the CIT network.) You can also use the wget command on Linux. You will see the raw HTML output, as opposed to the processed HTML presentation generated by a web browser: wget -q -O - http://localhost/ The -O option (capital O) specifies the output file, -O - combination causes wget to write its output to standard output i.e., to your Terminal window. (The -q switch ["quiet"] suppresses any connection/progress/protocol information output by wget; it turns off any status messages, so you only see the web content.)

CTEC1863/2017F Lab #11, Part 1 Page 11 of 11 SUMMARY: To start up Apache: /usr/local/apache/bin/apachectl start SUMMARY: To restart Apache after changing its configuration: /usr/local/apache/bin/apachectl restart SUMMARY: To shut down Apache: /usr/local/apache/bin/apachectl stop Finally, to automatically start and stop Apache as a service: 1) Manually stop Apache (see above) 2) cd back to the lab11/scripts directory 3)./make_apache_service When You Are Done Run the following command: ls -lr /usr/local/apache gzip -9c > ls-lr.gz Email ls-lr.gz and your /usr/local/apache/conf/httpd.conf file to your professor. (Or post on BB.)