RHCSA Practice Labs¶
These are a collection of labs that will cover essential RHCSA study points.
Doing these labs will be a great way to get hands-on with the tools we'll be using in the RHCSA exam.
Snapshots
It is highly recommended to take a snapshot of your VM before starting any of
these labs.
This will allow you to revert back to a clean state if you make a mistake.
Configuring Apache Webserver && SELinux Contexts¶
This lab will have us set up and configure an Apache web server on a non-standard port, use a non-standard directory for web site files, and configure SELinux to make the Apache config work, as well as allow remote access.
The lab scenario is as follows.
Scenario¶
Your company wants Apache configured with the following requirements:
- Apache must listen on TCP port
8081. - Website files must be stored under
/srv/rhcsa-web. -
The website must display:
-
/srv/rhcsa-web/uploadsmust be writable by Apache. - Remote clients must be able to access port
8081. - SELinux must remain enforcing.
- Everything must persist across a reboot.
Do not solve SELinux problems by:
- Disabling SELinux
- Leaving SELinux permissive
- Using
chconas the permanent solution - Generating a custom policy with
audit2allow
Use SELinux the correct way. Set contexts and booleans properly. This will help to gain a deeper understanding of Apache and SELinux (and will be expected on the RHCSA exam).
It's highly recommended to attempt the lab before looking at the solution.
Solution Part 1: Setting up Apache
-
Ensure the necessary packages are installed.
-
Create the custom document root.
-
Create the web page that will be served.
Add the following text to that file.
-
Set the ordinary Linux permissions on the file.
-
Create the Apache configuration file.
The config file should be as follows.
-
Check the syntax of the Apache webserver config.
Look for
Syntax OK.
Now Apache is set up to serve the custom document root on port 8081.
The next steps will require setting SELinux contexts on the new document
root directory, enabling a specific SELinux boolean, and allowing access
through Firewalld.