View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Apache

From LQWiki

Jump to: navigation, search

Apache is the common name for an open source web server used on Linux systems, written by the Apache Foundation. Since the Apache Foundation has produced a lot of projects, the web server is more correctly known as the "Apache web server" or httpd.

The Apache web server is one of the most popular web servers in current use (powering 69% of web sites according to a recent Netcraft survey).

Contents

General Setup

Apache can be fairly easy to setup and administer. The official Apache httpd website has many resources and documentation.

If you will only be hosting one site with Apache, setup is particularly simple. In /etc/httpd/httpd.conf (or its equivalent, depending on distribution):

  • set the ServerName directive to your servername (which should be resolvable via DNS)
  • disable UserDir unless you want users to publish their own websites in their home directories
  • place your website in the Document Root (varies by distribution; see below).
  • run apachectl start

Test in any browser.


Setting up an apache server with mod_perl, php, mysql and ssl support can be a little bit more difficult. There is an excellent howto on the subject at http://lamps.efactory.de/

Distribution-Specific Setup

Most distributions will already have a standard Apache setup configured in their base system.

Debian and Ubuntu

Apache2 installation and configuration with PHP and SSL support

Apache2 Configuration in Debian

Apache2 installation and configuration with PHP in Ubuntu

Apache2 Installation and Configuration in Ubuntu

Slackware 9.x/10.x

To have Apache start automatically when you boot your system:

  • Make sure the apache-1.3.29 package is installed (or newer version)
  • Make /etc/rc.d/rc.httpd executable (chmod 755 /etc/rc.d/rc.httpd)

The default document root is /var/www/htdocs. Also, the userdir module is loaded by default, allowing users of your system to place their websites in ~/public_html. This is accessible as http://localhost/~username/. Main settings can be changed in /etc/apache/httpd.conf.

Fedora Core 1

  • login as root: su - (the dash allows your /sbin dir to be in $PATH)
  • run: service httpd start (this starts apache)
  • run: chkconfig httpd on (this sets apache to start in your current init)
  • run: redhat-config-securitylevel
    • configure your firewall to allow WWW (HTTP) requests
  • Place your index files in /var/www/html
    • the default page is generally index.html

Settings can be changed in /etc/httpd/conf/httpd.conf

Red Hat's graphical configuration tool (redhat-config-httpd or "Start" > System Settings > Server Settings > HTTP) provices a graphical, easy-to-use interface for configuring Apache.

SuSE

In SuSE, the Document root is /srv/www/htdocs. If you chose to install Apache via YaST, UserDir is enabled, so users can put websites in ~/public_html as in the Debian example above. Set it up using

yast2 -i apache2

To start apache2 on SuSE, use

/etc/init.d/apache2 start

Arch Linux

Arch Linux uses Apache 2.0.

  • Make sure the apache package is installed (pacman -Sy apache)
  • Add httpd to the list of daemons in /etc/rc.conf
  • Optionally start Apache now using /etc/rc.d/httpd start

The userdir module described above is loaded by default. The document root is /home/httpd/html/. The main config files are located at /etc/httpd/conf/.

Gentoo Linux

Gentoo uses Apache 2 by default.

  • To install run: # emerge apache.
  • If you want PHP support you should also run: # emerge mod_php
  • Start Apache with: /etc/init.d/apache2 start
  • And to start at boot run: rc-update add apache2 default
  • The default DocumentRoot is /var/www/localhost/htdocs/
  • The main configuration file is at /etc/apache2/httpd.conf

See also

External links

  • Apache.org (www.apache.org)
    Official website
  • Webmin (www.webmin.com)
    A graphical configuration tool for Apache.
  • Apache Forum (www.nabble.com)
    A large unofficial Apache forum -- hosted by Nabble currently archiving all the Apache projects' mailing lists for cross search and browsing.

Personal tools