apache2/apache2-README.QUICKSTART

102 lines
4.8 KiB
Plaintext

QUICKSTART -- How to get your server up and running as fast as possible
o General machine setup:
- configure your network
- make sure that all components are current, by running YaST Online Update
regularly
o synchronise time (parts of the HTTP protocol depend on correct time):
- configure machine as NTP client, either with the YaST configuration module or
by editing /etc/ntp.conf (just put a server name into it) and starting
"rcxntpd start", and running "chkconfig -a xntpd"
o if you run a firewall, make sure to allow access through port 80 if the server
should be reachable from other machines.
o start the server, and configure it to automatically start at boot time:
- rcapache2 start
- chkconfig -a apache2
o add web pages:
- the DocumentRoot is at /srv/www/htdocs
- if you add documents somewhere else and link to them with e.g.
Alias someplace "/path/to/someplace"
make sure to also use <Directory /path/to/someplace> ... </Directory>
to define access permissions and options for that directory, since
(starting with SuSE Linux 9.0) access to the entire filesystem is blocked
by default. See http://httpd.apache.org/docs-2.2/mod/core.html#directory
o go through /etc/sysconfig/apache2:
- check loaded modules (APACHE_MODULES="...").
- add "php4", "perl", or other needed modules to APACHE_MODULES al gusto.
- modules can be enabled/disabled in a simple (Debian-compatible ;) way from
the command line like this:
a2enmod php5
a2dismod php5
- there is also a command a2enflag, to change APACHE_SERVER_FLAGS
- restart the server ('rcapache2 restart')
o where to add your own configuration:
- add e.g. /etc/apache2/httpd.conf.local and change APACHE_CONF_INCLUDE_FILES
in /etc/sysconfig/apache2, e.g. APACHE_CONF_INCLUDE_FILES="httpd.conf.local"
- to understand the hierarchy and layout of all include files, read the
comments at the top of httpd.conf
- if you strongly prefer the old, single, 40K, monolithic configuration file,
it's there! Just use it:
mv /etc/apache2/httpd.conf /etc/apache2/httpd.conf.dist
cp /usr/share/doc/packages/apache2/httpd-std.conf-prefork /etc/apache2/httpd.conf
rcapache2 restart
o add virtual hosts:
- edit /etc/apache2/listen.conf. It is a suitable place to add
NameVirtualHost directives.
- copy the commented template /etc/apache2/vhosts.d/vhost.template to
/etc/apache2/vhosts.d/yourhost.conf
(note, it must end in .conf to be automatically read)
- edit /etc/apache2/vhosts.d/yourhost.conf to suit your needs
- alternative approach: simply append the NameVirtualHost directive and the
<VirtualHost> container to your local configuration (httpd.conf.local --
see above)
- if in doubt about how apache interprets your vhost setup, always use
httpd2 -S. If SSL is involved you will need to run httpd2 -S -DSSL instead --
likewise for other needed defines.
- the "default" server, which responds to requests not handled by other
vhosts, is always the one which is defined first. If you want a dedicated
"default" server for such requests, you need to put it first in the configuration.
If the configuration is in multiple files, like /etc/apache2/vhosts.d/*.conf, then
simply name the file _default.conf, or e.g. _192.168.0.1.conf if you do it per IP
address.
o TROUBLESHOOTING -- if anything does not work:
- fire up "tail -F /var/log/apache2/*_log &" in a root shell
- reproduce what is not working (starting apache, doing client requests,
or whatever), and see how it is reflected in the logs
- read http://www.suse.com/~poeml/apache-faq.html
- make use of http://bugzilla.novell.com if you suspect a bug
o for all configuration questions, consult
http://localhost/manual (if the apache2-doc package is installed), or
http://httpd.apache.org/docs-2.2/ (the online version)
- read the documentation under /usr/share/doc/packages/apache2/ (where you
will also find example configuration files)
o building 3rd party modules:
- install apache2-devel (and of course gcc as well as other needed
development tools)
- use
apxs2 -- to build a module for all MPM types, or
apxs2-prefork -- to build a module for the Prefork MPM, or
apxs2-worker -- to build a module for the Worker MPM
(see man 8 apxs2). In most cases you can just use "apxs2", the most
notably exception being mod_php4. Using apxs2-prefork then will prevent
you from accidentally trying to use the module with the Worker MPM.
Typical example: apxs2 -c -i -a mod_foo.c
-c compiles
-i installs the module in the right place
-a activates the module by running 'a2enmod mod_foo'
- if the module's build system does not allow to use apxs, use at least
CFLAGS=$(apxs2 -q CFLAGS)
to determine the right compiler flags for your apache installation.