How to deploy meteor app on production server using Centos7

How to deploy meteor in centos7 We have installed meteor and meteor packages and nodes. But we cannot open the production link. Please help me.

+3


source to share


1 answer


  • First of all, you don't need to install Meteor on your production server. Node.js is enough.
  • On my Centos server, I am using nginx + supervisord to run my meteor application.
  • You have to build your application using the meteor build --directory command. With this command you will get the package directory. Compress this folder and upload it to the server. Example

    meteor build --directory <some_path>
    
          

  • Extract to server then

    cd bundle/programs/server
    npm install
    
          

  • An example of a meteor application configuration in the supervisord.conf file. All the specific configuration of the meteor application is used in the "environment" variable in this configuration. Other entries appear in your supervisord.conf file. You will need to add this for your meteor app. For more information on the supervisor, visit http://supervisord.org

    [program:my-meteor-app]
    command=node main.js              ; the program (relative uses PATH, can take args)
    directory=/home/path_where_bundle_is/bundle
    process_name=%(program_name)s ; process_name expr (default %(program_name)s)
    numprocs=1                    ; number of processes copies to start (def 1)
    autostart=true                ; start at supervisord start (default: true)
    autorestart=unexpected        ; whether/when to restart (default: unexpected)
    user=app_user                   ; setuid to this UNIX account to run the program
    redirect_stderr=true          ; redirect proc stderr to stdout (default false)
    stdout_logfile=/var/log/meteor.log        ; stdout log path, NONE for none; default AUTO
    stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)
    ;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stdout_events_enabled=false   ; emit events on stdout writes (default false)
    stderr_logfile=/var/log/meteor_err.log        ; stderr log path, NONE for none; default AUTO
    stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)
    stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)
    ;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)
    ;stderr_events_enabled=false   ; emit events on stderr writes (default false)
    environment=PORT="3003", ROOT_URL="https://your_url",MAIL_URL="smtp://xxx:xxx@smtp.mailgun.org:25",MONGO_URL="mongodb://xxx:xxx@localhost/databasename"       ; process environment additions (def no adds)
    ;serverurl=AUTO                ; override serverurl computation (childutils) 
    
          

  • For the nginx config, this is my config relative to the meteor app (this is not the whole config file, just the part meteor needs):

        location / {
       proxy_pass http://localhost:3003/;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_http_version 1.1;
    }
    
          

For more details on setting up nginx, you can check the digitalocean documentation: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-meteor-js-application-on-ubuntu-14-04- with-nginx

When everything is ok:



    supervisorctl start all
    service nginx start

      

  • I am running a meteor application on port 3003 and forwarding requests to that port using nginx. You might want to add an iptables rule to remove connections on port 3003 so that only nginx can connect to port 3003. Here are two iptables rules to deny mongodb and port 3003 connections from public networks.

    iptables -A INPUT -i eth0 -p tcp -m tcp --dport 27017 -j DROP
    iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3003 -j DROP
    
          

+5


source







All Articles