PixelFed is a free and open-source, federated image-sharing platform that can be self-hosted. This tutorial will guide you through the process of installing PixelFed on Ubuntu Server Latest.
Before you start installing PixelFed, you should have:
Before starting with the PixelFed installation, it is important to update the system and packages to their latest versions. Run the following command:
sudo apt-get update && sudo apt-get upgrade -y
PixelFed requires some dependencies to be installed. Use the below command to install those dependencies:
sudo apt-get install -y curl git imagemagick ffmpeg exiftool sqlite3 libsqlite3-dev composer nodejs npm php7.4-fpm php7.4 gd php7.4-gd php7.4-mbstring php7.4-xml php7.4-bcmath
PixelFed needs a web server to function, we will install Nginx web server. Run the below command:
sudo apt-get install -y nginx
Once installed, start the Nginx service with:
sudo systemctl start nginx
PixelFed's source code is available on Github, clone the repository using Git by executing:
git clone https://github.com/pixelfed/pixelfed.git /var/www/pixelfed
PixelFed requires some extensions to be enabled in PHP. Edit the /etc/php/7.4/fpm/php.ini file and add the following values:
cgi.fix_pathinfo=0
file_uploads=On
upload_max_filesize=20M
post_max_size=20M
memory_limit=256M
Restart PHP-FPM to apply the changes:
sudo systemctl restart php7.4-fpm
Create a new Nginx server block by creating a file at /etc/nginx/sites-enabled/pixelfed.conf with the below content:
server {
listen 80;
server_name pixelfed.example.com;
root /var/www/pixelfed/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?$query_string;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 300;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Replace pixelfed.example.com
with your domain. After creating the configuration file, link it by running the following command:
sudo ln -s /etc/nginx/sites-available/pixelfed.conf /etc/nginx/sites-enabled/
Test the Nginx configuration:
sudo nginx -t
If the configuration test is successful, restart the Nginx service:
sudo systemctl reload nginx
PixelFed needs a database to store its data. Create an SQLite database by running the following commands:
sudo mkdir -p /var/www/pixelfed/database/
sudo touch /var/www/pixelfed/database/database.sqlite
sudo chown -R www-data:www-data /var/www/pixelfed/database/
PixelFed uses Composer to manage its dependencies. Change the working directory to /var/www/pixelfed and install dependencies by running the following command:
cd /var/www/pixelfed
sudo composer install --no-dev --optimize-autoloader
Run the following command to generate an application key:
php artisan key:generate --force
Create tables in the database by running database migrations using the command below:
php artisan migrate --force
After running the migration, you will need to seed the database with default data using the below command:
php artisan db:seed --force
PixelFed uses NodeJS to compile CSS and JavaScript. Install NodeJS dependencies by running the following command:
cd /var/www/pixelfed
sudo npm install
sudo npm run production
Finally, set the App URL by editing the .env file:
sudo nano /var/www/pixelfed/.env
Edit the below line with your domain name:
APP_URL=http://pixelfed.example.com
Restart Nginx and PHP-FPM service:
sudo systemctl reload nginx
sudo systemctl restart php7.4-fpm
You can now access the PixelFed website by visiting the URL you set in the .env file.
Congratulations! You have successfully installed PixelFed on Ubuntu Server Latest.
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!