How to Install SuiteCRM on Latest NixOS

Step 1: Create a User and Update Your System

Log in as a user with sudo privileges.

Create a new user and set its password:

sudo useradd -m -s /bin/bash suitecrmuser
sudo passwd suitecrmuser

Switch to the new user:

sudo su - suitecrmuser

Now you need to update your system:

sudo nix-channel --update
sudo nix-env -u

Step 2: Install Required Dependencies for SuiteCRM

To install dependencies for SuiteCRM, run the following command:

sudo nix-env -i mariadb php php-fpm composer nginx

Step 3: Install and Configure MariaDB

MariaDB is required by SuiteCRM. To install it, run the following command:

sudo nix-env -i mariadb

Once it installed, you need to start and enable mariadb on boot:

sudo systemctl enable mariadb
sudo systemctl start mariadb

Now you can setup the MariaDB root password and launch the secure installation by running:

sudo /nix/store/*/bin/mysql_secure_installation

Step 4: Configure PHP

SuiteCRM requires PHP version 7.3 or higher, so we need to install and configure it.

sudo systemctl start php-fpm

To configure PHP for nginx:

sudo nano /etc/php/7.4/fpm/php.ini

Add/edit the following lines:

cgi.fix_pathinfo=0
upload_max_filesize = 50M
post_max_size = 50M
memory_limit = 512M

Save and close the file.

Step 5: Install SuiteCRM

Now we can install SuiteCRM. To do that, go to the website https://suitecrm.com and get the link to the latest stable release.

Move to your home directory and run:

cd ~
curl -LJO https://suitecrm.com/download/suitecrm-7.11.20.zip
unzip suitecrm-7.11.20.zip
rm suitecrm-7.11.20.zip
sudo mv suitecrm /var/www/
sudo chown -R nginx:nginx /var/www/suitecrm
sudo chmod -R 775 /var/www/suitecrm

Step 6: Configure Nginx

Create a new nginx server block by running:

sudo nano /etc/nginx/sites-available/suitecrm.conf

Add the following code:

server {
    listen 80;
    listen [::]:80;
    server_name example.com;

    client_max_body_size 50M;

    root /var/www/suitecrm;
    index index.php;

    error_log /var/log/nginx/suitecrm-error.log;
    access_log /var/log/nginx/suitecrm-access.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Save and close the file.

Now create a symlink of that server block to the sites-enabled folder:

sudo ln -s /etc/nginx/sites-available/suitecrm.conf /etc/nginx/sites-enabled/

Test the nginx configuration:

sudo nginx -t

If there are no errors, reload the nginx configuration:

sudo systemctl reload nginx

Step 7: Access SuiteCRM

To access SuiteCRM, open your browser and type http://your_server_ip/ in the address bar. You will see the SuiteCRM installer. Follow the on-screen instructions to complete the installation.

Once the installation is complete, log in to SuiteCRM and start using it.

Congratulations! You have successfully installed SuiteCRM on NixOS.