0% found this document useful (0 votes)
21 views11 pages

University of Engineering & Technology, Taxila

This report outlines the installation and configuration of an Apache web server on CentOS, including system updates, Apache installation, and firewall configuration. It details the setup of IP-based and port-based websites with specific virtual host entries and document root directories. Additionally, it provides troubleshooting tips and security best practices for maintaining the web server environment.

Uploaded by

Usman Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views11 pages

University of Engineering & Technology, Taxila

This report outlines the installation and configuration of an Apache web server on CentOS, including system updates, Apache installation, and firewall configuration. It details the setup of IP-based and port-based websites with specific virtual host entries and document root directories. Additionally, it provides troubleshooting tips and security best practices for maintaining the web server environment.

Uploaded by

Usman Abdullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

University of Engineering &

Technology, Taxila

Faculty of Telecommunication & Information Engineering


B.Sc. Computer Engineering

Lab No. 3

System Programming
(CP-410)

Name: Muhammad Usman


Roll No: 21-CP-21
Semester: 8th (21CP)
Sec: Alpha
LAB Report No. 03
System Programming (CP-410)
Web Server Installation

Report on Web Server Installation and Configuration on CentOS 1.


Introduction
This report details the installation and configuration of an Apache web server on CentOS,
including firewall settings and the setup of IP-based and port-based websites. The document also
includes troubleshooting tips and security best practices for maintaining a robust web hosting
environment.

2. Web Server Installation

2.1 Update System and Install Apache


Run the following commands to update the system and install Apache:
sudo yum update -y sudo
yum install httpd -y
2.2 Enable and Start Apache
Enable Apache to start on boot and launch the service:
sudo systemctl enable httpd sudo
systemctl start httpd
2.3 Verify Apache Installation To

confirm Apache is running, use:

sudo systemctl status httpd


To test, open a browser and enter the server's IP address:
http://your-server-ip

If Apache is correctly installed, the default CentOS test page should appear.

3. Configure Firewall for Web Server


To allow HTTP and HTTPS traffic through the firewall, execute:
sudo firewall-cmd --permanent --add-service=http sudo
firewall-cmd --permanent --add-service=https sudo
firewall-cmd --permanent --add-port=2000/tcp sudo
firewall-cmd --reload

To verify the firewall rules:


sudo firewall-cmd --list-all

4. IP-Based Website Configuration

4.1 Configure Virtual Hosts


Edit the Apache configuration file:
sudo nano /etc/httpd/conf.d/httpd-vhosts.conf

Add the following Virtual Host entry for an IP-based website:


<VirtualHost 192.168.15.128:80>
DocumentRoot "/var/www/html/site1"
ServerName 192.168.15.128 <Directory "/var/www/html/site1">
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/site1_error.log"
CustomLog "/var/log/httpd/site1_access.log" combined </VirtualHost>

Create the document root directory and an index page:


sudo mkdir /var/www/html/index.html sudo
vi /var/www/html/index.html
So in index file I create simple webpage
5. Port-Based Website Configuration
5.1 Create a New Virtual Host for Port-Based Access
Edit the Apache configuration file:
sudo nano /etc/httpd/conf.d/httpd-vhosts.conf

Add the following Virtual Host entry:

For port 80:


<VirtualHost *:80>
DocumentRoot "/var/www/html/site1"
<Directory "/var/www/html/site1”
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/site1_error.log"
CustomLog "/var/log/httpd/site1_access.log" combined </VirtualHost>

For port 8080:


<VirtualHost *:8080>
DocumentRoot "/var/www/html/site2"
<Directory "/var/www/html/site2”
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/site2_error.log"
CustomLog "/var/log/httpd/site2_access.log" combined </VirtualHost>

For port 9090:


<VirtualHost *:9090>
DocumentRoot "/var/www/html/site3"
<Directory "/var/www/html/site3”
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/site3_error.log"
CustomLog "/var/log/httpd/site3_access.log" combined </VirtualHost>

Create the document root and index pages for all three sites
sudo mkdir -p /var/www/html/site1 sudo
vi /var/www/html/site1/index.html
sudo mkdir -p /var/www/html/site2 sudo
vi /var/www/html/site2/index.html
sudo mkdir -p /var/www/html/site3 sudo
vi /var/www/html/site3/index.html

In index.html write this content we create simple three different pages as seen below

On Port localhost:80
On Port localhost:8080
On Port localhost:9090

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy