pixelfed/docs

End to end Ubuntu 20.04 installation guide

shleeable opened this issue · 5 comments

image
image

Upgrade Ubuntu 20.04 LTS

apt update
apt upgrade -y
reboot now

Redis - Install

apt -y install redis-server
systemctl enable redis-server

MariaDB - Install

apt -y install mariadb-server
systemctl enable mariadb
mysql_secure_installation
mysql -u root -p

Run the SQL query to create the pixelfed DB

create database pixelfed;
grant all privileges on pixelfed.* to 'pixelfed'@'localhost' identified by 'secretpasswordhere';
flush privileges;
exit;

Setup dependent packets

apt -y install ffmpeg 
apt -y install jpegoptim optipng pngquant gifsicle 
apt -y install unzip zip

PHP - Install

apt -y install php7.4-fpm php7.4-cli
### Install additional PHP modules not installed by default
apt -y install php7.4-bcmath php7.4-curl php7.4-gd php7.4-intl php7.4-mbstring php7.4-redis php7.4-xml php7.4-zip php7.4-mysql

PHP - Setup

nano /etc/php/7.4/fpm/php.ini

Edit these lines

    post_max_size (default 8M, set this around or slightly greater than your desired post size limit)
    file_uploads (default On, which it needs to be)
    upload_max_filesize (default 2M, set this <= post_max_size)
    max_file_uploads (default 20, but make sure it is >= your desired attachment limit)
    max_execution_time (default 30, consider raising this to 600 or more so that longer tasks arent interrupted)

PHP-fpm - Setup

cd /etc/php/php-fpm.d/

edit these lines

    [pixelfed]
    user = pixelfed
    group = pixelfed
    listen = /run/php/php7.4-fpm-pixelfed.sock

Composer

curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

AS PIXELFED USER

adduser pixelfed
su - pixelfed
git clone -b dev https://github.com/pixelfed/pixelfed.git pixelfed

cd pixelfed
composer install --no-ansi --no-interaction --optimize-autoloader
cp .env.example .env

Complete .env

nano .env

edit these lines

    APP_NAME="Pixelfed Australia"
    APP_DEBUG=false

    APP_URL="https://pixelfed.au"
    APP_DOMAIN="pixelfed.au"
    ADMIN_DOMAIN="pixelfed.au"
    SESSION_DOMAIN="pixelfed.au"

PHP Artisan tasks

#One time only, you need to generate the secret APP_KEY:
php artisan key:generate

#One time only, the storage/ directory must be linked to the application:
php artisan storage:link

#Database migrations must be run:
php artisan migrate --force

#If you want to enable support for location data:
php artisan import:cities

#If you enabled ActivityPub federation:
php artisan instance:actor

#If you enabled OAuth:
php artisan passport:keys

#Routes should be cached whenever the source code changes or whenever you change routes:
php artisan route:cache
php artisan view:cache

#Every time you edit your .env file, you must run this command to have the changes take effect:
php artisan config:cache

### Laravel Horizon - Job queueing
php artisan horizon:install
php artisan horizon:publish

AS ROOT USER

tee /etc/systemd/system/pixelfedhorizon.service <<EOF
[Unit]
Description=Pixelfed task queueing via Laravel Horizon
After=network.target
Requires=mariadb
Requires=php7.4-fpm
Requires=redis
Requires=nginx

[Service]
Type=simple
ExecStart=/usr/bin/php artisan horizon --environment=production
ExecStop=/usr/bin/php artisan horizon:terminate --wait
User=pixelfed
WorkingDirectory=/home/pixelfed/pixelfed/
Restart=on-failure

KillSignal=SIGCONT
TimeoutStopSec=3600

[Install]
WantedBy=multi-user.target

EOF

systemctl daemon-reload
systemctl enable pixelfedhorizon
systemctl status pixelfedhorizon

Crontab for schedule

crontab -e

add this line

* * * * * /usr/bin/php /home/pixelfed/pixelfed/artisan schedule:run >> /dev/null 2>&1

Nginx - Install

apt -y install nginx
systemctl enable nginx

Certbot

apt install certbot python3-certbot-nginx
certbot --nginx -d pixelfed.au -d www.pixelfed.au

Nginx

cp /home/pixelfed/pixelfed/contrib/nginx.conf /etc/nginx/sites-available/pixelfed.conf
ln -s /etc/nginx/sites-available/pixelfed.conf /etc/nginx/sites-enabled/
nano /etc/nginx/sites-available/pixelfed.conf
systemctl reload nginx

"cd /etc/php/php-fpm.d/"

Starting with a vanilla 20.04 installation on DigitalOcean (LTS), the above directory does not exist. There is a 7.4 version qualifier in there.

root@pixelfed:/etc/php# ls
7.4

Forgot to have folks add secretpasswordhere to .env. DB connection effort upon artisan migrate w/out that.

I think you want "cd /etc/php/php-fpm.d/" to read "nano /etc/php/7.4/fpm/php-fpm.conf"

Permissions aren't being set on /home/pixelfed/pixelfed. They need to be.

I had problems running it with a dedicated os level user ( pixelfed ). The problem was that nginx was forbidden to display the uploaded images because of permissions. When changed to www-data ( nginx on ubuntu 22.04 server ) it works as expected.