Hi, I’m still fairly new to using Balena Cloud but I want to know if it is possible to set up a web server through B. Cloud using a Raspberry Pi 4? I’ve had trouble setting up web servers on my Pi, and I was wondering if using Balena Cloud would be a good solution or not. If possible, could you please link resources or articles/guides I can refer to? Thank you.
Hello Ethan! Yes, it’s very simple to get a working webserver set up on your device with balenaCloud. I’d suggest taking a look at the node hello world example project, which sets up a simple express.js server:
And following this guide for how to get started with balena:
Thanks for linking the article and the GitHub page, but I am running into trouble with accessing my Pi through FTP. I’m using WinSCP and set the hostname as my Pi’s IP address, and the username as “pi” and the password through the password I set through SCP_PASSWORD in Device variables. I connected using both SCP and SFTP with no success. Do I need to enable SSH somehow? Or am I doing something else wrong here?
Hi @ethanic17 – can you let us know exactly how far you’ve gone along in the tutorial? At what step are you running into trouble?
Also, I’m not sure from your message why you’re trying to connect to your Pi through WinSCP. Can you outline what you want to accomplish with this step?
All the best,
So what I’m trying to do is setup a web server using my Raspberry Pi. I’m working on some web projects /websites and want to host the files locally on my Pi. I’m editing those files through my Windows computer and I want to setup remote edit so I can edit them in real-time and easily upload files to my Pi directly from my Windows computer. The Pi would then host the webpages/websites on my local network (and eventually in the future, on the Internet).
However, I am having trouble accessing my files through WinSCP (also I tried FileZilla).
Also, I’m using HTML, CSS, and PHP to edit, but I also plan to use MySQL, so would I have to create a MySQL Server on my Pi as well? I was also looking into LAMP stacks, but I’m not too sure on how I would implement that.
Sorry, if I don’t make too much sense, I’m fairly new to all this so all help is appreciated.
WinSCP and FileZilla are FTP clients that were typically used to upload static files as a deployment method. The Balena Cloud web server example (https://github.com/balena-io-examples/balena-node-hello-world) that my colleague mentioned doesn’t expose an FTP server, therefore connecting to the Pi using FTP would work out of the box.
While its possible to run FTP on the device, I encourage you to adopt a git-based (rather than FTP-based) deployment method, the recommended modern approach in web servers in general, as the static files get embedded into the container and you have a history of what was upload, when, and by who, which you don’t easily get with FTP.
The idea is that you have a git repository like https://github.com/balena-io-examples/balena-node-hello-world with your static files, and every time you want to change something, you edit the static files in the repo, commit your changes, push them, and all done, without needing to bring FTP into the mix. (the getting started guide outlines this approach in more detail: https://www.balena.io/docs/learn/getting-started/raspberrypi3/nodejs/)
I was also looking into LAMP stacks, but I’m not too sure on how I would implement that.
That can definitely be done. The idea is basically to define new containers in your balena cloud applications for i.e. MySQL through a
So what you’re saying is that I setup a repo which I connect to my Pi and then whenever I edit files I would then commit/push them and it’ll automatically update to my Pi? I’m not too familiar with GitHub but would I use like an SSH key or something?
So I would use something like this (article below)? I read through it, but I wasn’t too sure on how to do it inside of a
docker-compose.yml file, like you said.
That is correct Ethan, you’d be using GitHub as your destination for deployments in that model.
In the more traditional approach to Hosting that you were originally pursuing, you would run your services (Apache, MySQL, PHP) in a container, or probably even better is to split them up into 3 containers. Your docker-compose file defines the services (containers) to build, and a Dockerfile in each sub-directory will describe the recipe to follow for building the particular container. Hope that helps!
Ok, thank you, I will try it out over the weekend and update here later on how it goes.