Simple Web Server and Page CentOS - Hsanokklis/2023-2024-Tech-journal GitHub Wiki
We are using
rockyfor this labHTML Color codes: https://www.html-color-codes.info/color-names/
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


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 httpdLet's check the current Apache status:systemctl status httpd

Testing your server
-
On the web server, let's curl it:
curl http://Your_IP_Here | grep "Test Page"\ -
Start your Kali VM
-
Open a web browser
-
Navigate to URL "http://Your_IP_Here"Links to an external site.


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!



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.htmlwith 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>

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

Personalizing Your Page
Resource: https://www.w3schools.com/html/
