PHP

Enable additional modules required by Pixelfed:

sudo a2enmod rewrite proxy proxy_fcgi

Restart the service:

sudo systemctl restart apache2

Installation

After checking that the system is up to date, add php repository sources. Press Enter if needed:

sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/apache2

Install php and its Apache module:

sudo apt install -y php8.4-cli libapache2-mod-php8.4

Install additional modules required by Pixelfed:

sudo apt install -y php8.4-{bcmath,ctype,curl,exif,gd,iconv,imagick,intl,mbstring,mysqli,redis,tokenizer,xml,zip}
At the time of writing this tutorial (august 2025), php latest version is 8.4; check if you need to migrate.
Your installed version is given running php -v:
PHP 8.4.11 (cli) (built: Aug  3 2025 08:42:27) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
    

PHP-FPM

sudo apt install -y php-fpm

Add a directory and change ownership:

sudo mkdir -p /run/php-fpm
sudo chown www-data:www-data /run/php-fpm

Configure a pool:

sudo cp /etc/php/8.4/fpm/pool.d/www.conf /etc/php/8.4/fpm/pool.d/pixelfed.conf
sudo nano /etc/php/8.4/fpm/pool.d/pixelfed.conf

Modify the uncommented lines:

; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[pixelfed]
; Unix user/group of the child processes. This can be used only if the master
; process running user is root. It is set after the child process is created.
; The user and group can be specified either by their name or by their numeric
; IDs.
; Note: If the user is root, the executable needs to be started with
;       --allow-to-run-as-root option to work.
; Default Values: The user is set to master process running user by default.
;                 If the group is not set, the user's group is used.
user = pixelfed-user
group = pixelfed-user

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
;                            a specific port;
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/php-fpm/pixelfed.sock
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: Owner is set to the master process running user. If the group
;                 is not set, the owner's group is used. Mode is set to 0660.
listen.owner = www-data
listen.group = www-data
listen.mode = 0660

Save and exit Nano.
Edit php.ini file:

sudo nano /etc/php/8.4/apache2/php.ini

Find and modify the values of those parameters:

; Maximum execution time of each script, in seconds
; https://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 300

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; https://php.net/max-input-time
max_input_time = 300
; Maximum amount of memory a script may consume
; https://php.net/memory-limit
memory_limit = 512M
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; https://php.net/post-max-size
post_max_size = 1G
; Maximum allowed size for uploaded files.
; https://php.net/upload-max-filesize
upload_max_filesize = 1G

; Maximum number of files that can be uploaded via a single request
max_file_uploads = 500

Instagram imports

Instagram imports are affected by these settings. If you enable imports, you will want to raise post_max_size to the maximum size you expect an Instagram archive* to be, upload_max_filesize to the maximum size you expect individual Instagram photos to be, and max_file_uploads to the maximum number of photos (not posts) you'd expect an Instagram archive to contain.

Source: Pixelfed Docs

* the archive is the exported file sent to you by Meta, usually as instagram-user_name-YYYY-MM-DD-hash.zip

Save and exit Nano.
Modify those same lines in PHP-FPM ini file:

sudo nano /etc/php/8.4/fpm/php.ini

Restart PHP-FPM service:

sudo systemctl restart php8.4-fpm.service

Composer

cd ~/
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

We should see Installer verified. If so, we install Composer:

sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer