Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2964,"date":"2019-12-30T09:16:45","date_gmt":"2019-12-30T09:16:45","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2964"},"modified":"2019-12-30T09:16:45","modified_gmt":"2019-12-30T09:16:45","slug":"deploy-a-meteor-application-on-ubuntu","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/deploy-a-meteor-application-on-ubuntu\/","title":{"rendered":"Deploy a Meteor Application on Ubuntu"},"content":{"rendered":"

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

$ npm install -g mupx\r\n<\/code><\/pre>\n

After installation is complete, go into your Meteor project folder, e.g.\u00a0\/projects\/myApp<\/code>, and run the following commands:<\/p>\n

$ mkdir .deploy\r\n$ cd $_\r\n$ mupx init\r\n<\/code><\/pre>\n

For those not familiar with the\u00a0$_<\/code>\u00a0syntax, it’s a shortcut for the last argument used in a command. So in this case,\u00a0cd $_<\/code>\u00a0executes as\u00a0cd .deploy<\/code>.<\/p>\n

You will see the following output:<\/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

The initialization process creates two files,\u00a0mup.json<\/code>\u00a0and\u00a0settings.json<\/code>. We’ll leave the latter file alone right now. Go ahead and open up\u00a0mup.json<\/code>. At the time of writing this article, the default\u00a0mup.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

We need to change a few things in order for the setup process to work.<\/p>\n

First, make sure to set\u00a0host<\/code>\u00a0to your VPS IP address, for example:<\/p>\n

\"host\": \"123.123.123.123\",\r\n<\/code><\/pre>\n

If you need to use a port number other than the default 22, you can do so using the\u00a0sshOptions<\/code>\u00a0field, for example:<\/p>\n

\"host\": \"123.123.123.123\",\r\n\"sshOptions\": { \"port\": 9876 },\r\n<\/code><\/pre>\n

Set the\u00a0username<\/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\u00a0pem<\/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\u00a0pem<\/code>\u00a0line entirely, and make sure that your SSH private key is cached in an ssh agent (e.g. on Mac,\u00a0ssh-add <path to ssh private key><\/code>).<\/p>\n

Leave\u00a0setupMongo<\/code>\u00a0set to its default value.<\/p>\n

Change\u00a0appName<\/code>\u00a0to the name of your Meteor app. In our case:<\/p>\n

\"appName\": \"myApp\",\r\n<\/code><\/pre>\n

… and set the location of the app as well, relative to this deployment folder:<\/p>\n

\"app\": \"..\",\r\n<\/code><\/pre>\n

Lastly, set the\u00a0ROOT_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

That’s it! Save the\u00a0mup.json<\/code>\u00a0file, then run:<\/p>\n

$ mupx setup\r\n<\/code><\/pre>\n

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

$ mupx deploy\r\n<\/code><\/pre>\n

Now if you go to\u00a0http:\/\/123.123.123.123<\/code>, your app will show when the page loads.<\/p>\n

Multi-core support<\/h3>\n

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\/projects\/myApp<\/code>), and type:<\/p>\n

$ meteor add meteorhacks:cluster\r\n<\/code><\/pre>\n

Now edit your\u00a0mup.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

Since we’ve added a new package to your app, you’ll have to redeploy.<\/p>\n

$ mupx setup && mupx deploy\r\n<\/code><\/pre>\n

If you ever want to change your environment variables in\u00a0mup.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

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}]}}