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

Linux Copy

The document outlines the steps to install and configure the Apache Web Server on a Linux system, including updating the package list, installing Apache, starting the service, and testing the installation. It also discusses the purpose of the httpd.conf file, how to set up a virtual host, and compares Apache and Nginx web servers in terms of architecture, performance, and best use cases. Additionally, it details the process of enabling and starting the web server service, checking its status, and configuring firewall settings for HTTP and HTTPS traffic using ufw and iptables.
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)
7 views11 pages

Linux Copy

The document outlines the steps to install and configure the Apache Web Server on a Linux system, including updating the package list, installing Apache, starting the service, and testing the installation. It also discusses the purpose of the httpd.conf file, how to set up a virtual host, and compares Apache and Nginx web servers in terms of architecture, performance, and best use cases. Additionally, it details the process of enabling and starting the web server service, checking its status, and configuring firewall settings for HTTP and HTTPS traffic using ufw and iptables.
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

LA GRANDEE INTERNATIONAL COLLEGE

Simalchaur, Pokhara Nepal

Assignment-4
On
Course: Linux

Submitted By: Submitted To:


Student Name: Prabhat Raj Poudel Mr. Ranjan Regmi

Roll Number: 20 (Department Of BCA)

Semester: VII

Signature

Submission Date: December 4, 2024


1.Explain the steps to install and configure Apache Web Server on a
Linux system. What are the directories for configuration and
website files?
Steps:

a. Update the Package List:


Command: sudo apt update
Output:

b. Install Apache
Command: sudo apt install apache2
Output:
c. Start the Apache service
Command: sudo systemctl start apache2

d. Sudo systemctl enable apache2


Command: sudo systemctl enable apache2
Output:

e. Test the Installation:


Open a browser and visit http://<your-server-ip>.
Output:
2. What is the Purpose of the httpd.conf file in an Apache web server?
Explain how to modify it to set up a virtual host.
Purpose of httpd.conf:
 The httpd.conf file contains global settings for the Apache server, such as:
o Server-wide configuration (e.g., ports to listen on).
o Directory permissions and access control.
o Enabling or disabling modules.
o Logging configuration.

Setting up a virtual host:


a.Create a Virtual Host File:
Command: sudo nano /etc/apache2/sites-available/example.com.conf

Example configuration

b. Enable the Virtual Host:


Command: sudo a2ensite example.com.conf

c. Reload Apache to apply the changes:


Command: sudo systemctl reload apache2
d. Test Configuration:
Command: sudo apachectl configtest

e.Edit the hosts File for Testing Locally


Command: sudo nano /etc/hosts
Add the following line:
127.0.0.1 example.com www.example.com
Access the Website
Open the browser and got to http://example.com
3. Compare and contrast the use of Apache and Nginx as Web servers
in Linux. What are the primary advantages of using one over the
other?
Feature Apache Nginx
Event-driven, handles
Process-based (each request
Architecture multiple requests in a single
spawns a new process/thread).
thread.
Handles dynamic content better Faster for serving static files
Performance
(e.g., PHP integration). and reverse proxy setups.
Slower compared to Nginx for Optimized for static content
Static Content
static files. delivery.
Relies on a separate backend
Dynamic Directly integrates with backend
(e.g., FastCGI) for dynamic
Content languages like PHP via mod_php.
content.
Supports .htaccess for per- Centralized configuration;
Configuration
directory overrides. does not support .htaccess.
Advanced load balancing
Load Balancing Basic load balancing capabilities.
features with health checks.
Highly optimized for reverse
Proxy Features Good, but slower than Nginx.
proxy and caching.
Less scalable due to process- Highly scalable for large
Scalability
based model. traffic sites.
Rich documentation and Extensive documentation,
Documentation
community support. growing community.
Higher due to spawning multiple
Memory Usage Lower memory footprint.
processes.
Best Use Case Suitable for smaller websites or Best for high-traffic websites
those with complex dynamic or static content.
Feature Apache Nginx
requirements.

Use Apache if:


 You need .htaccess for easy per-directory configuration.
 You have a lot of dynamic content (e.g., WordPress sites).
Use Nginx if:
 Your site is static or requires high-speed reverse proxying.
 You expect very high traffic and need scalability.
4. Describe the process of enabling and starting a web server service
in Linux using system. Include the commands for checking service
status.
Commands:
a. Enable Apache Service: Ensures Apache starts on boot
sudo systemctl enable apache2

b. Start Apache: Start the Apache service:


sudo systemctl start apache2

c. Check Service Status: Check if Apache is running:


sudo systemctl status apache2
5. After installing a web server, what are the necessary firewall
configurations to ensure it is accessible from the internet? Provide an
example of how to use ufw or iptables to allow HTTP and HTTPS
traffic.
Using ufw (Uncomplicated Firewall):
a. Allow HTTP and HTTPS traffic:
Command: sudo ufw allow 'Apache Full'

b. Enable the firewall:


sudo ufw enable

c. Check the status of the firewall:


sudo ufw status
Using iptables:

a. Allow HTTP (port 80):


Command: sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT

b. Allow HTTPS (port 443):


Command: sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT

c. Save the Firewall Rules: To ensure the rules persist after a


reboot:
Command: sudo apt install iptables-persistent -y
Command: sudo netfilter-persistent save

You might also like