How to Install RackTables on NixOS Latest?

RackTables is an open-source data center asset management system that helps organizations keep track of their servers, switches, and other hardware components. If you're looking to set up RackTables on your NixOS Latest system, then you've come to the right place. In this tutorial, we'll cover the steps required to install and configure RackTables on your NixOS system.

Prerequisites

Before we proceed with the installation process, it's important to ensure that you have the following prerequisites installed on your system:

Step 1: Install and Configure Apache Web Server

To install Apache web server, run the following command:

sudo nix-env -i apacheHttpd

Once installed, start Apache using the following command:

sudo systemctl start apache

To enable Apache to automatically start at boot time, run the following command:

sudo systemctl enable apache

To configure Apache to work with RackTables, create a new virtual host configuration file in the /etc/httpd/sites-available/ directory. For example, create a file named racktables.conf with the following content:

<VirtualHost *:80>
    DocumentRoot "/var/www/html/racktables"
    ServerName racktables.example.com

    <Directory "/var/www/html/racktables">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog "/var/log/apache/racktables-error.log"
    CustomLog "/var/log/apache/racktables-access.log" combined
</VirtualHost>

Save and close the file. Then, create a symbolic link to the sites-enabled directory using the following command:

sudo ln -s /etc/httpd/sites-available/racktables.conf /etc/httpd/sites-enabled/

Finally, restart Apache to apply the changes:

sudo systemctl restart apache

Step 2: Install and Configure MariaDB or MySQL Server

To install MariaDB, run the following command:

sudo nix-env -i mariadb

Once installed, start MariaDB using the following command:

sudo systemctl start mariadb

To enable MariaDB to automatically start at boot time, run the following command:

sudo systemctl enable mariadb

To secure MariaDB, run the following command:

sudo mysql_secure_installation

This command will prompt you to set a root password and reset other security-related settings.

Next, create a new database for RackTables using the following command:

mysql -u root -p -e "CREATE DATABASE racktables;"

Create a new user for RackTables and grant them access to the new database using the following command:

mysql -u root -p -e "GRANT ALL PRIVILEGES ON racktables.* TO 'racktables'@'localhost' IDENTIFIED BY 'password';"

Replace password with a strong password for the new user.

Finally, restart MariaDB to apply the changes:

sudo systemctl restart mariadb

Step 3: Install and Configure PHP

To install PHP, run the following command:

sudo nix-env -i php

Once installed, create a new php.ini file in the /etc/php/ directory using the following command:

sudo cp /etc/php/php.ini-development /etc/php/php.ini

Next, open the new php.ini file using your favorite text editor and update the following settings:

# Update the following settings:
max_execution_time = 300
memory_limit = 512M
upload_max_filesize = 128M
post_max_size = 128M
date.timezone = "UTC"

Save and close the file.

Step 4: Install and Configure RackTables

To install RackTables, run the following command:

sudo nix-env -i racktables

Once installed, create a new directory for RackTables using the following command:

sudo mkdir -p /var/www/html/racktables

Next, download the latest stable version of RackTables from the official website https://github.com/RackTables/racktables/releases.

Extract the RackTables archive to the /var/www/html/racktables directory using the following command:

sudo tar xvf racktables-x.y.z.tar.gz -C /var/www/html/racktables --strip-components=1

Replace x.y.z with the version number of the RackTables archive you downloaded.

Next, set the correct permissions for the RackTables directory using the following command:

sudo chown -R apache:apache /var/www/html/racktables

Then, create a new configuration file for RackTables using the following command:

sudo cp /var/www/html/racktables/inc/config.dist.php /var/www/html/racktables/inc/config.php

Open the new config.php file using your favorite text editor and update the following settings:

# Update the following settings:
$pdo_dsn = "mysql:host=localhost;dbname=racktables;charset=utf8mb4";
$pdo_user = "racktables";
$pdo_pass = "password";

Replace password with the password you set for the RackTables user in Step 2.

Save and close the file.

Step 5: Access RackTables

You should now be able to access RackTables by navigating to http://racktables.example.com/ in your web browser. Replace racktables.example.com with the server name or IP address of your NixOS system.

The default username and password for RackTables are admin and admin, respectively. We highly recommend that you change the default password as soon as possible.

Congratulations! You have successfully installed and configured RackTables on your NixOS Latest system.

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!