How to Install Webtrees on NixOS
Webtrees is an open source web-based genealogy application. In this tutorial, we will guide you through the process of installing Webtrees on NixOS.
Prerequisites
- Access to a NixOS system with the root access or a user account with sudo privileges.
Step 1: Open the Terminal
Open the terminal on your NixOS system.
Step 2: Update the System
Before proceeding, update the system packages to ensure that you have the latest software installed on your system.
To update the system, run the following command:
sudo nix-channel --update
sudo nixos-rebuild switch
Step 3: Install PHP
Webtrees is written in PHP, so you need to install PHP and some PHP extensions required by Webtrees.
To install PHP, run the following command:
sudo nix-env -i php php-fpm php-mysql php-gd php-zip
Step 4: Install a Web Server
Webtrees requires a web server to run. You can choose between Apache or Nginx. In this tutorial, we will install Nginx.
To install Nginx, run the following command:
sudo nix-env -i nginx
Step 5: Configure Nginx
Next, you need to create a new Nginx server block for Webtrees.
Open the Nginx configuration file using your favorite text editor:
sudo nano /etc/nginx/nginx.conf
Scroll down to the http section and add the following lines:
server {
listen 80;
server_name your-domain-name.com;
root /var/www/webtrees;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
Replace your-domain-name.com with your actual domain name. Save and close the file.
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Step 6: Download and Install Webtrees
Download Webtrees from the official website:
wget https://github.com/fisharebest/webtrees/releases/download/2.0.11/webtrees-2.0.11.zip
Extract the downloaded file to the default document root directory of Nginx:
sudo unzip -d /var/www/ webtrees-2.0.11.zip
Rename the extracted directory to webtrees:
sudo mv /var/www/webtrees-2.0.11 /var/www/webtrees
Change the ownership of the webtrees directory to the Nginx user:
sudo chown -R nginx:nginx /var/www/webtrees
Step 7: Configure Webtrees
Open the config.ini.php configuration file:
sudo nano /var/www/webtrees/data/config.ini.php
Edit the following lines:
[DATABASE]
db_type = "mysql"
db_host = "localhost"
db_user = "webtrees_user"
db_pass = "webtrees_password"
db_name = "webtrees_db_name"
Replace the database credentials with your actual database credentials.
Save and close the file.
Step 8: Create a MySQL Database
Connect to your MySQL database server:
mysql -u root -p
Create a new database for Webtrees:
CREATE DATABASE webtrees_db_name;
Create a new user for Webtrees:
CREATE USER 'webtrees_user'@'localhost' IDENTIFIED BY 'webtrees_password';
Grant all privileges on the webtrees_db_name database to the webtrees_user:
GRANT ALL PRIVILEGES ON webtrees_db_name.* TO 'webtrees_user'@'localhost';
Exit MySQL:
exit
Step 9: Test Webtrees
Finally, open your web browser and go to http://your-domain-name.com. You should see the Webtrees installation wizard.
Follow the prompts to complete the installation.
Conclusion
In this tutorial, you learned how to install Webtrees on NixOS. You also learned how to configure Nginx, PHP, and MySQL to work with Webtrees.