Contents

How to Install, Configure and Deploy a Meteor.js App on Ubuntu 16.04

How to Install, Configure and Deploy a Meteor.js App on Ubuntu 16.04
How to Install, Configure and Deploy a Meteor.js App on Ubuntu 16.04
  MeteorJS or simply Meteor is an open-source framework based on JavaScript. It was made with Node.js and it allows you to build apps for every device(e.g web, iOS, Android, or Desktop) using the same code. In the following tutorial we will teach you how to deploy a simple Meteor application on a Linux VPS running Ubuntu 16.04 as an operating system. Begin by connecting to your linux server via SSH and install the MeteorJS framework by executing the following command:
sudo curl https://install.meteor.com/ | sh
This should install the latest official Meteor release on your Ubuntu VPS. If you receive the error message below when you execute the installation command:
-bash: curl: command not found
This means you don’t have curl on your server. In order to install the package, use the commands below:
sudo apt-get update

sudo apt-get install curl
After curl is installed, you may execute the installation command once more for MeteorJS and then get the Meteor framework installed. It should take several minutes for the installation procedure to be done, but after it’s finished, you may confirm that the installation is successfully by checking the Meteor version:
meteor --version
This will give you an output very similar to this one:
$ meteor --version

Meteor 1.4.3.2
Once you use the meteor command for the first time, it should be a couple of seconds for Meteor to be set up in your user’s home directory. Now you should be prepared to create your first MeteorJS application. Go to your home directory:
cd ~
Next, execute the command below:
meteor create firstApp
The application should be set up instantly. To run the application, enter the following commands:
cd firstApp

meteor
Ensure that you receive no errors in the output. It will be similar to the one below:
$ meteor

[[[[[ ~/firstApp ]]]]]



=> Started proxy.

=> Started MongoDB.

=> Started your app.



=> App running at: http://localhost:3000/
Since the application is running on port 3000 and it is accessible from the local machine only. In order to make it accessible using a domain name you may set up Nginx as a reverse proxy on your Meteor VPS. Begin by installing Nginx, then set up a server block. Append the following lines to the Nginx server block for your Meteor application.
upstream meteor {

server 127.0.0.1:3000;

}



server {

listen      80;

server_name your_domain;



access_log  /var/log/nginx/meteor.access.log;

error_log   /var/log/nginx/meteor.error.log;



proxy_buffers 16 64k;

proxy_buffer_size 128k;



location / {

proxy_pass  http://meteor;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

proxy_redirect off;



proxy_set_header    Host            $host;

proxy_set_header    X-Real-IP       $remote_addr;

proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header    X-Forwarded-Proto https;

}

}
Swap your_domain with your actual domain name. Save and close the file, then make sure that there are no errors:
sudo nginx -t
If there are absolutely no errors, you can restart nginx:
sudo systemctl restart nginx.service
Now, restart your Meteor application and then open up your web browser of choice. You will be able to access the Meteor application you have just deployed using your domain name. If you receive the welcome screen it means your Meteor application is successfully deployed. To start building real applications with MeteorJS you can check the tutorials at https://www.meteor.com/tutorials
Updated on 05 Mar 2018
0 Comments
Add a comment
Login for Comment