Apache Quickstart HOWTO
From openSUSE
| This document describes how to get your server up and running as fast as possible. It is not an extensive introduction into web servers, just a quick step-by-step reference. |
Contents |
General machine setup
Configure your network and make sure that all components are current, by running YaST Online Update regularly. Parts of the HTTP protocol depend on correct time. Configure machine as a NTP client, either with the YaST configuration module or by editing /etc/ntp.conf (just put a server name into it) and running,
# chkconfig -a ntp
Installation of Apache packages
Install the package or the complete LAMP server pattern.
# zypper in -t pattern lamp_server
Firewall
If you run a firewall, make sure to allow access to HTTP(s) ports if the server should be reachable from other machines. The supplied configurations are called apache2 and apache2-ssl. They can be enabled via YaST, by adding them to FW_CONFIGURATIONS_EXT in /etc/sysconfig/SuSEfirewall2 or issuing these commands,
# sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2-ssl
# rcSuSEfirewall2 restart
Starting the server
Start the server and configure it to automatically start at boot time.
# chkconfig -a apache2
Adding web pages
The default DocumentRoot is at /srv/www/htdocs, put the files there.
Apache Modules
Enable required Apache Modules by editing APACHE_MODULES in /etc/sysconfig/apache2. Modules can be enabled/disabled/listed with the commands below. Any such operation requires a restart of the service.
# a2dismod perl
# a2enmod -l
# /etc/init.d/apache restart
Virtual Hosts
The directory for virtual host configurations is /etc/apache2/vhosts.d/. As you can see there are two sample configuration files - one with ssl; one without ssl. We use the template without ssl. Only files ending with ".conf" are automatically included to the apache configuration.
In the following instructions, please replace {DOMAINNAME} with an IP or an domain-name you want.
|
- Plan your website infrastructure. It's helpful to use a directory (
/srv/www/vhosts) including one subdirectory for each virtual host.
- You have to decide which sort of virtual host you need, based on the following options:
- name based
- IP based
- Port based
- Copy the sample configuration file
vhost.templateto{DOMAINNAME}.confand create the subdirectory for this virtual host.
- # cd /etc/apache2/vhosts.d
# cp vhost.template {DOMAINNAME}.conf
# mkdir -p /srv/www/vhosts/{DOMAINNAME}/
- Now edit the copied configuration file and adjust the following as needed:
- Change the document root for your virtual host:
DocumentRoot /srv/www/vhosts/{DOMAINNAME} - You also need to change corresponding directory directive:
<Directory "/srv/www/vhosts/{DOMAINNAME}"> -
<VirtualHost *:80>It is possible to replace the "*" with an IP addess and "80" with a non standard http port. See documentation.
- Change the document root for your virtual host:
- Restart apache.
- # /etc/init.d/apache2 restart
Custom configuration
Add/edit configuration for all virtual hosts to /etc/apache2/default-server.conf. Edit APACHE_CONF_INCLUDE_FILES in /etc/sysconfig/apache2 to include configurations from external files. To understand the hierarchy and layout of all include files, read the comments at the top of httpd.conf The old, single, 40K, monolithic configuration file is available in /usr/share/doc/packages/apache2/httpd-std.conf-prefork.
Troubleshooting
Read any error messages when you start the service. Reproduce what is not working and see how it is reflected in the logs. The log files can be monitored in a root shell,
If you suspect a bug, please report it.
See also
- Apache Virtual Host documentation
- More HOWTOs about Apache web server (LAMP, SSL, WebDAV, VirtualHosts)
- Package documentation and example configuration files in
/usr/share/doc/packages/apache2/
External Links
- Apache's online documentation
- HowTo: Configure a Linux Apache Web Server on openSUSE 10.x and 11.x (including SSI and CGI)
Passed QA check: Fsundermeyer 13:56, 15 June 2009 (UTC)

