Installing Apache on NixOS

Apache is a well-known and widely used web server that is available for many different platforms, including NixOS. In this tutorial, we will discuss how to install Apache on the latest version of NixOS.

Prerequisites

Before proceeding with the installation, make sure your NixOS system is up-to-date by running the following command:

sudo nix-channel --update
sudo nixos-rebuild switch

Installing Apache

To install Apache on NixOS, follow these steps:

  1. Open a terminal on your NixOS system.

  2. Run the following command to update the package list:

    sudo nix-channel --update
    
  3. Once the package list is updated, run the following command to install Apache:

    sudo nix-env -i apacheHttpd
    

    This will install the latest version of Apache available for NixOS.

Configuring Apache

After you have installed Apache, you can configure it to suit your needs. The main configuration file for Apache on NixOS is located at /etc/nixos/apache2.nix.

To edit this file, open it in a text editor with root privileges:

sudo nano /etc/nixos/apache2.nix

This file contains all of the basic configuration options for Apache. You can modify this file to change things like the server name, ports, document root, and more.

Once you have modified the configuration file to suit your needs, save the file and restart Apache by running the following command:

sudo systemctl restart httpd

Testing Apache

To test that Apache is working properly on your NixOS system, open a web browser and navigate to http://localhost. You should see the default Apache page.

Congratulations, you have successfully installed and configured Apache on NixOS!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!