How to Install Known on NixOS Latest
In this tutorial, we will go through the steps to install Known, a social publishing platform, on NixOS Latest.
Prerequisites
Before we begin, make sure you have the following:
- A server running NixOS Latest
- A user with sudo privileges
- A domain name or subdomain for your Known instance
Step 1: Update NixOS
Let's make sure that your NixOS is up to date by running the following command:
sudo nixos-rebuild switch
Step 2: Install Known Dependencies
Before we can install Known, we need to install its dependencies. Run the following command to install the required packages:
sudo nix-env -i nginx php74 php74-fpm php74-intl php74-apcu php74-memcached sqlite git
Step 3: Clone the Known Repository
Next, we need to clone the Known repository. Run the following command to clone it:
git clone https://github.com/idno/known.git /opt/known
Step 4: Configure Nginx
Now, we need to configure Nginx to serve Known. Create a new configuration file called known in the /etc/nginx/sites-available/ directory:
sudo nano /etc/nginx/sites-available/known
Paste the following configuration:
server {
listen 80;
server_name your-domain.com;
# Redirect all HTTP requests to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name your-domain.com;
root /opt/known;
index index.php;
ssl_certificate /etc/nginx/certificates/your-domain.com.crt;
ssl_certificate_key /etc/nginx/certificates/your-domain.com.key;
# Redirect all HTTP requests to HTTPS
if ($scheme != "https") {
return 301 https://$server_name$request_uri;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}
}
Replace your-domain.com with your domain or subdomain, and save the file. Now, enable the site by creating a symbolic link to the sites-enabled folder:
sudo ln -s /etc/nginx/sites-available/known /etc/nginx/sites-enabled/
Finally, restart Nginx to apply the changes:
sudo systemctl restart nginx
Step 5: Configure Known
Now, we need to configure Known to use our domain name and database. First, rename the Ini.sample file to Ini:
cd /opt/known
mv Ini.sample Ini
Next, open the Ini file and set the following values:
known.followermail.enabled = false
known.site = https://your-domain.com/
known.pretty_urls = true
db.defaults.engine = mysql
db.host = localhost
db.user = known
db.pass = your-password
db.name = known
Replace your-domain.com with your domain or subdomain, and set a secure password for db.pass. We use mysql here, but you can also use sqlite.
Step 6: Install Known
We have configured everything we need, so let's install Known by running the following command:
php74 composer.phar install
This will install all the required dependencies, and may take several minutes to complete.
Step 7: Start Known
Finally, let's start Known by running the following command:
sudo systemctl start php74-fpm
That's it! You should now be able to access your Known instance by navigating to https://your-domain.com/ in your web browser. If you run into any issues, make sure to check the logs and troubleshoot accordingly.