Apache on SUSE Linux runs "out of the box"
with a standard, predefined configuration. By following the instructions
in this chapter, can have the Apache Web server up and
running in little time. You must be
root to install and configure Apache.
The SUSE Linux apache2 package differs slightly in its file system and application layout from the standard software package available on the Apache Web site (http://httpd.apache.org). The following section describes the installation of the SUSE Linux apache2 package in detail and denotes the variations where applicable.
To install a simple Web server, proceed as follows:
Procedure 46.1. Quick Installation
Start YaST in GUI or command line mode.
Select +.
Click to confirm the installation of packages apache2 and apache2-prefork.
When the installation has finished, the appears and you can start configuring the Web server.
The disadvantage in preceeding as instructed above is that there is an absence of PHP and database support. To install a Web server with PHP and database support, proceed as follows:
Procedure 46.2. Installation of Simple Web Server
Start YaST in GUI or command line mode.
Select +.
Select in then check .
Press .
Confirm the installation of the dependent packages to finish the SUSE Linux Apache2 installation process.
For advanced users, SUSE Linux offers custom package selection. To perform a custom installation of a Web server, proceed as follows:
Procedure 46.3. Installation of the Default Apache RPM with YaST
Start YaST in GUI or command line mode. Select +.
Select in then enter
apache2 in the field.
Select apache2 for installation.
Use step 2 and 3 for module selection. See Section 46.5, “Apache Modules”.
After selection press .
You are then prompted to choose one of the dependencies for the necessary
apache2-MPM package:
apache2-prefork or
apache2-worker. Refer to the
Section 46.2.2, “Multiprocessing Modules” for an explanation of the differences
between the two.
If you are not sure, select the apache2-prefork package, which is the
default for Unix-based operating systems then press .
Confirm the installation of the dependent packages to finish the SUSE Linux Apache2 installation process.
![]() | Starting a Web Server |
|---|---|
Installing Apache does not start the Web server automatically. Refer to Section 46.3.3, “Activating, Starting, and Stopping Apache” for information about controlling Apache start-up and shutdown. | |
As mentioned in Installation of the Default Apache RPM with YaST, SUSE Linux provides two different multiprocessing modules (MPMs) for use with Apache. MPMs are responsible for accepting and handling requests to the Web server, representing the core of the Web server software.
The prefork MPM implements a nonthreaded, preforking Web server. It makes the Web server behave similarly to Apache version 1.x in that it isolates each request and handles it by forking a separate child process. Thus problematic requests cannot affect others, avoiding a lockup of the Web server.
While providing stability with this process-based approach, the prefork MPM consumes more system resources than its counterpart, the worker MPM. The prefork MPM is considered the default MPM for Unix-based operating systems.
![]() | MPMs in This Document |
|---|---|
This document assumes Apache is used with the prefork MPM. | |
The worker MPM provides a multithreaded web server. A thread is a “lighter” form of a process. The advantage of a thread over a process is its lower resource consumption. Instead of only forking child processes, the worker MPM serves requests by using threads with server processes. The preforked child processes are multithreaded.
This approach makes Apache perform better by consuming fewer system
resources than the prefork MPM. One major
disadvantage is the stability of the worker MPM: if a thread becomes
corrupt, all threads of a process can be affected. In the worst case,
this may result in a server crash. Especially when using CGI (described in
Section 46.5.1.2, “Common Gateway Interface: mod_cgi
”) with Apache under heavy
load, internal server errors might occur due to threads unable to
communicate with system resources.
Another argument against using the worker MPM with Apache is that not all available Apache modules (see Section 46.5, “Apache Modules”) are thread-safe and thus cannot be used in conjunction with the worker MPM.
![]() | PHP as an Apache Module (mod_php) |
|---|---|
Not all available PHP modules are thread-safe. Using the
worker MPM with | |
SUSE Linux places files of the Apache package into default locations. The locations of the most important files are listed here.
Most of the executable files in SUSE Linux Apache have a
2 appended to them. This simplifies differentiation of
binary files for a parallel
installation of Apache 1.x and Apache 2.x.
/usr/sbin/httpd2
Symbolic link pointing to the chosen multiprocessing module as described
in Section 46.2.2, “Multiprocessing Modules”. The
default is httpd2-prefork. The symlink is maintained
by the start script according to the system configuration setting of the
MPM.
/usr/sbin/httpd2-prefork
The actual Apache2 executable.
/usr/sbin/apache2ctl
Control script to start and stop the Web server, provided by the Apache HTTPD project. See Section 46.3.3, “Activating, Starting, and Stopping Apache” for more information or run /usr/sbin/apache2ctl help.
/etc/init.d/apache2
Start and stop script providing full integration in the SUSE Linux installation and starting Apache at boot time. It checks for a valid configuration before starting and stopping the server and overrides the location of the configuration. It allows easy inclusion of further configuration files, loading of modules, or even start of a seperate instance of the server without modification of the script.
/usr/sbin/rcapache2
A convenient symlink for /etc/init.d/apache2,
because
/etc/init.d/ is not in the path by default. Simply
use rcapache2 start to start Apache.
/usr/sbin/htpasswd2
Utility to generate encrypted passwords for
.htaccess-based authentication. Refer to the
htpasswd2(1) man page for details on how to
use the tool.
Most of the configuration files reside under
/etc/apache2. For information about how to change
configuration
settings, refer to Section 46.3, “Configuration”.
/etc/apache2/httpd.conf
Top-level configuration file. If possible, avoid changes to this file. It mainly includes other configuration files and declares global settings.
/etc/apache2/*.conf
Some external Apache modules put their configuration files in the
directory /etc/apache2/, usually prefixed with
the module name itself (mod_*.conf).
/etc/apache2/conf.d/*
Directory holding various other configuration files that come with
certain packages. For an example, see
Section 46.5.3.2, “Serving PHP: mod_php4, mod_php5
”.
/etc/apache2/vhosts.d/*
Directory holding the optional configuration files for virtual hosts. See Section 46.4, “Virtual Hosts” for details.
/etc/sysconfig/apache2
SUSE Linux configuration file relating to Apache2. It holds all
relevant configuration parameters for controlling the Apache Web
server. /etc/sysconfig/apache2 is used by YaST
for configuring Apache as described in
Section 46.3.1, “Configuring Apache with YaST”. It can also be edited
manually as described in Section 46.3.2, “Configuring Apache Manually”.
By default, Apache provides various information about its runtime status in the following files:
/var/log/apache2/error_log
Apache logs start-up and shutdown notices and all runtime errors into this file.
/var/log/apache2/access_log
All requests to the Web server are logged into this file. The default format of the entries is combined format, showing information about the host and user agent sending the request and the referring URI.
The physical directory /srv/www/htdocs is the
default location from which Apache serves Web pages.
It acts as “root directory” for a client request. To publish
Web pages
with Apache, store the files hierarchically in or
under that directory.
A URL like http://www.example.com/index.html refers to
/srv/www/htdocs/index.html in the
default Apache configuration in SUSE Linux for a domain named
example.com.
Apache is built with a modular approach, meaning that modules provide the capabilities of the Web server software itself. Consequently, Apache can be extended by advanced users by writing custom modules. Refer to the man pages mentioned in the following for more detailed information.
To be able to develop modules for Apache or compile third-party modules,
the package apache2-devel is required along with
the corresponding development tools.
apache2-devel also contains the
apxs2 tools, which are necessary for compiling
additional modules for Apache.
The apxs2 binaries are located under
/usr/sbin:
/usr/sbin/apxs2—suitable for building an extension
module that works with any MPM. The installation location is
/usr/lib/apache2.
/usr/sbin/apxs2-prefork—suitable for
prefork MPM modules. The installation location is
/usr/lib/apache2-prefork.
/usr/sbin/apxs2-worker—suitable for
worker MPM modules.
apxs2 installs modules so they can be used for all
MPMs. The other two programs install modules so they can only be used for
the respective MPMs. apxs2 installs modules in
/usr/lib/apache2 and
apxs2-prefork installs modules in
/usr/lib/apache2-prefork.
apxs2 enables the compilation and installation of
modules from source code (including the required changes to the
configuration files), which creates dynamic shared
objects (DSOs) that can be loaded into Apache at runtime.
Install a module from source code with the commands cd
/path/to/module/source; apxs2 -c -i
mod_foo.c. Other options of
apxs2 are described in the
apxs2(1) man page. The modules should then be
activated
in /etc/sysconfig/apache2 with the entry
APACHE_MODULES as described in
Section 46.3.2, “Configuring Apache Manually”.