How to install Shaark on NixOS Latest
Shaark is a web-based Wireshark-like network protocol analyzer that is compatible with PCAP files. It can help you troubleshoot network issues and monitor network traffic. In this tutorial, we will show you how to install Shaark on NixOS Latest.
Prerequisites
Before you start, make sure that you have:
- An instance of NixOS Latest with a user account with
sudoaccess. - Internet connectivity to download and install the necessary packages.
Step 1: Update system
First, update the system to the latest version:
sudo nix-channel --update
sudo nixos-rebuild switch
Step 2: Install Required Dependencies
You will need the following dependencies installed on your system:
- MySQL
- Nginx
- PHP-FPM
- Composer
You can install these dependencies by running the following commands:
sudo nix-env -i mysql nginx php-fpm composer
Step 3: Clone Shaark from GitHub
Next, clone the latest version of Shaark from GitHub:
git clone https://github.com/MarceauKa/shaark.git
Step 4: Install Required PHP Packages
To install the required PHP packages, navigate to the Shaark root directory and run the following command:
cd shaark
composer install
Step 5: Configure Nginx
Create a new Nginx configuration file for Shaark:
sudo nano /etc/nginx/sites-available/shaark
Add the following configuration:
server {
listen 80;
server_name shaark.example.com;
root /path/to/shaark/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
Change the server_name and root values to match your environment. Save and exit the file.
Create a symbolic link to sites-enabled:
sudo ln -s /etc/nginx/sites-available/shaark /etc/nginx/sites-enabled/
Remove the default Nginx configuration:
sudo rm /etc/nginx/conf.d/default.conf
Test the Nginx configuration:
sudo nginx -t
If there are no errors, restart Nginx:
sudo systemctl restart nginx
Step 6: Configure PHP-FPM
Edit the PHP-FPM configuration file:
sudo nano /etc/php-fpm.d/www.conf
Change the following values:
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
Save and exit the file.
Restart PHP-FPM:
sudo systemctl restart php-fpm
Step 7: Configure MySQL
Create a new database and user in MySQL:
mysql -u root -p
CREATE DATABASE shaark;
CREATE USER 'shaark'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON shaark.* TO 'shaark'@'localhost';
FLUSH PRIVILEGES;
Change password to a secure password of your choice.
Step 8: Configure Shaark
Copy the .env.example file to .env:
cp .env.example .env
Edit the .env file:
APP_ENV=production
APP_DEBUG=false
APP_URL=http://shaark.example.com
DB_DATABASE=shaark
DB_USERNAME=shaark
DB_PASSWORD=password
Change the APP_URL, DB_USERNAME, DB_PASSWORD values to match your environment. Save and exit the file.
Generate a new application key:
php artisan key:generate
Run the database migrations:
php artisan migrate
Step 9: Start Shaark
Start the built-in PHP development server:
php artisan serve --host=0.0.0.0 --port=8000
You should now be able to access Shaark by visiting http://server_ip_address:8000 in your web browser.
Conclusion
You have successfully installed Shaark on NixOS Latest. You can now use Shaark to analyze network traffic using PCAP files.