๐Ÿ††1 โ“1ใ€Ž the metabuilt way ใ€ Profile picture
live true & metabuild // est. '21 // relaunched '25

Apr 18, 2021, 35 tweets

๐—ฆ๐—ฒ๐˜๐˜๐—ถ๐—ป๐—ด ๐—จ๐—ฝ ๐—” ๐—ฅ๐—ฎ๐˜€๐—ฝ๐—ฏ๐—ฒ๐—ฟ๐—ฟ๐˜† ๐—ฃ๐—ถ ๐—ฎ๐˜€ ๐—ฎ๐—ป ๐—จ๐—ฏ๐˜‚๐—ป๐˜๐˜‚ ๐——๐—ฒ๐˜ƒ๐—ฒ๐—น๐—ผ๐—ฝ๐—บ๐—ฒ๐—ป๐˜ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ

A #LearnInPublic & #BuildiInPublic thread

The intention is to have a Raspberry Pi as a dev environment for web / web app & python projects primarily, for these endeavours

I'm going to approach this in my customary haphazard & non-linear fashion

No plan for the thread

Just a document of what I'm doing, as it unfolds

First thing I learned a while ago is that there is some complexity to creating a bootable SD Card for a Pi

I'm not quite sure what that is

A thing I learned today, is that @Raspberry_Pi have created a 'Pi Imager' application to make this bootable SD Card business easier

Great

The next thing I learned is that my Mac is too old to run it

raspberrypi.org/blog/raspberryโ€ฆ

A thing I learned after that, is that there is a tool called Etcher for creating bootable drives, and there is Mac app

Etcher is built on Electron, which is compatible with MacOS 10.10 and above, so I'm alright here, this will install

Dl/d & installed

balena.io/etcher/

I've already downloaded the latest stable version of Ubuntu Server

So apparently what I do is to run Etcher, select the Ubuntu image, and point it at the SD

This makes the SD bootable, but I don't see how it completes the 'headless server' setup by itself (e.g. wifi & ssh?)

Answer is this method does not complete the headless server setup by itself

This will involve connecting up the Pi after this install and completing the setup on the device, rather than having an ideal installer config

Fair enough

Ok, so...

We go:
- Run Etcher
- Select Ubuntu Image

Then:

- Select SD Drive as Target
- Flash (ahaaa!)

(and wait)

Took a couple of minutes or so, and was done

