如何使用Centos7在生产服务器中部署meteor应用程序

时间:2014-11-21 09:17:12

标签: meteor meteor-up

如何在centos7中部署流星。我们安装了meteor和meteorjs包和nodejs。 但我们无法打开生产链接。请帮助我。

1 个答案:

答案 0 :(得分:5)

  • 首先,您不需要在生产服务器上安装meteor。 Node.js就足够了。
  • 在我的Centos服务器上,我使用nginx + supervisord来运行我的meteor应用程序。
  • 您应该使用“meteor build --directory”命令构建您的应用。使用此命令,您将获得一个bundle目录。压缩该bundle文件夹并将其上传到服务器。实施例

    meteor build --directory <some_path>
    
  • 在服务器上提取,然后

    cd bundle/programs/server
    npm install
    
  • supervisord.conf文件中的示例meteor app config。所有特定于meteor app的配置都在此配置的“环境”变量中。你的supervisord.conf文件中还有其他条目。你必须为你的流星应用程序添加这个。有关supervisord的更多信息,请访问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) 
    
  • 对于nginx配置,这是我关于meteor app的配置(这不是整个配置文件只是流星所需的部分):

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

有关设置nginx的更多详细信息,您可以查看digitalocean文档: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-meteor-js-application-on-ubuntu-14-04-with-nginx

一切都好的时候:

    supervisorctl start all
    service nginx start
  • 我在端口3003上运行meteor app并使用nginx将请求重定向到该端口。您可能希望添加iptables规则以删除到端口3003的连接,以便只有nginx可以连接到端口3003.这里有两个iptables规则来拒绝来自公共网络的mongodb和端口3003连接。

    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
    
相关问题