1.113.3 Operate and perform basic configuration of Apache Weight 4 1.113.3 Operate and perform basic configuration of Apache Weight 4 Linux Professional Institute Certification — 102 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Andrew Eager andrew.eager@aes-pl.com.au Geoffrey Robertson ge@ffrey.com Nick Urbanik nicku@nicku.org This document Licensed under GPL—see section 9 License of this Document 2005 July Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Topic 113 Networking Services [24] Where we are up to 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective 1.113.1 Configure and manage inetd, xinetd, and related services [4] 1.113.2 Operate and perform basic configuration of sendmail [4] 1.113.3 Operate and perform basic configuration of Apache [4] 1.113.4 Properly manage the NFS, smb, and nmb daemons [4] 1.113.5 Setup and configure basic DNS services [4] 1.113.7 Set up secure shell (OpenSSH) [4] Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Description of Objective 1.113.3 Operate and perform basic configuration of Apache 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Candidates should be able to modify simple parameters in Apache configuration files, start, stop, and restart httpd, arrange for automatic restarting of httpd upon boot. Does not include advanced custom configuration of Apache. Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Key files, terms, and utilities include: 1.113.3 Operate and perform basic configuration of Apache 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective httpd.conf — main configuration file for Apache apachectl — a program to send commands to a running Apache server, especially the graceful command httpd — the Apache server program Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Operate and Perform Basic Configuration of Apache Resources of Interest 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Apache home page: http://httpd.apache.org Configuring Apache License of this Document Apache 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Apache is a web server (http daemon) Default on all Linux distros Most popular web server on the internet Named after the number of patches to orginal source code Provides both HTTP and HTTPS (SSL) as standard Other features added with modules (eg cgi) Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Starting and Stopping Apache 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Apache can be started: On demand through inetd or xinetd As a daemon Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document Normally started as daemon to reduce connect delay Uses standard SysV start/stop semantics Debian, Red Hat: $ sudo /etc/init.d/apache start ← Red Hat/Fedora: $ sudo service httpd start ← An alternative is apachectl $ sudo service httpd graceful ← actually calls apachectl apachectl apachectl is a management utility. To use it: $ sudo apachectl command ← 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache command start stop restart fullstatus graceful configtest help function Start the daemon Stop the daemon Restart or start the daemon Report status of server (requires lynx) Gracefully restart the server Test config file syntax Display commands Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document httpd Options The httpd deamon can be run directly if needed. On Debian the daemon is called apache. 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Option -v -V -h -l -L -S -t -T Function Shows version Shows compile configuration List all cmd line parameters List compiled in modules List config directives Shows parsed settings (virtual hosts only) Test config file & doc root Test config file only Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache License of this Document Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache License of this Document httpd options with parameters 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective The following options take parameters: Parameter -D name -d directory -f file -C "directive" -c "directive" Function Defines a name for use in IfDefine name Defines an alternate server root Set a new configuration file Process directive before reading config file Process directive after reading config file Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache License of this Document Configuring Apache 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Apache originally (a decade ago) used 3 configuration files: httpd.conf — Server settings srm.conf — File types & doc specs access.conf — Security settings Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives All configuration is now done in httpd.conf Normally located in /etc/httpd/conf License of this Document Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Site-wide Directives 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Directive ServerAdmin ServerName DocumentRoot ServerRoot ServerType MinSpareServers MaxSpareServers StartServers MaxClients Function Sets email address for admin Sets the name of the server Sets the root for content served Sets root for server files standalone or inetd No of free httpd’s before starting more No of free httpd’s before killing some No of httpd’s to start Maximum no of httpd’s to run at once. Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Directory block Directives 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources You can set directives so that thay only apply to a particular part of the content directory tree. For example: AllowOverride None This says that the .htaccess file can not override settings for this directory Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Access Control This directive controls who can access what directories on your site. This is about the only directive that needs to be changed from an ‘off-the-shelf’ configuration if you don’t want external users to access your site. order deny,allow deny from all allow from 127.0.0.0/255.0.0.0 allow from .c222 This says to deny first then allow. The result is that only users in the .c222 domain and the localhost will be able to access the server. 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Outline 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Other Directives 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives There are a large number of configuration directives. These are grouped as follows: Aliases and Redirects Default pages User Web Directories (site content in a users home) MIME types CGI files Directory Browsing Authentication Virtual hosts (multiple sites on one host) Logging directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document Topics Covered Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options httpd Options with Parameters Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache Site-wide Directives Directory block Directives Access Control Other Directives License of this Document License of this Document 1.113.3 Operate and perform basic configuration of Apache Weight 4 Andrew Eager Context Objective Copyright c 2005, 2003 Andrew Eager , Geoffrey Robertson and Nick Urbanik . Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version. Resources Intro to Apache Starting and Stopping Apache apachectl httpd options Configuring Apache License of this Document