Add a section about the Apache HTTP Server :
Installing, basic required httpd.conf configuration directives, additional available Apache modules, mod_ssl, PHP, etc.. Sponsored by: FreeBSD Mall, Inc.
This commit is contained in:
parent
bf5ab71c94
commit
f16e4ec5b5
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=21603
1 changed files with 238 additions and 0 deletions
|
@ -3875,6 +3875,244 @@ zone "10.168.192.in-addr.arpa" in {
|
||||||
</sect2>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
<sect1 id="network-apache">
|
||||||
|
<sect1info>
|
||||||
|
<authorgroup>
|
||||||
|
<author>
|
||||||
|
<firstname>Murray</firstname>
|
||||||
|
<surname>Stokely</surname>
|
||||||
|
<contrib>Contributed by </contrib>
|
||||||
|
</author>
|
||||||
|
</authorgroup>
|
||||||
|
</sect1info>
|
||||||
|
<title>Apache HTTP Server</title>
|
||||||
|
|
||||||
|
<indexterm><primary>web server</primary>
|
||||||
|
<secondary>setting up</secondary></indexterm>
|
||||||
|
<indexterm><primary>Apache</primary></indexterm>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Overview</title>
|
||||||
|
|
||||||
|
<para>&os; is used to run some of the busiest web sites in the
|
||||||
|
world. The majority of web servers on the Internet are using
|
||||||
|
the the <application>Apache HTTP Server</application>.
|
||||||
|
<application>Apache</application> software packages should be
|
||||||
|
included on your FreeBSD installation media. If you did not
|
||||||
|
install <application>Apache</application> when you first
|
||||||
|
installed FreeBSD, then you can install it from the <filename
|
||||||
|
role="package">www/apache13</filename> or <filename
|
||||||
|
role="package">www/apache2</filename> port.</para>
|
||||||
|
|
||||||
|
<para>Once <application>Apache</application> has been installed
|
||||||
|
successfully, it must be configured.</para>
|
||||||
|
|
||||||
|
<note><para>This section covers version 1.3.X of the
|
||||||
|
<application>Apache HTTP Server</application> as that is the
|
||||||
|
most widely used version for &os;. Apache 2.X introduces many
|
||||||
|
new technologies but they are not discussed here. For more
|
||||||
|
information about Apache 2.X, please see <ulink
|
||||||
|
url="http://httpd.apache.org/"></ulink>.</para></note>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Configuration</title>
|
||||||
|
|
||||||
|
<indexterm><primary>Apache</primary>
|
||||||
|
<secondary>configuration file</secondary></indexterm>
|
||||||
|
|
||||||
|
<para>The main Apache HTTP Server configuration file is
|
||||||
|
installed as
|
||||||
|
<filename>/usr/local/etc/apache/httpd.conf</filename> on &os;.
|
||||||
|
This file is a typical Unix text configuration file with
|
||||||
|
comment lines beginning with the <literal>#</literal>
|
||||||
|
character. A comprehensive description of all possible
|
||||||
|
configuration options is outside the scope of this book, so
|
||||||
|
only the most frequently modified directives will be described
|
||||||
|
here.</para>
|
||||||
|
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term>ServerRoot "/usr/local"</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>This specifies the default directory hierarchy for
|
||||||
|
the Apache installation. Binaries are stored in the
|
||||||
|
<filename role="directory">bin</filename> and
|
||||||
|
<filename role="directory">sbin</filename> subdirectories
|
||||||
|
from this root, and configuration files are store in
|
||||||
|
<filename role="directory">etc/apache</filename>.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>ServerAdmin you@your.address</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Your address, where problems with the server should
|
||||||
|
be emailed. This address appears on some
|
||||||
|
server-generated pages, such as error documents.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>ServerName www.example.com</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>ServerName allows you to set a host name which is
|
||||||
|
sent back to clients for your server if it's different
|
||||||
|
than the one the program would get (i.e., use "www"
|
||||||
|
instead of the host's real name).</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>DocumentRoot "/usr/local/www/data"</term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>DocumentRoot: The directory out of which you will
|
||||||
|
serve your documents. By default, all requests are taken
|
||||||
|
from this directory, but symbolic links and aliases may
|
||||||
|
be used to point to other locations.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
|
||||||
|
<para>It's always a good idea to make backup copies of your
|
||||||
|
Apache configuration file before making changes. Once you are
|
||||||
|
satisfied with your initial configuration you are ready to
|
||||||
|
start running <application>Apache</application>.</para>
|
||||||
|
|
||||||
|
<!-- sect3 for performance tuning directives? maxservers minservers -->
|
||||||
|
<!-- etc..?? -->
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Running <application>Apache</application></title>
|
||||||
|
|
||||||
|
<indexterm><primary>Apache</primary>
|
||||||
|
<secondary>starting or stopping</secondary></indexterm>
|
||||||
|
|
||||||
|
<para><application>Apache</application> does not run from the
|
||||||
|
<application>inetd</application> super server as many other
|
||||||
|
network servers do. It is configured to run standalone for
|
||||||
|
better performance for incoming HTTP requests from client web
|
||||||
|
browsers. A shell script wrapper is included to make
|
||||||
|
starting, stopping, and restarting the server as simple as
|
||||||
|
possible. To start up <application>Apache</application> for
|
||||||
|
the first time, just run:</para>
|
||||||
|
|
||||||
|
<screen>&prompt.root; <userinput>/usr/local/sbin/apachectl start</userinput></screen>
|
||||||
|
|
||||||
|
<para>You can stop the server at any time by typing :</para>
|
||||||
|
|
||||||
|
<screen>&prompt.root; <userinput>/usr/local/sbin/apachectl stop</userinput></screen>
|
||||||
|
|
||||||
|
<para>After making changes to the configuration file for any
|
||||||
|
reason, you will need to restart the server:</para>
|
||||||
|
|
||||||
|
<screen>&prompt.root; <userinput>/usr/local/sbin/apachectl restart</userinput></screen>
|
||||||
|
|
||||||
|
<para>To launch <application>Apache</application> at system
|
||||||
|
startup, add the following line to
|
||||||
|
<filename>/etc/rc.conf</filename>:</para>
|
||||||
|
|
||||||
|
<programlisting>apache_enable="YES"</programlisting>
|
||||||
|
|
||||||
|
<para>If you would like to supply additional command line
|
||||||
|
options for the <application>Apache</application>
|
||||||
|
<command>httpd</command> program started at system boot, you
|
||||||
|
may specify them with an additional line in
|
||||||
|
<filename>rc.conf</filename>:</para>
|
||||||
|
|
||||||
|
<programlisting>apache_flags=""</programlisting>
|
||||||
|
|
||||||
|
<para>Now that the web server is running, you can view your web
|
||||||
|
site by pointing a web browser to
|
||||||
|
<literal>http://localhost/</literal>. The default web page
|
||||||
|
that is displayed is
|
||||||
|
<filename>/usr/local/www/data/index.html</filename>.</para>
|
||||||
|
|
||||||
|
</sect2>
|
||||||
|
|
||||||
|
<sect2>
|
||||||
|
<title>Apache Modules</title>
|
||||||
|
|
||||||
|
<indexterm><primary>Apache</primary>
|
||||||
|
<secondary>modules</secondary></indexterm>
|
||||||
|
|
||||||
|
<para>There are many different Apache modules available to add
|
||||||
|
functionality to the basic server. The FreeBSD Ports
|
||||||
|
Collection provides an easy way to install
|
||||||
|
<application>Apache</application> together with some of the
|
||||||
|
more popular add-on modules.</para>
|
||||||
|
|
||||||
|
<sect3>
|
||||||
|
<title>mod_ssl</title>
|
||||||
|
|
||||||
|
<indexterm><primary>web server</primary>
|
||||||
|
<secondary>secure</secondary></indexterm>
|
||||||
|
<indexterm><primary>SSL</primary></indexterm>
|
||||||
|
<indexterm><primary>cryptography</primary></indexterm>
|
||||||
|
|
||||||
|
<para>The mod_ssl module uses the OpenSSL library to provide
|
||||||
|
strong cryptography via the Secure Sockets Layer (SSL v2/v3)
|
||||||
|
and Transport Layer Security (TLS v1) protocols. This
|
||||||
|
module provides everything necessary to request a signed
|
||||||
|
certificate from a trusted certificate signing authority so
|
||||||
|
that you can run a secure web server on &os;.</para>
|
||||||
|
|
||||||
|
<para>If you have not yet installed
|
||||||
|
<application>Apache</application>, then a version of Apache
|
||||||
|
that includes mod_ssl may be installed with the <filename
|
||||||
|
role="package">www/apache13-modssl</filename> port.</para>
|
||||||
|
|
||||||
|
<!-- XXX add more information about configuring mod_ssl here. -->
|
||||||
|
<!-- Generating keys, getting the key signed, setting up your secure -->
|
||||||
|
<!-- web server! -->
|
||||||
|
</sect3>
|
||||||
|
|
||||||
|
<sect3>
|
||||||
|
<title>mod_perl</title>
|
||||||
|
|
||||||
|
<indexterm><primary>Perl</primary></indexterm>
|
||||||
|
|
||||||
|
<para>The Apache/Perl integration project brings together the
|
||||||
|
full power of the Perl programming language and the Apache
|
||||||
|
HTTP server. With the mod_perl module it is possible to
|
||||||
|
write Apache modules entirely in Perl. In addition, the
|
||||||
|
persistent interpreter embedded in the server avoids the
|
||||||
|
overhead of starting an external interpreter and the penalty
|
||||||
|
of Perl start-up time.</para>
|
||||||
|
|
||||||
|
<para>If you have not yet installed
|
||||||
|
<application>Apache</application>, then a version of Apache
|
||||||
|
that includes mod_perl may be installed with the <filename
|
||||||
|
role="package">www/apache13-modperl</filename> port.</para>
|
||||||
|
</sect3>
|
||||||
|
|
||||||
|
<sect3>
|
||||||
|
<title>PHP</title>
|
||||||
|
|
||||||
|
<indexterm><primary>PHP</primary></indexterm>
|
||||||
|
|
||||||
|
<para>PHP, which stands for <quote>PHP: Hypertext
|
||||||
|
Preprocessor</quote> is a widely-used Open Source
|
||||||
|
general-purpose scripting language that is especially suited
|
||||||
|
for Web development and can be embedded into HTML. Its
|
||||||
|
syntax draws upon C, Java, and Perl, and is easy to learn.
|
||||||
|
The main goal of the language is to allow web developers to
|
||||||
|
write dynamically generated webpages quickly, but you can do
|
||||||
|
much more with PHP.</para>
|
||||||
|
|
||||||
|
<para>PHP may be installed from the <filename
|
||||||
|
role="package">lang/php5</filename> port.</para>
|
||||||
|
</sect3>
|
||||||
|
</sect2>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="network-ntp">
|
<sect1 id="network-ntp">
|
||||||
<sect1info>
|
<sect1info>
|
||||||
<authorgroup>
|
<authorgroup>
|
||||||
|
|
Loading…
Reference in a new issue