How to Install PixelFed on Manjaro

PixelFed is an open-source, federated image-sharing platform that allows users to upload, share, and follow photos and videos from other PixelFed instances. In this tutorial, we will show you how to install PixelFed on Manjaro, a popular Arch-based Linux distribution.

Prerequisites

Before getting started, you need to have the following prerequisites:

Installation

Here are the steps to install PixelFed on Manjaro Linux.

Step 1: Install Required Packages

Firstly, ensure that your system is up-to-date by running the following command:

sudo pacman -Syu

Once the system is updated, install the required packages for PixelFed as follows:

sudo pacman -S nginx certbot php php-fpm php-intl php-gd php-imagick php-pgsql postgresql imagemagick git composer

Step 2: Create a Database

Next, create a new user and a database for PixelFed:

sudo -u postgres createuser pixelfed --createdb
sudo -u postgres createdb -O pixelfed pixelfed

Step 3: Clone the PixelFed Git Repository

Next, clone the PixelFed Git repository to your system:

sudo git clone https://github.com/pixelfed/pixelfed.git /var/www/pixelfed

Step 4: Install Dependencies

Navigate to the cloned directory and install the required dependencies using Composer:

sudo chmod -R 777 /var/www/pixelfed/storage /var/www/pixelfed/bootstrap/cache
cd /var/www/pixelfed
sudo composer install --no-dev

Step 5: Configuration

Create a new virtual host for PixelFed using Nginx by creating a new configuration file:

sudo nano /etc/nginx/conf.d/pixelfed.conf

Add the following configuration to the file:

server {
    listen      80;
    server_name your-domain.example.com www.your-domain.example.com;
    return      301 https://$server_name$request_uri;
}

server {
    listen      443 ssl http2;
    server_name your-domain.example.com www.your-domain.example.com;
    root        /var/www/pixelfed/public;

    index       index.php;

    charset utf-8;

    gzip                on;
    gzip_types          text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    autoindex           off;
    add_header          X-Content-Type-Options    nosniff;
    add_header          X-XSS-Protection          "1; mode=block";
    add_header          X-Frame-Options           "SAMEORIGIN";
    add_header          X-Powered-By              "PixelFed";

    ssl_certificate "/etc/letsencrypt/live/your-domain.example.com/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/your-domain.example.com/privkey.pem";
    ssl_protocols       TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers         "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 1h;

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

    location ~ \.php$ {
        include         fastcgi_params;
        fastcgi_pass    unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO               $fastcgi_path_info;
        fastcgi_param   PATH_TRANSLATED         $document_root$fastcgi_path_info;
        fastcgi_param   QUERY_STRING            $query_string;
        fastcgi_param   SERVER_NAME             $server_name;
        fastcgi_param   HTTPS                   on;
        fastcgi_param   HTTP_PROXY              "";
        fastcgi_param   PHP_ADMIN_VALUE         "open_basedir=$document_root:/tmp:/usr/share/pear:/usr/share/php:/var/www/pixelfed:/var/www/pixelfed/vendor/bin:/var/www/pixelfed/vendor/autoload.php";
    }

    location = /favicon.ico {
        return 204;
        access_log off;
        log_not_found off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ /\.(?!well-known).*$ {
        deny all;
    }
}

Save and exit the file.

Step 6: Obtain TLS/SSL Certificate

PixelFed requires TLS/SSL certificates for secure communication between the server and the client. To obtain a free Let's Encrypt TLS/SSL certificate, install Cerbot:

sudo pacman -S certbot

Then, run the following command to obtain the Let's Encrypt TLS/SSL certificate:

sudo certbot certonly --webroot -w /var/www/pixelfed/public -d your-domain.example.com -d www.your-domain.example.com

Step 7: Configure Pixelfed

Next, configure Pixelfed by copying the example configuration file:

cd /var/www/pixelfed
sudo cp .env.example .env
sudo nano .env

Update the following variables in the .env file:

APP_NAME = "PixelFed"
APP_ENV = production
APP_DEBUG = false
APP_URL = https://your-domain.example.com

DB_CONNECTION = pgsql
DB_HOST = 127.0.0.1
DB_PORT = 5432
DB_DATABASE = pixelfed
DB_USERNAME = pixelfed
DB_PASSWORD = your-secret-password

MAIL_DRIVER = smtp
MAIL_HOST = smtp.gmail.com
MAIL_PORT = 465
MAIL_USERNAME = your-email-address
MAIL_PASSWORD = your-email-password
MAIL_ENCRYPTION = ssl

REDIS_HOST = 127.0.0.1
REDIS_PORT = 6379
REDIS_PASSWORD = your-secret-redis-password

SESSION_DRIVER = redis
SESSION_LIFETIME = 120

BROADCAST_DRIVER = log

IMGPROXY_URL = https://pixelfed.example.com/proxy

Save and exit the file.

Step 8: Create the Database

Run the following command to run the database migration:

sudo php artisan migrate

Step 9: Start the Services

Start the required services by running the following command:

sudo systemctl start nginx php-fpm postgresql redis

Step 10: Enable Services

Enable the services to run on system boot:

sudo systemctl enable nginx php-fpm postgresql redis certbot-renew.timer

That's it! You can now access PixelFed by navigating to https://your-domain.example.com in your web browser.

Conclusion

In this tutorial, you have learned how to install PixelFed on Manjaro Linux. If you face any issues during the installation, post your queries in the comment section below!

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!

Alternatively, for the best virtual desktop, try Shells!