SDB:Apache installation

(Redirected from Apache Quickstart HOWTO)
Jump to: navigation, search


Tested on openSUSE

Recommended articles


Introduction

This document provides a quick step by step guide to get Apache running on your openSUSE box.


Icon-warning.png
Warning: It does not cover the concepts of web servers in detail. Please do not use the steps given below for production machines as the security considerations needed to successfully run a web server have not been taken care of. The below steps are mainly for users wanting or desiring to deploy the Apache software either for further tweaking or web development purposes.



General Machine Setup

The first thing which must be taken care of is the network. The network must be properly configured before proceeding further.

The second thing is to ensure that the system is uptodate. This can be done by opening the YaST Control Center. In the Software section click the Online update icon to check for software update and install them.

Installation of Apache Packages

The Apache web server can be installed by using zypper. Open a terminal and become root. Type the below command:

# zypper in apache2

Firewall Adjustments

By default the firewall configuration blocks all traffic coming on port 80 to your machine. So if you need to allow access so that the web server can be accessed from within a LAN we need to fine tune the firewall configuration. The below step needs to be performed as root user. 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

# sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2
# sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2-ssl
# rcSuSEfirewall2 restart

Starting Server

Start the server and configure it to automatically start at boot time.

# rcapache2 start
# chkconfig -a apache2

Apache Modules

To enable required Apache Modules we can edit APACHE_MODULES in /etc/sysconfig/apache2. Modules can also be enabled/disabled/listed with the commands below. Any such operation requires a restart of the service and of course needs root privileges.

# a2enmod php5
# a2enmod -l
# rcapache2 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:
  • Copy the sample configuration file vhost.template to {DOMAINNAME}.conf and 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 Apache Documentation.
  • 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.

Trouble Shooting

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 with the following command:

# tail -F /var/log/apache2/*

If you suspect a bug, please report it

See also

Related articles

  • SuSE Firewall
  • Package documentation and example configuration files in /usr/share/doc/packages/apache2/

External links