💾 Archived View for snowcode.ovh › tech › postmill.gmi captured on 2022-04-29 at 12:19:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

How to install Postmill on Debian

Step 1: Requirements

Here are the few requirements to have to install Postmill.

sudo apt install php php-curl php-gd php-iconv php-intl php-mbstring php-pgsql php-xml php-tokenizer
sudo apt install postgresql
sudo apt install composer 
# Download node in /usr/local and link the binaries
sudo su
cd /usr/local
wget <url to node>
tar xvf *.tar.*
rm *.tar.*
mv node*/ node/
ln -s /usr/local/node/bin/* /usr/bin

# Install yarn
npm install -g yarn

Step 2: Download and install Postmill

1. Let's download postmill using git into the /var/www dir

cd /var/www
git clone https://gitlab.com/postmill/Postmill.git
cd Postmill

Now let's build the assets (yarn)

yarn install 
yarn run build-prod

Then setup the backend

composer install
# or run this if you use PHP8
compose install --ignore-platform-reqs

THen check your configuration

vendor/bin/requirements-checker

Step 3: Setup the database

Create a user for postmill:

sudo -u postgres createuser -P postmill
# what ever password you want to setup for the db

Create a database

sudo -u postgres createdb -O postmill postmill

Step 4: Setup postmill

Into the directory and start configuring:

cd /var/www/Postmill/
nano .env

In it, change "db_user" to "postmill", "db_password" to your password, and "db_name" to "postmill". You might also want to remove the "?serverVersion=X.y"

Change APP_ENV to prod and add some password in "APP_SECRET"

Now migrate the database

bin/console doctrine:migrations:migrate

Then run postmill

php -S 127.0.0.1:8000 -t public

Step 5: Making a service file

Now we can make a service file to run it in the background:

nano /etc/systemd/system/postmill.service

Paste the following config:

[Unit]
Description=Postmill
After=network.target

[Service]
Restart=always
RestartSec=1
WorkingDirectory=/var/www/Postmill
ExecStart=php -S 127.0.0.1:8000 -t public

[Install]
WantedBy=multi-user.target

Then start it

sudo systemctl start postmill

Step 6: Configure nginx

Now you can create a nginx config file as following one. Make sure you have some HTTPS cert ready for this and replace "sub.domain.tld" by your domain name.

sudo apt install letsencrypt
sudo systemctl stop nginx
sudo certbot certonly --standalone -d sub.domain.tld
sudo systemctl start nginx

Here's the config to paste and modify in /etc/nginx/sites-available/postmill.conf

server {
	listen 80;
	listen [::]:80;

	server_name sub.domain.tld;

	return 301 https://sub.domain.tld$request_uri;
}

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	location / {
		proxy_pass http://127.0.0.1:8000;

	    proxy_set_header Host $host;
    	proxy_set_header Connection       $http_connection;
	    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
    	proxy_set_header X-Scheme         $scheme;
	    proxy_buffering                   off;
	}

	include /etc/nginx/snippets/letsencrypt.conf;

	server_name sub.domain.tld;

	ssl_certificate /etc/letsencrypt/live/sub.domain.tld/fullchain.pem;
	ssl_certificate_key /etc/letsencrypt/live/sub.domain.tld/privkey.pem;
	ssl_trusted_certificate /etc/letsencrypt/live/sub.domain.tld/fullchain.pem;

	access_log /var/log/nginx/sub.domain.tld.access.log;
	error_log /var/log/nginx/sub.domain.tld.error.log;
}

Then enable the file and reload nginx

ln -s /etc/nginx/sites-available/postmill.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Postmill should now be accessible on your domain name.