Next will be to connect up the Pi board (it's not tucked up in its case, yet), and continue the config process (probably tomorrow)

Alright

Raspberry Pi kit out

However, I'm gonna try to get the whole headless server setup according to some instructions I've found, so that I won't need to plug this in to a monitor and keyboard to finish the setup

Idea is to set it up and then use it headlessly

Next:

Adding a simple file to the SD card called 'ssh'

Apparently when the Pi finds this file on first boot, it will enable ssh; if it's not there, ssh (a method of logging in remotely and securely via a terminal) will be disabled on first boot

Next, and unconfidently, the final step, is to create another file on the ssd card containing wifi settings

Apparently the Pi, when seeing this file on first boot, will create a permanent wifi profile, and so the theory is I should just be able to log in via ssh straight away

Ok, so now we learn something about the learning process...

That didn't work
And that's ok, 'cos this is learning

So here is a new vid with what seems the correct method of setting these wifi settings on the SD Card in headless Ubuntu on the Pi ๐Ÿ‘‡

Then, there's one final setting which needs to be made: telling the Raspberry Pi to reboot after its initial boot-up and creation of the wifi profile

It'll then reboot, pick up the new wifi profile, and connect to the wifi router, which then makes it discoverable & we can log in

Next up is to insert the SD card into the Pi, and power it on

Then let it boot up, apply the wifi profile, reboot itself, and see if it appears on the network... ๐Ÿ‘‡

So as per the above video, this latest (correct) approach to setting the wifi config worked, and the Pi booted up and was visible on my wifi router

That means I can ssh into the router and complete the basic setup

Bingo!

ssh into the Pi, of course...

next couple of days i'll be deciding what packages to install on the Pi for it to become an effective dev environment

will probably leave it there for now as i'd like to run rest of it through my creative process, which requires a cork wall...

andโ€ฆ. returning to this thread

life had many (mostly unwelcome, some welcome) interruptions since i was last here

however, we resume, and development is, in small way, now underway

onto pi dev environment steps ๐Ÿ‘‡

i'm wanting to move web development off my mac (sort of, apart from the code editor & previewing web sites etc.) and off my nas onto the pi

so the pi will run apache, serve dev sites, run python & other required packages etc

i become more conversant with linux as a result

and i will prob end up scripting the creation of new tech endeavours and putting together a slick dev process, and then can incrementally ship new & changed stuff pretty quickly

this helps me to flit between my creative endeavours and just go where the energy is, and do that

so ok, setup stuff:

next up was to get the pi to see my nas shares, where all my web stuff is, and where git files & python scripts will live

it makes sense to keep files stored on the nas in this way & have the pi serve sites from here, as the nas gets backed up

i can then figure out how to backup key files on the pi and have it re-built easily if necessary

first up then was installing the NFS Client on the pi, and then getting my regular pi user to be able to see & write to those shares

this wasn't easy
pulled my hair out

installing nfs client package easy

initially mounting an NFS share easy enough

but getting permissions right, using the right nfs version & options was the tricky bit for a noob

we did some root squashing and recursive chowning here, ok?

a resource: bytexd.com/installing-nfsโ€ฆ

ooh, i cracked this

didn't like that root squashing business, and wanted my network share to work without it

this meant changing the userid of my regular user account on the pi, so that it is the same id as on the nas

then disabled the root squashing business, and it works ๐Ÿค˜

a nice little resource on changing linux user & group ids, and changing file ownership to those new ids:

cyberciti.biz/faq/linux-chanโ€ฆ

onto setting up Apache on the Pi

easy enough; just a few config tweaks after the install

best resource for this is the ubuntu apache install guide, surprisingly enough

install is a simple: sudo apt install apache2

then i veer from the doc for my setup
ubuntu.com/tutorials/instโ€ฆ

the idea here is to get apache to serve website hosted on my NAS, not on the Pi itself

this is achieved by the previous (slightly confounding) setup of NFS shares & permissions

meaning my requirement was easy to achieve, which was to simply point apache to that shared folder

this is done by setting up a virtual hosts file in the sites-available folder in apache's directory structure

so for each domain and subdomain, a new virtual hosts file is required

this is easyโ€ฆ grab a template, change the server / host name & document locations & save file

in ubuntu land, that vhosts then needs activating, according to the ubuntu apache install doc instructions

- sudo a2ensite yournewvirtualhost.conf

effectively creates a symlink to the conf file in the sites-enabled folder, so apache will see the virtual host

then reload apache

one more step i had to make here, aside from pointing my apache via the vhosts to a network share location, was to change the ip address of the local domain for the site i'm developing to the pi's ip address, in order that apache will serve the website at that address

i do that on my NAS as that device is managing DNS addresses on my network

so the NAS receives DNS queries, directs certain requests for particular domains to the Pi, and the Pi serves the website request using files stored on the NASโ€ฆ

in essence my little dev setup is done for now, in a slightly old-fashioned way (my code editor will push updated files around dev & test subdomains and onto the production server)

and so i'm ready to knock pages/sites up and to explore the numerous unfolding ways in codeโ€ฆ

part of me questions the reason for doing the below when i read that back

2 reasons:

1. the NAS website management interface has become impossibly slow after the last couple of OS updates. whereas it takes me seconds to create a new vhosts file on the Pi

1.1 i can automate new vhosts creation if i wish to

2. the NAS is kinda old and it won't run Docker

so it's only useful for basic network stuff and storing stuff

rest of my dev process needs to be on something newer, and the Pi is more than adequate for serving, packaging etc

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling