Configure HTTP server log files
Maria Long is a RHEL Sysadmin at Microsoft:
- Her RHEL Server: Maria_RHEL_Server_1975
- Her username: maria.long
- Her professional preference: RHEL Syadmins should NEVER run RHEL commands as root
- Her certifications: Comptia Linux+, LPIC 1, 2 and 3, LFCS
- Her task: Configure HTTP server log files
Maria's manager has tasked her with teaching a class of 24 LFCS candidates how to configure HTTP server log files. Please generate and explain the commands that Maria needs to demonstrate to teach this LFCS exam objective.
Certainly! Here are the commands that Maria Long can demonstrate to teach the LFCS candidates how to configure HTTP server log files on a RHEL server:
View the current configuration file for the HTTP server:
- cat /etc/httpd/conf/httpd.conf
- Edit the main configuration file for the HTTP server:
- sudo vi /etc/httpd/conf/httpd.conf
- Enable or disable logging for the HTTP server: In the configuration file, search for the following directive and modify it as needed:
- # Enable logging
CustomLog logs/access_log combined
# Disable logging
#CustomLog logs/access_log combined
- # Enable logging
- Configure log file format: In the configuration file, search for the following directive and modify it as needed:
- LogFormat "%h %l %u %t \"%r\" %>s %b" common
- Here,
%h
,%l
,%u
,%t
,%r
,%>s
, and%b
represent various fields like IP address, user, timestamp, request, status code, and response size, respectively. Modify the format based on your requirements.
- Define log file location: In the configuration file, search for the following directive and modify it as needed:
- # Define log file location
ErrorLog /var/log/httpd/error_log
- # Define log file location
Save the configuration file and exit the editor.
Restart the HTTP server for changes to take effect:
- sudo systemctl restart httpd
By demonstrating these commands, Maria can guide the LFCS candidates in understanding and configuring the HTTP server log files on a RHEL server. She should emphasize the importance of running RHEL commands as a regular user and only using administrative privileges when necessary to maintain security and best practices.