HomeARCHHow To Install Apache Web Server on Arch Linux|EndeavourOS

How To Install Apache Web Server on Arch Linux|EndeavourOS

Welcome to our today’s guide on How To Install Apache Web Server on Arch Linux|EndeavourOS. Apache is free software that is open-source and has a flexible architecture that permits additional functionality. Everyone can download and use Apache because it is maintained by a volunteer developer community.

Apache is the primary Web Server on Linux-based systems. Clients access web servers to request content, which is then displayed in any browser. For example, a user might type a URL into the browser’s address bar. It is a web server that processes the input to obtain relevant information for a client.

Install Apache Web Server on Arch Linux|EndeavourOS

The Apache Web Server is available in Arch Linux’s official repository. As a result, it can be installed using the “Pacman” package manager from Arch.

The following steps will guide you on how to install the Apache web server on Arch Linux|EndeavourOS successfully.

#1. Update the system

Use the following command to synchronize and update the system’s database before installation.

sudo pacman -Syu

#2. Install the Apache web server

Provide the following command to Arch Linux|EndeavourOS to install the Apache Web Server.

sudo pacman -S apache

Sample output:

resolving dependencies...
looking for conflicting packages...

Package (3)     New Version  Net Change  Download Size

extra/apr       1.7.2-2        1.16 MiB       0.27 MiB
extra/apr-util  1.6.3-1        0.67 MiB       0.17 MiB
extra/apache    2.4.56-1       6.48 MiB       1.69 MiB

Total Download Size:   2.13 MiB
Total Installed Size:  8.31 MiB

:: Proceed with installation? [Y/n] Y

#3. Enable and Start Apache Service on Arch Linux|EndeavourOS

Use the following command to start and enable the Apache service;

sudo systemctl enable httpd
sudo systemctl restart httpd

Verify Apache status:

systemctl status httpd

Output:

 httpd.service - Apache Web Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
     Active: active (running) since Wed 2023-03-15 07:18:13 UTC; 22s ago
   Main PID: 3978 (httpd)
      Tasks: 82 (limit: 4576)
     Memory: 18.2M
        CPU: 118ms
     CGroup: /system.slice/httpd.service
             ├─3978 /usr/bin/httpd -k start -DFOREGROUND
             ├─3979 /usr/bin/httpd -k start -DFOREGROUND
             ├─3980 /usr/bin/httpd -k start -DFOREGROUND
             └─3981 /usr/bin/httpd -k start -DFOREGROUND

Mar 15 07:18:13 EndeavourOS systemd[1]: Started Apache Web Server.

The Apache package does not include a default index.html file for testing the Apache. You can put it in the Apache default root directory by running the following command:

sudo nano /srv/http/index.html

Insert the following code:

<html>
 <title>Welcome</title>
  <body>
   <h2>Welcome to Tutornix test page</h2>
  </body>
</html>

Save and close the file, then launch your web browser and navigate to the Apache test page at http://<your-server-ip>.
The Apache page should appear on the following screen:

How To Install Apache Web Server on Arch Linux|EndeavourOS

#4. Create a virtual host for Apache

Those that use virtual hosting can host numerous websites on a single server. Use the command below to establish a directory for virtual hosts:

sudo mkdir /etc/httpd/conf/vhosts

Create a file for Apache’s virtual host configuration.

sudo nano /etc/httpd/conf/vhosts/example.com

Insert the following code:

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

    <Directory "/srv/example.com">
        Require all granted
    </Directory>
</VirtualHost>

Save and close the file.

Test the configuration file above;

$ apachectl configtest
Syntax OK

Use the following command to establish a website directory;

sudo mkdir /srv/example.com

Create your website’s index.html page.

sudo nano /srv/example.com/index.html

Insert the following code:

<html>
 <title>Example.com</title>
  <body>
   <h1>Welcome to Tutornix.com. We provide you with amazing *Nix Tutorials</h1>
  </body>
</html>

Transfer ownership of your website:

sudo chown -R root:http /srv/example.com

Edit the Apache main configuration file as follows;

sudo nano /etc/httpd/conf/httpd.conf

Add the following line to your virtual host definition;

Include conf/vhosts/example.com

Add as shown below;

How To Install Apache Web Server on Arch Linux|EndeavourOS

The website name must be added to the hosts’ file before restarting Apache.

sudo nano /etc/hosts
.........
127.0.0.1  test.example.com

Add as shown below;

How To Install Apache Web Server on Arch Linux|EndeavourOS

To apply the changes, save and close the file, then restart the Apache service;

sudo systemctl restart httpd

Now, open your web browser and go to http://test.example.com to verify your website.
Your website should appear on the screen below:

How To Install Apache Web Server on Arch Linux|EndeavourOS

Conclusion

We covered how to install the Apache web server on Arch Linux|EndeavourOS in this post. We also demonstrated how to set up a virtual host in Apache. Using Apache’s virtual hosting feature, you can now host multiple websites on a single website.

Read more about Apache;

Other cool guides:

- Advertisment -

Recent posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here