【问题标题】:How to deploy meteor app in production server using Centos7如何使用 Centos7 在生产服务器中部署流星应用程序
【发布时间】:2015-01-19 09:22:21
【问题描述】:

centos7如何部署meteor。我们安装了meteor和meteorjs包和nodejs。 但是我们无法打开制作链接。请帮助我。

【问题讨论】:

    标签: meteor meteor-up


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

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

      cd bundle/programs/server
      npm install
      
    • supervisord.conf 文件中的示例流星应用程序配置。所有流星应用程序特定的配置都在此配置的“环境”变量中。您的 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 配置,这是我关于流星应用程序的配置(这不是整个配置文件,只是流星所需的部分):

          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 上运行流星应用程序,并使用 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
      

    【讨论】:

    • 我听从了你的回答,谢谢。但现在,我想在另一个位置运行我的流星应用程序,例如 /app。但是当我更改 location /app {...} 时,它会向我显示我的应用程序的 404 页面。一个主意?谢谢
    猜你喜欢
    • 2015-04-23
    • 2015-08-21
    • 2017-04-04
    • 2015-05-17
    • 1970-01-01
    • 2013-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多