0% found this document useful (0 votes)
4 views9 pages

Labno 03

This report outlines the process for installing and configuring an Apache web server on CentOS, including system updates, Apache installation, and firewall configuration. It details the setup for both IP-based and port-based websites, including virtual host configurations and document root creation. Additionally, the report provides troubleshooting tips and security best practices for maintaining a secure web hosting environment.

Uploaded by

Hafsa Rafique
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)
4 views9 pages

Labno 03

This report outlines the process for installing and configuring an Apache web server on CentOS, including system updates, Apache installation, and firewall configuration. It details the setup for both IP-based and port-based websites, including virtual host configurations and document root creation. Additionally, the report provides troubleshooting tips and security best practices for maintaining a secure web hosting environment.

Uploaded by

Hafsa Rafique
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/ 9

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/httpd.conf


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

<VirtualHost 192.168.94.131:80>
DocumentRoot "/var/www/html/ip_based"
ServerName 192.168.94.131
<Directory "/var/www/html/ip_based">
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/ip_based_error.log"
CustomLog "/var/log/httpd/ip_based_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

and write following paragraph

Hamna Amir, a dedicated student with the roll number 21-cp-10, has always strived for excellence in
her academic journey. Known for her sharp problem-solving skills and creative approach, she has
consistently demonstrated a passion for learning and growing. Whether tackling complex assignments
or engaging in group discussions, Hamna is committed to achieving her goals and making a positive
impact in her field of study.
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/httpd.conf

Add the following Virtual Host entry:

<VirtualHost 192.168.94.131:2000>
DocumentRoot "/var/www/html/port_based"
<Directory "/var/www/html/port_based">
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/port_based_error.log"
CustomLog "/var/log/httpd/port_based_access.log" combined
</VirtualHost>
Create the document root and index page:

sudo mkdir -p /var/www/html/site1


sudo vi /var/www/html/site1/index.html
In index.html write this content

Set silinux =disabled and save it by :wq so that port based web hosting is enabled
Restart Apache:

sudo systemctl restart httpd

You might also like