Categories
Servers

Updating Node on a Forge VPS

Forge publish a cookbook recipe for that here. The problem I had was my site uses website isolation, and that user didn’t have sudo access.

I was able to upgrade node (to v20 at the time of writing) by logging into the server as the root user. Ran the commands that Forge suggests, but without sudo since we were already root.

apt-get update --allow-releaseinfo-change &&  apt-get install -y ca-certificates curl gnupg

mkdir -p /etc/apt/keyrings

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |  gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20

echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" |  tee /etc/apt/sources.list.d/nodesource.list

apt-get update --allow-releaseinfo-change &&  apt-get install nodejs -y

That version of node seems to have flowed through to my isolated website user.

Categories
DevOps Servers

Envoyer Deployments

Update: build is passing. Now configure Envoyer to not deploy on push, but instead wait for webhook call from Chipper CI.


Not yet working for HadCoffee staging site. The clone and setup fails because ‘mike’ user that I am connecting with needs to use sudo to interact with the www-data files. Envoyer doesn’t sudo the commands.

Not sure if my Ubuntu users are incorrect, or if Envoyer should be using a different user that can do its work without sudo. Probably the latter.


Changed project to be owned and group of mike, which Envoyer uses. Now it can deploy.

I did have to manually make storage (symlinked) belong to www-data so Nginx can write there.

Now just need npm/node to work. I really don’t know why it isn’t, but it’s stopping me from building the CSS & JS.


npm install worked now that it’s owned by mike.

Potential remaining issues to test with future deployments:

  • Do Frontend assets build now?
  • Is .env maintained? Was I right to create the file?
  • Are file uploads, and S3 push working?

General question: How do DB migrations work in production?

Categories
Servers

Certbot Renewal failing well-known challenge

In my case when I added the domain for LetsEncrypt I forgot /public from the Laravel path. Registration worked for some reason (?), but renewal a few months later failed.

I updated /etc/letsencrypt/renewal/*.conf and changed the path to /public and it worked.

Categories
Servers

SCP with PEM key

If you’re using a non-default key to SSH into a server SCP will need an extra argument to connect and upload the file.

scp -i TheOtherKey.pem localfile.zip user@example.com:/var/www/uploadedfile.zip 

Categories
Servers

Changing PHP Upload limit on my Binary Lane VPS

php.ini is at /etc/php/7.3/fpm/php.ini

Change max_upload and post_max sizes (not their exact name, do a search for current value).

Restart PHP with this command:

service php7.3-fpm restart
Categories
Servers

503 Bad Gateway on Ubuntu Server

Rebooted Ubuntu web server and PHP-FPM wasn’t running.
Just needed the old:

service php7.3-fpm start
Categories
Servers

Remove Non-Empty Directory

rm -rf my_directory_name

Be careful.

Categories
Servers

MySQL Create User and Grant Privileges

GRANT ALL PRIVILEGES ON mydatabase.* TO 'my_new_user'@'localhost' IDENTIFIED BY 'a great password';

Creates user and gives them privileges at once. Probably follow up with FLUSH PRIVILEGES

Categories
Servers

Moving Site Off Nginx

When you move a website and change its DNS A record you will need to delete it from the old Nginx server. Otherwise when Nginx reboots (e.g. after a certificate renewal) it will fail DNS resolution.

I believe this can be changed, but by default Nginx will break when the DNS connection (even of an unrelated site) changes.

Categories
Servers

.htaccess force SSL

[code]RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L][/code]

From inMotion Hosting