Skip to content

Latest commit

 

History

History
118 lines (80 loc) · 2.53 KB

File metadata and controls

118 lines (80 loc) · 2.53 KB

Title: Introduction to Apache Server Configuration on Linux

  • Subtitle: A Beginner's Guide
  • Presented by: [Talha Jilal]
  • Date: [2024/05/16]

Table of Contents

Introduction to Apache

  • What is Apache?

    • Open-source HTTP server for modern operating systems.
    • Supports various features including loadable modules, SSL/TLS, and URL redirection.
  • Why Use Apache?

    • Widely used and reliable.
    • Highly customizable and extendable.
    • Strong community support and documentation.

Installation on Linux

Step 1: Update Package Repository

sudo yum update 

Step 2: Install Apache

sudo yum install httpd

Basic Configuration

CentOS/RHEL: /etc/httpd/conf/httpd.conf

sudo vi /etc/httpd/conf/httpd.conf  

Common Directives

ServerAdmin: Admin email address. DocumentRoot: Directory where web files are stored. ServerName: Server's domain name.

Mnaging Apache Service

  • Start/Stop Apache and Enable Apache to start on Boot.
sudo systemctl start httpd
sudo systemctl restart httpd
sudo systemctl stop httpd
sudo systemctl enable httpd   

Virtual Hosts

  • What are Virtual Hosts?
    • Allow running multiple websites on a single server.
  • Basic Virtual Host Configuration
sudo vi /etc/httpd/conf.d/vhost.conf

Example Configuration

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    DocumentRoot /var/www/mydomain
    ServerName www.mydomain.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Security Best Practices

Disable directory listing, when someone access your website so they can't review your Liux Directory structure of /var/www/html

sudo vi /etc/httpd/conf.d/vhost.conf
Options -Indexes
Escape wq! ( Save file )

Enable firewall so server can be accessible,

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Enable HTTPS

Install mod_ssl: sudo yum install mod_ssl (CentOS/RHEL) Obtain SSL certificates: Use Let's Encrypt or another CA.