- Subtitle: A Beginner's Guide
- Presented by: [Talha Jilal]
- Date: [2024/05/16]
-
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.
Step 1: Update Package Repository
sudo yum update Step 2: Install Apache
sudo yum install httpdCentOS/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.
- 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 - What are Virtual Hosts?
- Allow running multiple websites on a single server.
- Basic Virtual Host Configuration
sudo vi /etc/httpd/conf.d/vhost.confExample 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>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 --reloadEnable HTTPS
Install mod_ssl: sudo yum install mod_ssl (CentOS/RHEL) Obtain SSL certificates: Use Let's Encrypt or another CA.