How to Install PixelFed on Elementary OS Latest

PixelFed is a free and open-source social media app that is similar to Instagram. In this tutorial, we will guide you through the installation of PixelFed on Elementary OS latest version.

Prerequisites

Before starting the installation process, make sure your system is up to date:

sudo apt update && sudo apt upgrade -y

Step 1: Install Required Dependencies

PixelFed requires some dependencies that need to be installed before the installation process. Run the following command to install them:

sudo apt install -y apache2 php composer zip unzip php-dom php-mbstring php-gd php-curl php-zip php-bcmath php-mysql

Step 2: Download PixelFed

Now, download the latest PixelFed source code from its official repository using the following command:

git clone https://github.com/pixelfed/pixelfed.git

Step 3: Configure Apache

Next, we need to configure an Apache virtual host. Create a new Apache virtual host configuration file using your favorite text editor:

sudo nano /etc/apache2/sites-available/pixelfed.conf

Copy and paste the following configuration block into it:

<VirtualHost *:80>
    ServerName your.domain
    ServerAlias www.your.domain
    DocumentRoot /var/www/pixelfed/public
    <Directory /var/www/pixelfed/public>
        AllowOverride All
    </Directory>
    ErrorLog /var/log/apache2/pixelfed-error.log
    CustomLog /var/log/apache2/pixelfed-access.log combined
</VirtualHost>

Make sure to replace the your.domain value with your site’s domain name.

Save the changes and enable the virtual host:

sudo a2ensite pixelfed.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo systemctl reload apache2

Step 4: Configure the Database

PixelFed uses a MySQL/MariaDB database for its data storage. If you don’t already have MySQL/MariaDB installed, you can install it using the following command:

sudo apt install mariadb-server mariadb-client

Next, create a new database and user with the following commands:

mysql -u root -p
CREATE DATABASE pixelfed;
CREATE USER 'pixelfed_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON pixelfed.* TO 'pixelfed_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace your_secure_password with a strong password.

Step 5: Configure the Environment Variables

PixelFed uses environment variables to load the configuration settings. Create a new .env file in the project directory:

cd pixelfed
cp .env.example .env

Update the .env file with your database and site configuration settings:

APP_NAME="Your Site Name Here"
APP_ENV=production
APP_DEBUG=false
APP_URL=http://your.domain
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pixelfed
DB_USERNAME=pixelfed_user
DB_PASSWORD=your_secure_password

Again, make sure to replace the values with your own configuration settings.

Step 6: Install the Dependencies and Install PixelFed

Finally, run the following command to install the dependencies and install PixelFed:

composer install --no-dev
php artisan migrate --force

If everything is OK, you will see the following message:

Migration table created successfully.
Migrating: 2013_04_22_171935_create_oauth_clients_table
Migrated:  2013_04_22_171935_create_oauth_clients_table
Migrating: 2013_04_22_215523_create_profiles_table
Migrated:  2013_04_22_215523_create_profiles_table
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table
Migrating: 2018_09_25_175450_create_media_table
Migrated:  2018_09_25_175450_create_media_table
Migrating: 2018_09_25_175556_create_tags_table
Migrated:  2018_09_25_175556_create_tags_table
Migrating: 2018_09_25_175601_create_mentions_table
Migrated:  2018_09_25_175601_create_mentions_table
Migrating: 2018_09_25_175625_create_comments_table
Migrated:  2018_09_25_175625_create_comments_table
Migrating: 2018_09_25_175657_create_followers_table
Migrated:  2018_09_25_175657_create_followers_table
Migrating: 2018_09_25_175712_create_requests_table
Migrated:  2018_09_25_175712_create_requests_table
Migrating: 2018_09_25_175744_create_blocks_table
Migrated:  2018_09_25_175744_create_blocks_table
Migrating: 2018_09_25_175806_create_relationships_table
Migrated:  2018_09_25_175806_create_relationships_table
Migrating: 2019_03_02_000001_create_activitypub_relations_table
Migrated:  2019_03_02_000001_create_activitypub_relations_table
Migrating: 2019_03_02_200000_create_conversations_table
Migrated:  2019_03_02_200000_create_conversations_table
Migrating: 2019_03_02_200100_create_messages_table
Migrated:  2019_03_02_200100_create_messages_table
Migrating: 2020_08_22_000001_create_media_tags_table
Migrated:  2020_08_22_000001_create_media_tags_table
Migrating: 2021_03_17_235514_create_hastags_table
Migrated:  2021_03_17_235514_create_hastags_table
Migrating: 2021_03_17_235631_create_hashtaggables_table
Migrated:  2021_03_17_235631_create_hashtaggables_table

Step 7: Configure Cron Job

PixelFed requires a Cron job to run some of its background tasks. Open your user’s crontab file:

crontab -e

Add the following line at the end of the file:

* * * * * cd /path/to/pixelfed && php artisan schedule:run >> /dev/null 2>&1

Make sure to replace /path/to/pixelfed with the absolute path to the Pixelfed installation directory.

Save and close the file.

Step 8: Access the Site

At this point, the PixelFed installation is complete. You can access the site by visiting its URL on a web browser. If everything is configured correctly, you will see the PixelFed login page.

Conclusion

In this tutorial, we have shown you how to install PixelFed on Elementary OS latest version. You now have your own social media platform where you can share your photos and connect with your friends and family.

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!