Apache: Difference between revisions
(Initial draft) |
(Added NoIndex tag and depreciated note) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOINDEX__ | |||
'''This page is now depreciated - please see new [[:Category:Apache|Apache]] pages''' | |||
= Configuration = | |||
== Log Rotation == | |||
| <code> / | There are two ways to ensure your logs get rotated... | ||
* logrotate - The standard, cross application log rotation solution. Its very reliable and easy to configure, but requires that Apache is restarted every time your log is rotated so that it follows the log switch around. | |||
* rotatelog pipe - Has more overhead as logs are piped to a child process to handle, but doesn't require Apache restarts. | |||
=== rotatelog === | |||
Edit you existing config file to redirect logging through the child rotatelogs process, this will probably be found in either your site config (EG in <code>/etc/apache2/sites-enabled</code>) or your Apache service config (EG in <code> /etc/apache2/ </code>) | |||
ErrorLog "|/usr/sbin/rotatelogs /var/log/apache2/error-%Y-%m-%d.log 86400" | |||
CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/access-%Y-%m-%d.log 86400" combined | |||
Check that the path for <code>rotatelogs</code> is correct (search using <code> find / -iname rotatelogs </code>) | |||
Restart Apache, perform a test page load on your site (that would generate log entries), and check that a log file has been generated as per your config | |||
== User/pass restrictions == | == User/pass restrictions == | ||
Line 20: | Line 31: | ||
# Restart the apache service | # Restart the apache service | ||
#* <code> service apache2 restart </code> | #* <code> service apache2 restart </code> | ||
= Troubleshooting = | |||
== NameVirtualHost *:80 has no VirtualHosts == | |||
On restarting Apache you get presented with the following warning | |||
[Thu Jan 12 10:58:20 2012] [warn] NameVirtualHost *:80 has no VirtualHosts | |||
This is generally caused by duplicate <code>NameVirtualHost</code> entries in your config. | |||
Perform the following in <code>/etc/apache2</code> folder to identify where the entries and delete the unwanted duplicates.. | |||
grep NameVir * -R |
Latest revision as of 10:48, 9 February 2012
This page is now depreciated - please see new Apache pages
Configuration
Log Rotation
There are two ways to ensure your logs get rotated...
- logrotate - The standard, cross application log rotation solution. Its very reliable and easy to configure, but requires that Apache is restarted every time your log is rotated so that it follows the log switch around.
- rotatelog pipe - Has more overhead as logs are piped to a child process to handle, but doesn't require Apache restarts.
rotatelog
Edit you existing config file to redirect logging through the child rotatelogs process, this will probably be found in either your site config (EG in /etc/apache2/sites-enabled
) or your Apache service config (EG in /etc/apache2/
)
ErrorLog "|/usr/sbin/rotatelogs /var/log/apache2/error-%Y-%m-%d.log 86400" CustomLog "|/usr/sbin/rotatelogs /var/log/apache2/access-%Y-%m-%d.log 86400" combined
Check that the path for rotatelogs
is correct (search using find / -iname rotatelogs
)
Restart Apache, perform a test page load on your site (that would generate log entries), and check that a log file has been generated as per your config
User/pass restrictions
- Create a user/pass entry in a file for a username
htpasswd -c /usr/local/apache2/conf/htusers username
- Add the relavent bits to the
/etc/apache2/httpd.conf
file, eg<Directory />
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /usr/local/apache2/conf/htusers
Require valid-user
</Directory>
- Restart the apache service
service apache2 restart
Troubleshooting
NameVirtualHost *:80 has no VirtualHosts
On restarting Apache you get presented with the following warning
[Thu Jan 12 10:58:20 2012] [warn] NameVirtualHost *:80 has no VirtualHosts
This is generally caused by duplicate NameVirtualHost
entries in your config.
Perform the following in /etc/apache2
folder to identify where the entries and delete the unwanted duplicates..
grep NameVir * -R