1. Context 8 Configuring Apache 8.1 Site-wide Directives . . . . 8.2 Directory block Directives 8.3 Access Control . . . . . . 8.4 Other Directives . . . . . . License of this Document 1.113.3 2 5 5 6 6 6 7 1.113.3 Operate and perform basic configuration of Apache Weight 4 Linux Professional Institute Certification — 102 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1 Context Topic 113 Networking Services [24] 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 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] 2005 July Outline 2 Objective Contents 1 2 3 4 5 Context Objective Resources Intro to Apache Starting and Stopping Apache 2 2 2 3 3 3 4 4 Description of Objective 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. Key files, terms, and utilities include: 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 6 apachectl 7 httpd options 7.1 httpd Options with Parameters . . . . . . . . . . . . . . . . . . . . . . . 3 Resources Operate and Perform Basic Configuration of Apache Apache home page: http://httpd.apache.org 4. Intro to Apache 1.113.3 3 7. httpd options 1.113.3 4 4 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 • 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) Apache 7 5 Starting and Stopping Apache • Apache can be started: – On demand through inetd or xinetd – As a daemon • 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 Starting and Stopping Apache httpd options httpd Options The httpd deamon can be run directly if needed. On Debian the daemon is called 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 6 apachectl 7.1 httpd Options with Parameters httpd options with parameters The following options take parameters: apachectl apachectl is a management utility. To use it: $ sudo apachectl command ← 8. Configuring Apache 1.113.3 5 8.2 Directory block Directives 1.113.3 6 8.2 Directory block Directives 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 AllowOverride None This says that the .htaccess file can not override settings for this directory Directory block Directives You can set directives so that thay only apply to a particular part of the content directory tree. For example: 8 Configuring Apache • Apache originally (a decade ago) used 3 configuration files: – httpd.conf — Server settings – srm.conf — File types & doc specs – access.conf — Security settings • All configuration is now done in httpd.conf • Normally located in /etc/httpd/conf 8.3 Access Control 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. Configuring Apache 8.1 Site-wide Directives Site-wide Directives 8.4 Other Directives 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. 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 9. License of this Document 1.113.3 7 • Virtual hosts (multiple sites on one host) • Logging directives 9 License of this Document License of this Document 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.