• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Arch

How to Install Apache 2.4 on Arch Linux

How VPS by How VPS
August 8, 2019
in Arch, Uncategorized
0
0
SHARES
50
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Prerequisites
  2. Install Apache 2.4 Web Server
  3. Disabling Indexes
  4. User Directories
  5. Virtual Hosts
  6. Want to contribute?


Prerequisites

  • A Vultr server running up to date Arch Linux. See this guide for more information.
  • Sudo access.
    • Commands required to be run as root are prefixed by #, and ones that can be run as a regular user by $. The recommended way to run commands as root is to, as a regular user, prefix each of them with sudo.
  • Have a text editor installed, and be familiar with it, such as vi, vim, nano, emacs and so on.

Install Apache 2.4 Web Server

If you are using a firewall, you will need to enable incoming TCP traffic to port 80.

Install Apache:

# pacman -S apache

Start Apache, and make it start after every boot:

# systemctl enable --now httpd

Test that Apache is running. Visit http://YOUR-SERVER-WEB-ADDRESS-OR-IP, and you will see a page showing “Index of /”. Run ip addr if you need to know the IP address.

Apache’s configuration file is /etc/httpd/conf/httpd.conf. Although Apache is started by the root user, User http makes it immediately switch to running as this user for security reasons. DocumentRoot "/srv/http" sets where it will look for web files. CustomLog "/var/log/httpd/access_log" common sets where accesses to Apache that are successful will be logged. ErrorLog "/var/log/httpd/error_log" sets where accesses to Apache that error will be logged.

Disabling Indexes

By default, if Apache is given a directory that it does not find an index file with an extension it’s configured to use, it will automatically generate an index showing the directory’s contents. This can be considered a security vulnerability. To disable it, edit /etc/httpd/conf/httpd.conf and within <Directory "/srv/http">, from Options, delete Indexes. Once restarted, Apache will give an “Access forbidden!” error message, unless a file like /srv/http/index.html exists.

Restart Apache:

# systemctl restart httpd

User Directories

By default, a user’s ~/public_html/ directory will be shown at http://YOUR-SERVER-WEB-ADDRESS-OR-IP/~USERNAME/. But, the user http must have executable bit access to the user directory and its public_html directory:

$ mkdir ~/public_html
$ chmod o+x ~/
$ chmod o+x ~/public_html

Additionally, the user http must have read access to individual files. If necessary, run the following command:

$ chmod o+r ~/public_html/<FILES>

If you want to disable user’s public_html directories from being on your web server, regardless of directory and file permissions, comment this line (add # to the beginning) in /etc/httpd/conf/httpd.conf:

Include conf/extra/httpd-userdir.conf

Restart Apache:

# systemctl restart httpd

Virtual Hosts

You can host multiple domain names from the same Apache server, and serve them different content.

Create a folder to hold your virtual host configurations:

# mkdir /etc/httpd/conf/vhosts

Create a configuration file for each virtual host, such as /etc/httpd/conf/vhosts/YOUR-DOMAIN-NAME.com:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/srv/YOUR-DOMAIN-NAME.com"
    ServerName YOUR-DOMAIN-NAME.com
    ServerAlias YOUR-DOMAIN-NAME.com
    ErrorLog "/var/log/httpd/YOUR-DOMAIN-NAME.com-error_log"
    CustomLog "/var/log/httpd/YOUR-DOMAIN-NAME.com-access_log" common

    <Directory "/srv/YOUR-DOMAIN-NAME.com">
        Require all granted
    </Directory>
</VirtualHost>

Make the virtual host serving directory:

# mkdir /srv/YOUR-DOMAIN-NAME.com

At the end of /etc/httpd/conf/httpd.conf, include each of these virtual host configuration files:

Include conf/vhosts/YOUR-DOMAIN-NAME.com

Restart Apache:

# systemctl restart httpd

Requests Apache receives to YOUR-DOMAIN-NAME.com will be served out of /srv/YOUR-DOMAIN-NAME.com. Note requests to Apache not matching a specific ServerName or ServerAlias, just the IP address, or another domain name resolving to your IP, will still be served out of the first virtual host that is included. That said, you should still consider anything in the general DocumentRoot, which defaults to /srv/http, to be somehow accessible.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

Using Devtools on Arch Linux

Next Post

Using Makepkg on Arch Linux

Next Post

Using Makepkg on Arch Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet