This article will walk you through deploying your Meteor app to a AKLWEB HOST VPS running Ubuntu 14.04. It may also work on other Linux distributions (attempt at your own risk).<\/p>\n
An ingenious fellow named Arunoda Susiripala, who’s quite active in the Meteor community, has developed a deployment tool called mupx (short for “Meteor Up X”), which makes it extremely easy to deploy your Meteor application to a remote server via ssh. Mupx is the successor to mup. We’ll walk you through the process from start to finish. Mup does most of the heavy lifting, fortunately, so this will be a breeze!<\/p>\n
Our first step is to install mupx. You’ll do this on your development workstation,\u00a0not<\/em>\u00a0your VPS server! Make sure you have Node.js already installed, and run:<\/p>\n After installation is complete, go into your Meteor project folder, e.g.\u00a0 For those not familiar with the\u00a0 You will see the following output:<\/p>\n The initialization process creates two files,\u00a0 We need to change a few things in order for the setup process to work.<\/p>\n First, make sure to set\u00a0 If you need to use a port number other than the default 22, you can do so using the\u00a0 Set the\u00a0 Leave\u00a0 Change\u00a0 … and set the location of the app as well, relative to this deployment folder:<\/p>\n Lastly, set the\u00a0 That’s it! Save the\u00a0 At this point mupx will ssh into your VPS, install Docker, set the environment up, and pull the appropriate Docker images. Now deploy your app:<\/p>\n Now if you go to\u00a0 If your VPS has multiple cores, your Meteor app can take advantage of that. We’ll just have to make a couple quick tweaks.<\/p>\n First, you’ll need to install the cluster package. Go into the folder of your Meteor app (in this example,\u00a0 Now edit your\u00a0 Since we’ve added a new package to your app, you’ll have to redeploy.<\/p>\n If you ever want to change your environment variables in\u00a0 Congratulations, your Meteor app is now up and running! Also, your app will automatically start whenever your VPS reboots. Keep an eye out for future articles on Meteor deployment and management.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[106,242],"manual_kb_tag":[476],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2964"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2964"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2964\/revisions"}],"predecessor-version":[{"id":2965,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2964\/revisions\/2965"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2964"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2964"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}$ npm install -g mupx\r\n<\/code><\/pre>\n
\/projects\/myApp<\/code>, and run the following commands:<\/p>\n
$ mkdir .deploy\r\n$ cd $_\r\n$ mupx init\r\n<\/code><\/pre>\n
$_<\/code>\u00a0syntax, it’s a shortcut for the last argument used in a command. So in this case,\u00a0
cd $_<\/code>\u00a0executes as\u00a0
cd .deploy<\/code>.<\/p>\n
Meteor Up: Production Quality Meteor Deployments\r\n------------------------------------------------\r\nConfiguration file : mup.json\r\nSettings file : settings.json\r\n\r\nEmpty Project Initialized!\r\n<\/code><\/pre>\n
mup.json<\/code>\u00a0and\u00a0
settings.json<\/code>. We’ll leave the latter file alone right now. Go ahead and open up\u00a0
mup.json<\/code>. At the time of writing this article, the default\u00a0
mup.json<\/code>\u00a0looks like this:<\/p>\n
{\r\n \/\/ Server authentication info\r\n \"servers\": [\r\n {\r\n \"host\": \"hostname\",\r\n \"username\": \"root\",\r\n \"password\": \"password\",\r\n \/\/ or pem file (ssh based authentication)\r\n \/\/ WARNING: Keys protected by a passphrase are not supported\r\n \/\/\"pem\": \"~\/.ssh\/id_rsa\"\r\n \/\/ Also, for non-standard ssh port use this\r\n \/\/\"sshOptions\": { \"port\" : 49154 },\r\n \/\/ server specific environment variables\r\n \"env\": {}\r\n }\r\n ],\r\n\r\n \/\/ Install MongoDB on the server. Does not destroy the local MongoDB on future setups\r\n \"setupMongo\": true,\r\n\r\n \/\/ Application name (no spaces).\r\n \"appName\": \"meteor\",\r\n\r\n \/\/ Location of app (local directory). This can reference '~' as the users home directory.\r\n \/\/ i.e., \"app\": \"~\/Meteor\/my-app\",\r\n \/\/ This is the same as the line below.\r\n \"app\": \"\/path\/to\/the\/app\",\r\n\r\n \/\/ Configure environment\r\n \/\/ ROOT_URL must be set to your correct domain (https or http)\r\n \"env\": {\r\n \"PORT\": 80,\r\n \"ROOT_URL\": \"http:\/\/myapp.com\"\r\n },\r\n\r\n \/\/ Meteor Up checks if the app comes online just after the deployment.\r\n \/\/ Before mup checks that, it will wait for the number of seconds configured below.\r\n \"deployCheckWaitTime\": 15,\r\n\r\n \/\/ show a progress bar while uploading. \r\n \/\/ Make it false when you deploy using a CI box.\r\n \"enableUploadProgressBar\": true\r\n}\r\n<\/code><\/pre>\n
host<\/code>\u00a0to your VPS IP address, for example:<\/p>\n
\"host\": \"123.123.123.123\",\r\n<\/code><\/pre>\n
sshOptions<\/code>\u00a0field, for example:<\/p>\n
\"host\": \"123.123.123.123\",\r\n\"sshOptions\": { \"port\": 9876 },\r\n<\/code><\/pre>\n
username<\/code>\u00a0value to whatever user you want to own your Meteor app’s installation. I recommend removing the password line and using an SSH key instead, for security purposes. Uncomment the line with the\u00a0
pem<\/code>\u00a0value and make sure it points to your SSH secret key that corresponds with the SSH public key you’ve installed on your VPS (in\u00a0
\/root\/.ssh\/authorized_keys<\/code>). Make sure to add a comma after the password line! If your SSH key has a passphrase attached to it, remove the\u00a0
pem<\/code>\u00a0line entirely, and make sure that your SSH private key is cached in an ssh agent (e.g. on Mac,\u00a0
ssh-add <path to ssh private key><\/code>).<\/p>\n
setupMongo<\/code>\u00a0set to its default value.<\/p>\n
appName<\/code>\u00a0to the name of your Meteor app. In our case:<\/p>\n
\"appName\": \"myApp\",\r\n<\/code><\/pre>\n
\"app\": \"..\",\r\n<\/code><\/pre>\n
ROOT_URL<\/code>\u00a0to the designated URL for your app. Explicitly set a port number to the standard HTTP port.<\/p>\n
\/\/ Configure environment\r\n\"env\": {\r\n \"ROOT_URL\": \"http:\/\/myapp.com\",\r\n \"PORT\": 80\r\n},\r\n<\/code><\/pre>\n
mup.json<\/code>\u00a0file, then run:<\/p>\n
$ mupx setup\r\n<\/code><\/pre>\n
$ mupx deploy\r\n<\/code><\/pre>\n
http:\/\/123.123.123.123<\/code>, your app will show when the page loads.<\/p>\n
Multi-core support<\/h3>\n
\/projects\/myApp<\/code>), and type:<\/p>\n
$ meteor add meteorhacks:cluster\r\n<\/code><\/pre>\n
mup.json<\/code>\u00a0file and modify the environment variable section like so:<\/p>\n
\/\/ Configure environment\r\n\"env\": {\r\n \"ROOT_URL\": \"http:\/\/myapp.com\",\r\n \"PORT\": 80,\r\n \"CLUSTER_WORKERS_COUNT\": \"auto\"\r\n},\r\n<\/code><\/pre>\n
$ mupx setup && mupx deploy\r\n<\/code><\/pre>\n
mup.json<\/code>\u00a0without having to deploy the whole app, simply use the reconfigure command. This is useful when there were no application changes made.<\/p>\n
$ mupx reconfig\r\n<\/code><\/pre>\n