Simple Web Server and Page CentOS - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

Lab Specifications

We are using rocky for this lab

HTML Color codes: https://www.html-color-codes.info/color-names/

HTTPD on CentOS

Check for Connection

Type ip addr to see if you have an IP - write down IP for later. ping -c1 google.com for good measure.

  • IP address: 10.0.17.23/24

image

image

Set-up Apache/HTTPD

  • Install Apache/httpd with: yum install -y httpd
  • You need to allow http through the firewall: firewall-cmd --permanent --add-port=80/tcp
  • Reload firewall config: firewall-cmd --reload
  • Verify that firewall is open: firewall-cmd --query-port=80/tcp (should report "yes")
  • Start the httpd service: systemctl start httpd Let's check the current Apache status: systemctl status httpd

image

Testing your server

Deliverable-1: Submit Screen Capture of curl's command's output

image

Deliverable-2: Submit screen capture of Apache Test Page

image

Basic HTML Page

  • Go to "/var/www/html" as root in Rocky

This is the default root directory of the web server, which you will use frequently!

  • Use vi to create a file called index.html. Also once done, you'll need save the file before anything html can be seen!

image

Deliverable-3: Screenshot of a browser rendering your web page

image

image

all the elements are in a marquee tag, so they move across the screen in different directions

Adding PHP

  • Install PHP with: yum install php php-common php-cli php-curl
  • Test PHP: php -v
  • Restart httpd: systemctl restart httpd
  • Testing httpd: systemctl status httpd
  • Edit index.html with the following content:
<?php

     echo("<p>Some server side code here</p> <br>"); 
    // Variables start with $
    $var1 = "Your Name";
    $var2 = "First Page";

?>

<html>
 <head>
   <title>
       <?php  echo $var2;  ?>
   </title>
 </head>
 <body>
   First Page of <?php echo $var1;  ?>
 </body>
</html>

image

  • Changing the extension: mv index.html index.php

Deliverable-4: Screenshot of a browser rendering your web page with PHP added

image

Personalizing Your Page

Resource: https://www.w3schools.com/html/

Deliverable-5: Screenshot of a browser rendering your personalized web page

image

⚠️ **GitHub.com Fallback** ⚠️