[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


Setup Apache httpd server

This is a general how to to get a basic httpd service up and running.

Applies to:
Slackware 14.1 (and possibly previous versions)
Apache 2 (and possibly previous versions)

BASIC SETUP

1) Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary:

vi /etc/httpd/httpd.conf

  ServerAdmin you@myawesomeserver.com  <---OPTIONAL
  ServerName www.myawesomeserver.com:80
  
  <Directory />
      AllowOverride none
      Require all denied
  </Directory>

  DocumentRoot "/srv/httpd/htdocs"
  <Directory "/srv/httpd/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
  </Directory>

  <IfModule dir_module>
      DirectoryIndex index.html index.htm index.pl index.php
  </IfModule>
  
  ErrorLog "/var/log/httpd/error_log"
  
  CustomLog "/var/log/httpd/access_log" common
  
  Include /etc/httpd/extra/httpd-autoindex.conf <---OPTIONAL but nice. this creates a directory listing if index.html is missing.
  Include /etc/httpd/extra/httpd-default.conf   <---OPTIONAL

All other default settings should be good.

HINT: With these settings, your default webpages should be put in /srv/httpd/htdocs. Your default logs should be under /var/log/httpd.

2) Make it start on boot.

chmod 755 /etc/rc.d/rc.httpd
/etc/rc.d/rc.httpd start

USER DIRECTORIES

This will allow users to have individual web space (/home/USER/public_html). These can be accessed from the web by adding “~USERNAME” to the URL.
EXAMPLE:
http://www.slackware.com/~pat

1) Edit /etc/httpd/httpd.conf, change/uncomment the following:

 vi /etc/httpd/httpd.conf

  LoadModule authz_host_module lib64/httpd/modules/mod_authz_host.so
  LoadModule authz_user_module lib64/httpd/modules/mod_authz_user.so
  LoadModule authz_core_module lib64/httpd/modules/mod_authz_core.so
  LoadModule userdir_module lib64/httpd/modules/mod_userdir.so
  Include /etc/httpd/extra/httpd-userdir.conf

2) Edit /etc/httpd/extra/httpd-userdir.conf, change/uncomment the following:

vi /etc/httpd/extra/httpd-userdir.conf

  <Directory "/home/*/public_html">
      AllowOverride FileInfo AuthConfig Limit Indexes
      Options MultiViews Indexes SymLinksIfOwnerMatch
      Require method GET POST OPTIONS
  </Directory>

3) Restart Apache

/etc/rc.d/rc.httpd restart

CGI-BIN

This enables CGI script execution on your webserver.

1) Edit /etc/httpd/httpd.conf, change/uncomment the following:

 vi /etc/httpd/httpd.conf
  LoadModule proxy_fcgi_module lib64/httpd/modules/mod_proxy_fcgi.so
  LoadModule proxy_scgi_module lib64/httpd/modules/mod_proxy_scgi.so
  LoadModule cgid_module lib64/httpd/modules/mod_cgid.so

  <IfModule alias_module>
      ScriptAlias /cgi-bin/ "/srv/httpd/cgi-bin/"
  </IfModule>

  <Directory "/srv/httpd/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
  </Directory>

  <IfModule mime_module>
    AddHandler cgi-script .cgi .pl
  </IfModule>

2) Restart Apache

/etc/rc.d/rc.httpd restart

HINT: Your cgi-bin directory will be /srv/httpd/cgi-bin/. The scripts can be accessed by adding /cgi-bin/SCRIPTNAME to the website URL.

EXAMPLE:
http://www.slackware.com/cgi-bin/awesomescript.pl

NOTE: This does not apply to php scripts, see the below for them.

USER CGI-BIN

1) Setup CGI-BIN as described above.

2) Edit /etc/httpd/extra/httpd-userdir.conf and add the following:

  <Directory "/home/*/public_html/cgi-bin">
    Options ExecCGI
    SetHandler cgi-script
  </Directory>

3) Restart Apache

/etc/rc.d/rc.httpd restart

HINT: This will allow users to run CGI scripts out of their /home/USER/public_html/cgi-bin directory. Their scripts can be accessed through their user directories.

EXAMPLE: http://www.slackware.com/~pat/cgi-bin/webform.pl

ENABLE PHP

to be added

VIRTUAL HOSTS

to be added

HTTPS / SSL

to be added

SNI HTTPS / SSL (Name based https)

to be added

Sources

 howtos:network_services:setup_apache ()