Apache
Jump to navigation
Jump to search
What is Apache? ⌘
- Mature, stable HTTP server
- Many, many features
- Many, many modules available
Installing ⌘
- Included in the standard EL5 repos
- `yum -y install httpd`
Changing the configuration ⌘
- Main configuration file at `/etc/httpd/conf/httpd.conf`
- Syntax check with `service httpd configtest`
- Re-read config with `service httpd reload`
- Some actions (eg adding SSL certs) require a full restart
`service httpd restart`
Virtualhosts ⌘
- Create a file /etc/httpd/conf.d/vhost.conf
``` <VirtualHost *:80> ServerName localhost DocumentRoot /var/www/html CustomLog /var/log/httpd/localhost-access.log combined ErrorLog /var/log/httpd/localhost-error.log </VirtualHost> ```
Adding altername names to a vhost ⌘
- Alternate names can be added via the ServerAlias parameter
- Multiple names can be specified, separated by a space
Default VirtualHost ⌘
- The default virtualhost is the one that is the first alphabetically
- This will be used even if the ServerName/ServerAlias doesn't match if you remove welcome.conf
IP based virtual hosts ⌘
- What we just created was a name based VirtualHost
- We can also create address based VirtualHosts
- These are commonly used with SSL
``` NameVirtualHost 192.168.34.1:80 <VirtualHost 192.168.34.1:80> DocumentRoot /var/www/html CustomLog /var/log/httpd/localhost-access.log combined ErrorLog /var/log/httpd/localhost-error.log </VirtualHost> ```
Exercise ⌘
- There is some content under /var/www/exercise
- Create a virtualhost which will serve this only in response to a request for localhost.localdomain
- `$ curl http://localhost.localdomain/`