SElinux Howto
SElinux Howto
Copy all content of iso to a folder, here in below example it is mounted under /opt/rhel9 folder
total 48
[AppStream]
baseurl=file:///opt/rhel9/AppStream
enabled=1
gpgcheck=0
[BaseOS]
baseurl=file:///opt/rhel9/BaseOS
enabled=1
gpgcheck=0
IF repo is all set properly, you will be able to install httpd package, here it is already installed, for
you output will be different if installing for the first time
This system is not registered with an entitlement server. You can use subscription-manager to
register.
Last metadata expiration check: 23:43:03 ago on Monday 30 September 2024 12:39:58 PM.
Dependencies resolved.
Nothing to do.
Complete!
Docs: man:httpd.service(8)
====OMIT====
[root@localhost ~]#
Now check and set hostname of your system
localhost.localdomain
vm1.example.com
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
altname enp3s0
total 0
total 4
vm1.example.com
[root@vm1 ~]#
[root@vm1 ~]# ls
this is file 1
file1
anaconda-ks.cfg file1
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>
[root@vm1 ~]#
total 12
Permissive
this is file 2
Enforcing
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
</body></html>
[root@vm1 ~]#
total 12
[root@vm1 ~]#
total 8
this is file 2
[root@vm1 ~]#
IF some one does a relabel to system, with restorecon command context applied with chcon will
be remove, changed to original what is in policy.
[root@vm1 ~]#
Let’s Try to change Default Document Root of httpd from /var/www/html to /custom folder.
<html><head>
</head><body>
<h1>Not Found</h1>
</body></html>
Edit the Apache /etc/httpd/conf/httpd.conf configuration file, and replace the two occurrences of
the /var/www/html directory with the /custom directory. You can use the vim
/etc/httpd/conf/httpd.conf command to do so. (Edit file Carefully)
1.
DocumentRoot /var/www/html
change it to
DocumentRoot /custom
2.
<Directory “/var/www/html”>
change it to
<Directory “/custom”>
[root@vm1 ~]#
As We modified httpd server configuration file we need to restart httpd service to take new changes
into effect.
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
</body></html>
Enforcing
Permissive
[root@vm1 ~]#
Permissive
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
</body></html>
[root@vm1 ~]# ls -ldZ /custom/
Apply context as required by httpd service with chcon command to directory and file.
Enforcing
[root@vm1 ~]#
Thank you.