I am creating a Vue app with my roommate and we want to deploy it on our raspberry Pi.
Is there a possibility to npm build our final app on our PC and just start the server on the Pi without having to build the app on the Raspberry? And if so, how can we start the app on the Raspberry?
Thank you in advance!
Totally possible. Build your vue app on your PC (known as development environment) and host it on you raspberry pi (production environment). There multiple ways to do this, but from a high level perspective you just need to:
Set up you pi like normal by installing the preferred OS
SSH into the pi from your PC
Install a webserver. For Vue a quick fix could either be Nginx or Apache
You can install both Node and Git on the webserver through SSH. Then you can git clone the app right into the correct folder. Then with Node installed on the server you can run your npm commands like normal and build the Vue site on the server with npm run build. Otherwise you can just copy your build/dist folder to the server, but then you might need to do some extra configuration.
Get a domain name and point it to your raspberry pi's IP (https://www.noip.com/ is a good free choice I think)
A good list of tutorials to follow is:
How to set up SSH on a raspberri pi
How to set up Nginx or Apache on a raspberri pi
How to deploy a Vue app to a webserver (check both Nginx and Apache). There are some good videos on youtube to check out
Pointing a domain name to my raspberry pi website
NB: One last very important thing to remember is that if you're going to expose your webserver to the internet via your home network (using your own internet at home), you might expose your router to the world, which could enable malicious actors to get into your PC and any other device connected to your network. You might need to think about installing a firewall to prevent this. So maybe check out some research on that too.
Here are some useful links:
https://www.instructables.com/Host-your-website-on-Raspberry-pi/
https://medium.com/#thesabareesh/host-your-own-website-on-a-raspberry-pi-3-e3c8fdb90f90
The result of a vanilla Vue build is a dist directory containing static files.
You can serve them over the network using a static file server: Nginx or Apache for example. The latter I believe is preinstalled in the Raspberry Pi OS and a lot of other distros.
You can also follow this guide as a starting point for Apache.
Also the Vue docs have a page dedicated to deployment.
Related
We want to host the application on IIS server. We need it to support dynamic routing.
We tried downloading IIS node and we're not sure how to proceed.
Is there a file that needs to be loaded and needed to run, such as server.js?
You will need to install nodejs on the host system and have server running on a port, then use IIS as a reverse proxy on top.
This article goes into detailed steps on how to get there - https://alex.domenici.net/archive/deploying-a-node-js-application-on-windows-iis-using-a-reverse-proxy
I am learning node.js in an online course to build up a web server and app
before the teaching started, the teacher told me to set up your coding environment, and it got a direction to told me what to do step by step.
Because I using Chromebook, So I started an aws ec2 serve which is ubuntu 18.04 and using cloud9 for my ide
I installed node.js successful on the ec2
And the direction told me to type on those on the terminal
git clone https://github.com/OpenClassrooms-Student-Center/5614116-front-end-app.git frontend
You can then do the following:
cd frontend
npm install
ng serve
This will install all the dependencies needed by the front end app and will launch the development server. Now, if you navigate to http://localhost:4200 , you should see the following (assuming you've followed the steps above successfully):
the direction say if I successfully followed the step, will see something on http://localhost:4200
On the terminal, at last show me
ℹ 「wdm」: Compiled successfully.
But how can I connect to http://localhost:4200 which was an ec2?
I tried using IP:4200, the browser keeps on loading the page and nothing shows up on the browser
----------------------------------------
I found out that the program that teacher gave me to install set the URL to http://localhost:4200
because cloud9 says the program was running, but running at a URL call http://localhost:4200
what should I do?
Localhost refers to your local machine. But as mentionedd that your node.js running on ec2 and want to connect to it from your browser, get the IP of the ec2 and type in your browser- IP:4200
And it should work
The only problem here is you have to add port 4200 in your aws ec2 instance security group to allow inbound traffic.
STEPS:
1. Go to your EC2 instance.
2. Click security group from Description below.
3. Click Inbound then Edit.
4. Click Add Rule
5. Select Custom TCP , Port - 4200 , IP - 0.0.0.0/0
6. Then SAVE.
After that try <EC2-IP:Port> in your browser it will work fine.
I'm using Sails.js 0.10.5 on Node 0.10.33 on Ubuntu Trusty. I'd like to execute the node process as a non-root user with the least possible privileges in the production environment. I'm comfortable with the various options for binding to ports below 1024 but I'm more concerned with directory permissions.
Ideally, I'd prefer the node process only have write access to its log files and nothing else. It should only have read access to the directory containing app.js and below.
At the moment I have needed to grant write access to the ./.tmp directory and also to the ./views directory due to the grunt tasks that run at startup. I'd rather perform the grunt tasks at deploy time as a different user instead of at run-time. The sails www command appeared promising but I couldn't get the desired outcome.
Can someone please point me in the right direction for running Sails.js with zero write access to its assets, views, etc?
Use sails www to build static assets
chmod -R 440 all files and directories, so that your user and the webserver (group) can access the files.
Use nginx/apache to host a webserver on port 80/443 and proxy requests to sails (running on its own port or over a unix socket).
Run sails using PM2 to keep it running and have it manage/collect logs.
Sails will lift, but will be unable to write its .tmp directory, which shouldn't even be necessary since all your static files will be routed to the www directory through nginx/apache.
The simplest solution to me seems to be to separate the grunt tasks that need the elevated privileges out into a separate file that you can call with a different user on deploy. Then sails won't need to run anything and can be read only.
EDITED: I use PM2 with apache as proxy ( with mod WS ).
You can use one proxy like apache to route from port 80 to others internal server ports based on host.
With this way you can run multiple apps in same server.
It has a lot of usefull functions like see the logs how varius apps in terminal, restart and log crashed apps, run app as user, app status ... etc .
Pm2 link: https://github.com/Unitech/pm2
PM2 configs: https://github.com/Unitech/PM2/blob/development/ADVANCED_README.md#options
My project is a Real Time Two-Player Facebook Game, and what I need is a tool that will help me build the game with quick responses to enable the "Real Time" function of the game. I have just found out about the Node JS and Socket IO. I have some knowledge in JavaScript so I stepped up and watched a few tutorials that discuss the functions of Node JS and Socket IO.
Here's the link to the videos that I have watched:
http://www.youtube.com/watch?v=mSE6xHkcX0w
I understand the basic of the Node JS and Socket IO and successfully installed it in my localhost. The problem is when I uploaded the files from my localhost to my remote server, some functions of the program are not working well. I don't know how to node my JavaScript file when it is on the server, because if it's in my localhost, I am using command prompt to run it.
node app.js
Node is not a web framework.
Chances are, you're using a web host that's generalized for web frameworks like PHP and Ruby on Rails. You're going to need virtual private server hosting, or Node-specific hosting, because Node requires a virtual machine to run. You otherwise won't be able to run Node Package Manager or Node itself.
Joyent has provided a list of hosts here.
If you chose to use a VPS or dedicated machine, an installation guide would be found here. This is how you would install Node on CentOS.
wget http://nodejs.org/dist/v<version>/node-v<version>.tar.gz
tar -zxf node-v<version>.tar.gz
cd node-v<version>
./configure
make -j <number of cores>
make install
Ok so I have read through the Socket.IO docs and I am still a little unsure of a couple of points:
The documentation says...
To run the demo, execute the following:
git clone git://github.com/LearnBoost/Socket.IO-node.git socket.io
cd socket.io/example/
sudo node server.js
Now I don't know what this means at all! I think it may be command line interface. I of course have access to this on my localhost, but my online hosting package is a shared LAMP setup. Meaning I don't have access to the root command line (i think).
How do I actually setup socket.IO, is it impossible on my shared server package?
Appreciate any help...
W.
If you aren't familiar with node.js or with basic command line usage then I would suggest that you use a hosted WebSockets solution like pusherapp. Trying to learn WebSockets, and Node.js, and the Linux command line all at once is going to lead to a lot of frustration. Take a look a pusherapp's quick start guide, it's very easy to get started. You can have 5 simultaneous connections with a single application for free (I'm not affiliated with pusherapp).
Updated (with inline answers to questions):
If you are going to go the direction of running a Socket.IO application:
You don't technically need git since you can download node.js and Socket.IO from their respective download links on github.
You don't actually need a LAMP server to use Socket.IO. By default Socket.IO functions as a simple webserver in addition to a WebSockets server. If you want server side scripting then you might want Apache with mod_php, mod_python, etc.
You don't technically need a dedicated server or even root access. You do need a system where you can have long running process. And if you want the service to start automatically when the system is rebooted, you probably want to add a startup file to /etc/init.d, /etc/rc.d which will require root access. Both node.js and Socket.IO can be installed and run from a normal home directory. If you want to run Socket.IO on a standard port like 80 or 443 then you will need to run it with root privilege.
Node.JS scales quite well so Socket.IO will probably scale pretty well too.
It's not a simple matter to get everything setup and working, but if your goal is a free solution for web serving+WebSockets then Socket.IO is probably is good route to at least explore if you are brave.
First you'll have to determine if your host supports SSH. Sometimes they don't by default on shared hosting, but if you ask they can turn it on. If it does you'll use some sort of SSH client to connect to it. Putty for windows is the most common. Then you'll use git, which is a source control program. Which you'll probably have to install on your host, which may or may not be allowed. If you can, this can be accomplished a number of ways, you'll want to read the git documentation, it will depend largely on what linux distribution you're running. CD is change directory, basic command line stuff. sudo on the last line is telling the system to run the command as root, which it will ask you the password for, which you may not have access to on your host. Sounds like you're gonna have an uphill battle on shared hosting. You may want to opt for a VPS instead.
If your shared host is a LAMP system with no command line access you're not going to get very far with Socket.IO. The instructions you posted assume you have command line access and that you've installed the node.js runtime on your system.
If you really want to try this I recommend you get a VPS of your own (I use prgmr.com) to test it out. For what it's worth I found the Socket.IO platform pretty nice to use once I got it up and running.