How to deploy a meteor application to my own server?

后端 未结 6 902
灰色年华
灰色年华 2020-11-30 17:27

How to deploy a meteor application to my own server?

flavour 1: the development and deployment server are the same;

flavour 2: the development server is one

6条回答
  •  [愿得一人]
    2020-11-30 17:43

    I done with it few days ago. I deployed my Meteor application to my own server on the DigitalOcean. I used Meteor Up tool for managing deploys and Nginx on the server to serve the app.

    It's very simple to use. You should install meteor up with the command:

    npm install -g mup
    

    Then create the folder for deployment configuration and go to the created directory. Then run mup init command. It will created two configuration files. We are have interest for mup.json file. It have configurations for deployment process. It's looks like this:

    {
      // Server authentication info
      "servers": [
        {
          "host": "hostname",
          "username": "root",
          "password": "password",
          // or pem file (ssh based authentication)
          //"pem": "~/.ssh/id_rsa",
          // Also, for non-standard ssh port use this
          //"sshOptions": { "port" : 49154 },
          // server specific environment variables
          "env": {}
        }
      ],
    
      // Install MongoDB on the server. Does not destroy the local MongoDB on future setups
      "setupMongo": true,
    
      // WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
      "setupNode": true,
    
      // WARNING: nodeVersion defaults to 0.10.36 if omitted. Do not use v, just the version number.
      "nodeVersion": "0.10.36",
    
      // Install PhantomJS on the server
      "setupPhantom": true,
    
      // Show a progress bar during the upload of the bundle to the server.
      // Might cause an error in some rare cases if set to true, for instance in Shippable CI
      "enableUploadProgressBar": true,
    
      // Application name (no spaces).
      "appName": "meteor",
    
      // Location of app (local directory). This can reference '~' as the users home directory.
      // i.e., "app": "~/Meteor/my-app",
      // This is the same as the line below.
      "app": "/Users/arunoda/Meteor/my-app",
    
      // Configure environment
      // ROOT_URL must be set to https://YOURDOMAIN.com when using the spiderable package & force SSL
      // your NGINX proxy or Cloudflare. When using just Meteor on SSL without spiderable this is not necessary
      "env": {
        "PORT": 80,
        "ROOT_URL": "http://myapp.com",
        "MONGO_URL": "mongodb://arunoda:fd8dsjsfh7@hanso.mongohq.com:10023/MyApp",
        "MAIL_URL": "smtp://postmaster%40myapp.mailgun.org:adj87sjhd7s@smtp.mailgun.org:587/"
      },
    
      // Meteor Up checks if the app comes online just after the deployment.
      // Before mup checks that, it will wait for the number of seconds configured below.
      "deployCheckWaitTime": 15
    }
    

    After you fill all data fields you can start the setup process with command mup setup. It will setup your server.

    After sucessfull setup you can deploy your app. Just type mup deploy in the console.

提交回复
热议问题