CenOS 9 - Lab 22.1
docx
keyboard_arrow_up
School
San Antonio College *
*We aren’t endorsed by this school
Course
2325
Subject
Information Systems
Date
Apr 3, 2024
Type
docx
Pages
6
Uploaded by BaronRiver11822
T
Lab 22.1 – Preparation Task
There are a couple of things you will need to do to ensure successful lab 22.1 completion.
1.
Run a package search to ensure you have httpd installed by typing:
rpm -qa | grep httpd
If the service is installed, you’ll see an onscreen output like the image below:
2.
If the service is not installed, type the following command in the command line:
Sudo dnf install httpd
3.
If the service is installed, type the following command in the command line to check the status of the httpd service:
systemctl status http
T
4.
Verify you have a /etc/httpd/web
folder exists by typing ls-l /etc/httpd/web
According to my output, as displayed in the above image, the web folder exists and is empty.
Lab 22.1 – Task 1
In Centos 9, change the Apache document root to /web. In this directory, create a file with the name index.html and give its contents to my web server. Restart the HTTP process and try to access the web server. This will not work. Fix the problem.
To change the Apache document root to /web
in CentOS 9, follow these steps:
1.
Edit the Apache configuration file:
sudo vim /etc/httpd/conf/httpd.conf
2.
Find the following line:
T
DocumentRoot /var/www/html
You can do that by typing /DocumentRoot while in command mode. This will trigger vim to search the document for your desired character string.
3.
Replace it with the following line:
DocumentRoot /web
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
T
3.
Enter command mode, then save and close the file.
4.
Restart the Apache service and check the status:
sudo systemctl restart httpd
T
5.
Create a file named index.html
in the /web
directory:
sudo vim /etc/httpd/web/index.html
6.
Edit the index.html
file and add the following contents:
HTML
<!DOCTYPE html
>
<
html
>
<
head
>
<
title
>Welcome to my web server!</
title
>
</
head
>
<
body
>
<
h1
>This is my web server!</
h1
>
</
body
>
</
html
>
7.
Save and close the file.
Now, try to access your web server in a web browser. You should see the message "This is my web server!".
If you don't see the message, it's possible that the SELinux security module is preventing Apache from accessing the /web
directory. To fix this, you need to modify the SELinux context for the /web
directory.
To do this, run the following command:
sudo semanage fcontext -a -t httpd_sys_content_t '/web(/.*)?'
T
Then, reload the SELinux configuration:
sudo restorecon -R /web
Now, try to access your web server in a web browser again. You should see the message "This is my web server!".
Note: If you are using a firewall, you may need to open port 80 to allow traffic to your web server.
Additional troubleshooting tips:
Make sure that the index.html
file is readable by the Apache user. To do this, run the following command:
sudo chmod 644 /web/index.html
Make sure that the Apache service is running. To check, run the following command:
sudo systemctl status httpd
If the service is not running, start it with the following command:
sudo systemctl start httpd
Try restarting your server.
If you are still having problems, please consult the Apache documentation for more help.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help