Apache is a Web Server that's been around since the early days of internet. It can also be used as a Web Proxy, and is highly configurable and customizable, but is sometimes seen as a bit sluggish. Alternatives to Apache (for Linux) is nginx and lighttpd. They all have their own specific merits, but as this is an article on LAMP, we'll focus on Apache!
[root@centos66 ~]# yum install httpd mod_ssl
[root@centos66 ~]# cd /etc/httpd/conf.d
[root@centos66 conf.d]# rm welcome.conf README
You can read the README file before deleting it though, but make sure that you remove it from the conf.d directory afterwards, as this directory only should hold Apache configuration files.
The default configuration make Apache listen on all interfaces on port 80 (HTTP) and 443 (HTTPS), I usually want to control this per-host (see next section), and not use global settings, so you should turn off the default listeners. Edit the files listed below:
- In /etc/httpd/conf/httpd.conf - Find the line which reads "Listen 80" and change it to "#Listen 80". The #-sign is used to comment out the line.
- In /etc/httpd/conf.d/ssl.conf - Find the line which reads "Listen 443" and change it to "#Listen 443".
About Virtual Hosts
The core idea of Virtual Hosts is that you can use your resources (read: IP-addresses) in a better way. For instance, you can have several domain names pointing to the same IP-address, but still showing different web sites. Or you can set up multiple web sites on a single IP-address, but on different ports. This can be useful if IP-addresses is a sparse resource.
Some web servers can have a mix of public and private network interfaces, where you want to expose different content to the interfaces. For instance, the company Main Website and the Reseller Portal is made available to a public network interface, whereas the company Back Office website is only published on the company intranet (and thus only on a private network interface).
Using virtual host configurations, you can hold both public and private web applications on the same physical server, and at the same time control which sites should be exposed to internet, and which should be available only locally.
About HTTPS and SSL/TLS
Unfortunately, getting HTTPS to work is not trivial, and it can also be rather costly (you will need to purchase one or several certificates from a "CA"). Moreover, you need to configure Apache not to use non-modern encryption protocols, and there are also issues regarding using Virtual Hosts when you apply HTTPS.
This guide will only present a "non-secure" setup, not using HTTPS. Nonetheless, I do recommend you to install mod_ssl so that you have support for HTTPS, once you wish to start using it. And I hope to write a blog post on configuration and quirks using HTTPS in Apache, rather soon!
About Web Application Installation Paths
During this article, I will use "/var/www" as the root directory of applications (dogs and their old tricks, y'know), and I will refer to the installed application as the "demoapp".