Create a dedicated Apache directory for a virtual host:
sudo mkdir -p /www
sudo mkdir -p /www/pixelfed.fediverse.ovh
sudo chmod -R 755 /www
Edit a new file:
sudo nano /etc/apache2/sites-available/pixelfed.fediverse.ovh.conf
And paste these lines:
<VirtualHost *:80>
ServerName pixelfed.fediverse.ovh
DocumentRoot /usr/share/webapps/pixelfed/public
<Directory /usr/share/webapps/pixelfed/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/pixelfed-fediverse-ovh.error.log
CustomLog ${APACHE_LOG_DIR}/pixelfed-fediverse-ovh.access.log combined
# Send requests for PHP files to the PHP-FPM socket
ProxyPassMatch "^/(.*\.php(/.*)?)$" "unix:/run/php-fpm/pixelfed.sock|fcgi://localhost/usr/share/webapps/pixelfed/public/
</VirtualHost>
Save and exit Nano.
Enable the virtual host an disable the default Apache website:
sudo a2ensite pixelfed.fediverse.ovh.conf
sudo a2dissite 000-default.conf
Restart apache2 service:
sudo systemctl restart apache2