<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://serverrental.store/index.php?action=history&amp;feed=atom&amp;title=Installing_Apache_Web_Server</id>
	<title>Installing Apache Web Server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://serverrental.store/index.php?action=history&amp;feed=atom&amp;title=Installing_Apache_Web_Server"/>
	<link rel="alternate" type="text/html" href="https://serverrental.store/index.php?title=Installing_Apache_Web_Server&amp;action=history"/>
	<updated>2026-04-15T12:42:33Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://serverrental.store/index.php?title=Installing_Apache_Web_Server&amp;diff=5732&amp;oldid=prev</id>
		<title>Admin: New server guide</title>
		<link rel="alternate" type="text/html" href="https://serverrental.store/index.php?title=Installing_Apache_Web_Server&amp;diff=5732&amp;oldid=prev"/>
		<updated>2026-04-12T15:56:05Z</updated>

		<summary type="html">&lt;p&gt;New server guide&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Installing Apache Web Server =&lt;br /&gt;
&lt;br /&gt;
This guide provides a comprehensive walkthrough for installing and configuring the Apache HTTP Server (httpd) on a Linux system. We will cover basic installation, setting up virtual hosts for multiple websites, enabling URL rewriting with `mod_rewrite`, and securing your server with SSL/TLS certificates. This tutorial is suitable for beginners to intermediate Linux system administrators.&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
Before you begin, ensure you have the following:&lt;br /&gt;
&lt;br /&gt;
*   A Linux server with root or sudo privileges. Dedicated servers from [https://powervps.net/?from=32 PowerVPS] offer the full root access needed for these operations.&lt;br /&gt;
*   Internet connectivity to download packages.&lt;br /&gt;
*   Basic understanding of the Linux command line.&lt;br /&gt;
*   (Optional) A domain name pointing to your server's IP address.&lt;br /&gt;
&lt;br /&gt;
== Step 1: Installing Apache HTTP Server ==&lt;br /&gt;
&lt;br /&gt;
The installation process varies slightly depending on your Linux distribution.&lt;br /&gt;
&lt;br /&gt;
=== For Debian/Ubuntu-based systems ===&lt;br /&gt;
&lt;br /&gt;
Use the Advanced Package Tool (APT) to install Apache:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt update&lt;br /&gt;
sudo apt install apache2 -y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== For RHEL/CentOS/Fedora-based systems ===&lt;br /&gt;
&lt;br /&gt;
Use the YUM or DNF package manager:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo yum update -y&lt;br /&gt;
sudo yum install httpd -y&lt;br /&gt;
# Or for newer Fedora/RHEL versions:&lt;br /&gt;
# sudo dnf update -y&lt;br /&gt;
# sudo dnf install httpd -y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installation, start and enable the Apache service to run on boot:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# For Debian/Ubuntu&lt;br /&gt;
sudo systemctl start apache2&lt;br /&gt;
sudo systemctl enable apache2&lt;br /&gt;
&lt;br /&gt;
# For RHEL/CentOS/Fedora&lt;br /&gt;
sudo systemctl start httpd&lt;br /&gt;
sudo systemctl enable httpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verify the status of the Apache service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# For Debian/Ubuntu&lt;br /&gt;
sudo systemctl status apache2&lt;br /&gt;
&lt;br /&gt;
# For RHEL/CentOS/Fedora&lt;br /&gt;
sudo systemctl status httpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see output indicating the service is &amp;quot;active (running)&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
If you have a firewall enabled (e.g., `ufw` or `firewalld`), you need to allow HTTP and HTTPS traffic.&lt;br /&gt;
&lt;br /&gt;
==== Using UFW (Debian/Ubuntu) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo ufw allow 'Apache Full'&lt;br /&gt;
sudo ufw enable&lt;br /&gt;
sudo ufw status&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Using Firewalld (RHEL/CentOS/Fedora) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo firewall-cmd --permanent --add-service=http&lt;br /&gt;
sudo firewall-cmd --permanent --add-service=https&lt;br /&gt;
sudo firewall-cmd --reload&lt;br /&gt;
sudo firewall-cmd --list-all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open your web browser and navigate to your server's IP address (e.g., `http://your_server_ip`). You should see the default Apache welcome page.&lt;br /&gt;
&lt;br /&gt;
== Step 2: Configuring Virtual Hosts ==&lt;br /&gt;
&lt;br /&gt;
Virtual hosts allow you to host multiple websites on a single server. Each website will have its own configuration file.&lt;br /&gt;
&lt;br /&gt;
=== Create Directory Structure ===&lt;br /&gt;
&lt;br /&gt;
For each website, create a dedicated directory for its files. It's common practice to place these in `/var/www/`.&lt;br /&gt;
&lt;br /&gt;
Let's assume you want to host `example.com` and `blog.example.com`.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo mkdir -p /var/www/example.com/public_html&lt;br /&gt;
sudo mkdir -p /var/www/blog.example.com/public_html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Set Permissions ===&lt;br /&gt;
&lt;br /&gt;
Ensure Apache has the necessary permissions to access these directories.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo chown -R $USER:$USER /var/www/example.com/public_html&lt;br /&gt;
sudo chown -R $USER:$USER /var/www/blog.example.com/public_html&lt;br /&gt;
sudo chmod -R 755 /var/www/&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a sample `index.html` file for each site:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;&amp;lt;h1&amp;gt;Welcome to example.com!&amp;lt;/h1&amp;gt;&amp;quot; | sudo tee /var/www/example.com/public_html/index.html&lt;br /&gt;
echo &amp;quot;&amp;lt;h1&amp;gt;Welcome to blog.example.com!&amp;lt;/h1&amp;gt;&amp;quot; | sudo tee /var/www/blog.example.com/public_html/index.html&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create Virtual Host Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
Apache's virtual host configurations are typically stored in `/etc/apache2/sites-available/` (Debian/Ubuntu) or `/etc/httpd/conf.d/` (RHEL/CentOS/Fedora).&lt;br /&gt;
&lt;br /&gt;
==== For Debian/Ubuntu ====&lt;br /&gt;
&lt;br /&gt;
Create a new configuration file for `example.com`:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo nano /etc/apache2/sites-available/example.com.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the following content, replacing `example.com` with your domain and `your_server_ip` with your server's IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;VirtualHost *:80&amp;amp;gt;&lt;br /&gt;
    ServerAdmin webmaster@example.com&lt;br /&gt;
    ServerName example.com&lt;br /&gt;
    ServerAlias www.example.com&lt;br /&gt;
    DocumentRoot /var/www/example.com/public_html&lt;br /&gt;
    ErrorLog ${APACHE_LOG_DIR}/example.com_error.log&lt;br /&gt;
    CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined&lt;br /&gt;
&amp;amp;lt;/VirtualHost&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a similar file for `blog.example.com`:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo nano /etc/apache2/sites-available/blog.example.com.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the following content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;VirtualHost *:80&amp;amp;gt;&lt;br /&gt;
    ServerAdmin webmaster@blog.example.com&lt;br /&gt;
    ServerName blog.example.com&lt;br /&gt;
    DocumentRoot /var/www/blog.example.com/public_html&lt;br /&gt;
    ErrorLog ${APACHE_LOG_DIR}/blog.example.com_error.log&lt;br /&gt;
    CustomLog ${APACHE_LOG_DIR}/blog.example.com_access.log combined&lt;br /&gt;
&amp;amp;lt;/VirtualHost&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable the new virtual host configurations and disable the default one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2ensite example.com.conf&lt;br /&gt;
sudo a2ensite blog.example.com.conf&lt;br /&gt;
sudo a2dissite 000-default.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== For RHEL/CentOS/Fedora ====&lt;br /&gt;
&lt;br /&gt;
Create a new configuration file for `example.com` in the `conf.d` directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo nano /etc/httpd/conf.d/example.com.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the following content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;VirtualHost *:80&amp;amp;gt;&lt;br /&gt;
    ServerAdmin webmaster@example.com&lt;br /&gt;
    ServerName example.com&lt;br /&gt;
    ServerAlias www.example.com&lt;br /&gt;
    DocumentRoot /var/www/example.com/public_html&lt;br /&gt;
    ErrorLog /var/log/httpd/example.com_error.log&lt;br /&gt;
    CustomLog /var/log/httpd/example.com_access.log combined&lt;br /&gt;
&amp;amp;lt;/VirtualHost&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a similar file for `blog.example.com`:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo nano /etc/httpd/conf.d/blog.example.com.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the following content:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;VirtualHost *:80&amp;amp;gt;&lt;br /&gt;
    ServerAdmin webmaster@blog.example.com&lt;br /&gt;
    ServerName blog.example.com&lt;br /&gt;
    DocumentRoot /var/www/blog.example.com/public_html&lt;br /&gt;
    ErrorLog /var/log/httpd/blog.example.com_error.log&lt;br /&gt;
    CustomLog /var/log/httpd/blog.example.com_access.log combined&lt;br /&gt;
&amp;amp;lt;/VirtualHost&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test and Reload Apache ===&lt;br /&gt;
&lt;br /&gt;
Before applying the changes, test your Apache configuration for syntax errors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# For Debian/Ubuntu&lt;br /&gt;
sudo apache2ctl configtest&lt;br /&gt;
&lt;br /&gt;
# For RHEL/CentOS/Fedora&lt;br /&gt;
sudo httpd -t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the syntax is OK, reload Apache to apply the new virtual hosts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# For Debian/Ubuntu&lt;br /&gt;
sudo systemctl reload apache2&lt;br /&gt;
&lt;br /&gt;
# For RHEL/CentOS/Fedora&lt;br /&gt;
sudo systemctl reload httpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, if you have your DNS records set up correctly, `example.com` and `blog.example.com` should point to their respective content.&lt;br /&gt;
&lt;br /&gt;
== Step 3: Enabling mod_rewrite ==&lt;br /&gt;
&lt;br /&gt;
The `mod_rewrite` module allows for powerful URL manipulation, often used for SEO-friendly URLs or redirecting traffic.&lt;br /&gt;
&lt;br /&gt;
=== Enable the Module ===&lt;br /&gt;
&lt;br /&gt;
==== For Debian/Ubuntu ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo a2enmod rewrite&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== For RHEL/CentOS/Fedora ====&lt;br /&gt;
&lt;br /&gt;
`mod_rewrite` is usually enabled by default. If not, you might need to uncomment a `LoadModule rewrite_module modules/mod_rewrite.so` line in your main Apache configuration file (e.g., `/etc/httpd/conf/httpd.conf`). After enabling, reload Apache:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl reload httpd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configure .htaccess ===&lt;br /&gt;
&lt;br /&gt;
To use `mod_rewrite` rules, you need to allow `.htaccess` files to override server configurations. Edit your virtual host configuration files and add `AllowOverride All` within the `&amp;lt;Directory&amp;gt;` block for your `public_html` directories.&lt;br /&gt;
&lt;br /&gt;
For `example.com.conf` (Debian/Ubuntu):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;Directory /var/www/example.com/public_html&amp;amp;gt;&lt;br /&gt;
    Options Indexes FollowSymLinks&lt;br /&gt;
    AllowOverride All&lt;br /&gt;
    Require all granted&lt;br /&gt;
&amp;amp;lt;/Directory&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For `example.com.conf` (RHEL/CentOS/Fedora):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;Directory &amp;quot;/var/www/example.com/public_html&amp;quot;&amp;amp;gt;&lt;br /&gt;
    Options Indexes FollowSymLinks&lt;br /&gt;
    AllowOverride All&lt;br /&gt;
    Require all granted&lt;br /&gt;
&amp;amp;lt;/Directory&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Repeat this for `blog.example.com`. After making changes, test and reload Apache.&lt;br /&gt;
&lt;br /&gt;
=== Example .htaccess Rule ===&lt;br /&gt;
&lt;br /&gt;
Create a `.htaccess` file in your `public_html` directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo &amp;quot;RewriteEngine On&lt;br /&gt;
RewriteRule ^new-page$ /old-page.html [R=301,L]&amp;quot; | sudo tee /var/www/example.com/public_html/.htaccess&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This rule will redirect requests for `/new-page` to `/old-page.html` with a permanent (301) redirect.&lt;br /&gt;
&lt;br /&gt;
== Step 4: Securing Apache with SSL/TLS ==&lt;br /&gt;
&lt;br /&gt;
Securing your websites with HTTPS is crucial for data privacy and trust. We'll use Let's Encrypt for free SSL certificates.&lt;br /&gt;
&lt;br /&gt;
=== Install Certbot ===&lt;br /&gt;
&lt;br /&gt;
Certbot is a tool that automates the process of obtaining and renewing Let's Encrypt certificates.&lt;br /&gt;
&lt;br /&gt;
==== For Debian/Ubuntu ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo apt update&lt;br /&gt;
sudo apt install certbot python3-certbot-apache -y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== For RHEL/CentOS/Fedora ====&lt;br /&gt;
&lt;br /&gt;
First, ensure you have the EPEL repository enabled.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo yum install epel-release -y&lt;br /&gt;
sudo yum install certbot python3-certbot-apache -y&lt;br /&gt;
# Or for newer Fedora/RHEL versions:&lt;br /&gt;
# sudo dnf install epel-release -y&lt;br /&gt;
# sudo dnf install certbot python3-certbot-apache -y&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Obtain SSL Certificates ===&lt;br /&gt;
&lt;br /&gt;
Run Certbot to get certificates for your domains. Make sure your domain's DNS records are pointing to your server's IP address.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo certbot --apache -d example.com -d www.example.com -d blog.example.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Follow the on-screen prompts. Certbot will automatically detect your virtual hosts, obtain certificates, and configure Apache to use them. It will also set up automatic renewal.&lt;br /&gt;
&lt;br /&gt;
=== Verify SSL Configuration ===&lt;br /&gt;
&lt;br /&gt;
After running Certbot, your sites should be accessible via HTTPS. You can verify this by visiting `https://example.com` in your browser. Look for the padlock icon.&lt;br /&gt;
&lt;br /&gt;
Certbot typically modifies your virtual host files to include SSL configurations and redirects HTTP traffic to HTTPS.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
*   '''Apache not starting:''' Check the Apache error logs (`/var/log/apache2/error.log` or `/var/log/httpd/error_log`) for specific messages. Common issues include syntax errors in configuration files or port conflicts.&lt;br /&gt;
*   '''Virtual hosts not working:'''&lt;br /&gt;
    *   Ensure DNS records are correctly pointing to your server's IP.&lt;br /&gt;
    *   Verify that your virtual host configuration files are enabled (e.g., using `a2ensite` on Debian/Ubuntu).&lt;br /&gt;
    *   Check file permissions for your web root directories.&lt;br /&gt;
    *   Confirm that `ServerName` directives match the domains you are testing.&lt;br /&gt;
*   '''SSL certificate errors:'''&lt;br /&gt;
    *   Ensure Certbot ran successfully and that you followed all prompts.&lt;br /&gt;
    *   Check that your domain's DNS is pointing to the correct IP address.&lt;br /&gt;
    *   Verify that port 80 is open for the initial Let's Encrypt challenge.&lt;br /&gt;
    *   Run `sudo certbot renew --dry-run` to test the renewal process.&lt;br /&gt;
*   '''mod_rewrite not working:'''&lt;br /&gt;
    *   Ensure `mod_rewrite` is enabled.&lt;br /&gt;
    *   Verify that `AllowOverride All` is set in the relevant `&amp;lt;Directory&amp;gt;` block in your Apache configuration.&lt;br /&gt;
    *   Check your `.htaccess` file for syntax errors.&lt;br /&gt;
&lt;br /&gt;
== Related Articles ==&lt;br /&gt;
&lt;br /&gt;
*   [[Firewall Configuration]]&lt;br /&gt;
*   [[DNS Management]]&lt;br /&gt;
*   [[Securing Linux Servers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server Setup]]&lt;br /&gt;
[[Category:Apache]]&lt;br /&gt;
[[Category:Linux Administration]]&lt;br /&gt;
&lt;br /&gt;
{{Exchange Box}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>