How to Install PixelFed on Ubuntu Server Latest
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.
Prerequisites
Before you start installing PixelFed, you should have:
- Ubuntu Server Latest installed
- sudo access for the user
- Basic knowledge of the command line
Step 1: Update Packages and System
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
Step 2: Install Dependencies
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
Step 3: Install Nginx Web Server
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
Step 4: Clone the PixelFed Repository
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
Step 5: Configure PHP
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
Step 6: Configure Nginx
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
Step 7: Create an SQLite Database
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/
Step 8: Install Composer Dependencies
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
Step 9: Generate an Application Key
Run the following command to generate an application key:
php artisan key:generate --force
Step 10: Run Migrations
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
Step 11: Install Node Dependencies
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
Step 12: Set App URL
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
Step 13: Restart Services
Restart Nginx and PHP-FPM service:
sudo systemctl reload nginx
sudo systemctl restart php7.4-fpm
Step 14: Access PixelFed
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.