SYS‐255 Apache Installation and firewall‐cmd Configuration - aljimenez28/champlain GitHub Wiki
The purpose of this section of the lab was to install and configure the Apache web server on web01, allow web traffic through the firewall, replace the default Apache test page with a custom HTML page, and validate that the server is reachable from a workstation using a browser.
-
Install and start Apache (httpd)
-
Open HTTP and HTTPS services in firewalld
-
Verify web01 can serve webpages
-
Replace the default page with a custom index.html file
-
Install PHP and display a PHP test page
On web01, I installed Apache using dnf:
sudo dnf install httpd -y
Enabled and started the service:
sudo systemctl enable httpd
sudo systemctl start httpd
Verified Apache was running:
sudo systemctl status httpd
By default, firewalld blocks HTTP and HTTPS traffic. The following commands permanently opened those services:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
To verify the change, I ran:
sudo firewall-cmd --list-all
The expected output shows http and https under services.
From AD02, I opened a browser and entered the hostname or IP of web01:
http://web01-alejandra
or
http://10.0.5.10
The default Apache test page appeared, confirming that the web server was reachable.
This completed Deliverable 3.
Apache shows a default welcome page until the file below is removed:
sudo rm -f /etc/httpd/conf.d/welcome.conf
Created a custom web page:
sudo nano /var/www/html/index.html
Inserted:
<h1>Welcome to web01-alejandra</h1>
<p>Apache is successfully running.</p>
Refreshing the browser now displays the custom HTML page instead of the default Apache test page.
This completed Deliverable 4.
Installed PHP:
sudo dnf install php -y
sudo systemctl restart httpd
Created a PHP test file:
sudo nano /var/www/html/info.php
Inserted:
<?php
echo "<h1>This is Deliverable 5</h1>";
echo "<p>Hostname: " . gethostname() . "</p>";
phpinfo();
?>
Viewing:
http://web01-alejandra/info.php
The browser displayed both the custom output and detailed PHP configuration, proving the PHP module was active.
| Problem | Cause | Solution |
|---|---|---|
| Could not write index.html or info.php at first | File path was misspelled | Corrected the spelling of /var/www/html and saved again |
| Browser still showed default Apache page | welcome.conf was not deleted | Removed /etc/httpd/conf.d/welcome.conf and refreshed page |
| PHP file not served initially | Apache needed a restart after PHP install | Ran systemctl restart httpd |
sudo dnf install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo rm -f /etc/httpd/conf.d/welcome.conf
nano /var/www/html/index.html
sudo dnf install php -y
sudo systemctl restart httpd
nano /var/www/html/info.php
Apache is installed, configured, and serving custom content. Firewall rules were adjusted to allow HTTP and HTTPS traffic. PHP was installed and tested successfully. The workstation can reach the web server by hostname and IP.