logo

Apache HTTP Server

Last Updated: 2021-11-19

Ubuntu: /etc/apache2/sites-available/000-default.conf

HTTPD

httpd is not a specific package, but is provided by some packages:

$ sudo apt-get install httpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package httpd is a virtual package provided by:
nginx-naxsi 1.4.6-1ubuntu3.1
nginx-light 1.4.6-1ubuntu3.1
nginx-full 1.4.6-1ubuntu3.1
nginx-extras 1.4.6-1ubuntu3.1
apache2-mpm-itk 2.4.7-1ubuntu4.1
nginx-core 1.4.6-1ubuntu3.1
apache2-mpm-worker 2.4.7-1ubuntu4.1
apache2-mpm-prefork 2.4.7-1ubuntu4.1
apache2-mpm-event 2.4.7-1ubuntu4.1
apache2-bin 2.4.7-1ubuntu4.1
yaws 1.98-2
webfs 1.21+ds1-9
tntnet 2.2.1-1
ocsigenserver 2.2.0-3
mini-httpd 1.19-9.3
micro-httpd 20051212-15
lighttpd 1.4.33-1+nmu2ubuntu2
ebhttpd 1:1.0.dfsg.1-4.3
bozohttpd 20111118-1
boa 0.94.14rc21-5
aolserver4-daemon 4.5.1-16
aolserver4-core 4.5.1-16
You should explicitly select one to install.

E: Package 'httpd' has no installation candidate

Install:

$ sudo apt-get install apache2

Serve Static Website

<VirtualHost *:80>
    DocumentRoot /var/www/yourwebsite
    ServerName www.yourwebsite.com
</VirtualHost>

Proxy

Assume your website is served by some other tools(e.g. node) at 127.0.0.1:2368

<VirtualHost *:80>
    ServerName www.yourwebsite.com
    ProxyPreserveHost on
    ProxyPass / http://127.0.0.1:2368/
    ProxyPassReverse / http://127.0.0.1:2368/
</VirtualHost>

Config files

Redhat / Fedora distributions

/etc/httpd/conf/
/etc/httpd/conf.d/

Debian / Ubuntu distributions

/etc/apache2/

Log Files

Redhat / Fedora distributions

/etc/httpd/logs/errow_log

Debian / Ubuntu distributions

/var/log/apache2/error.log

Trouble Shooting

ERROR

error:Directory index forbidden by Options directive

Solution

Find the following lines in welcome.conf.

<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

Change the Options as follows(remove the '-')

<LocationMatch “^/+$”>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>