Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何将meteor应用程序部署到本地网络中的Ubuntu服务器?_Node.js_Nginx_Meteor_Deployment_Meteor Up - Fatal编程技术网

Node.js 如何将meteor应用程序部署到本地网络中的Ubuntu服务器?

Node.js 如何将meteor应用程序部署到本地网络中的Ubuntu服务器?,node.js,nginx,meteor,deployment,meteor-up,Node.js,Nginx,Meteor,Deployment,Meteor Up,我有一个简单的meteor应用程序,我想让它在本地机器上运行,在我的本地网络上运行Ubuntu和nginx,这样就可以通过浏览器使用机器的本地IP地址访问它。我尝试过使用mup(meteor up),但它需要SSH密钥,而且我必须使用nginx,所以我必须手动部署 如果您能帮助我部署该应用程序,我将不胜感激。只要它运行在nginx上,我就可以使用并尝试不同的方法 我现在不需要SSL,所以我尝试跳过这一步。另外,我的MongoDB服务器将在同一台机器上运行,因此我也尝试在本地访问它。我已经尝试过这

我有一个简单的meteor应用程序,我想让它在本地机器上运行,在我的本地网络上运行Ubuntu和nginx,这样就可以通过浏览器使用机器的本地IP地址访问它。我尝试过使用mup(meteor up),但它需要SSH密钥,而且我必须使用nginx,所以我必须手动部署

如果您能帮助我部署该应用程序,我将不胜感激。只要它运行在nginx上,我就可以使用并尝试不同的方法

我现在不需要SSL,所以我尝试跳过这一步。另外,我的MongoDB服务器将在同一台机器上运行,因此我也尝试在本地访问它。我已经尝试过这个教程,它将永远运行meteor 但我不知道如何运行它,它也没有解释如何配置我的MongoDB URL和其他东西

我已经安装了node,forever&meteor,创建了一个新用户,将我的存储库克隆到我的家庭服务器上,我可以在本地使用“meteor run”命令运行它

我想我在配置nginx和绑定应用程序的脚本时遇到了问题,我在前面的教程中解释了这一点。我不确定在哪里可以找到env_settings.sh文件。它位于我的/etc/nginx/目录中

这是我的nginx配置文件

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
env_settings.sh

#load environment variables
source ../env_settings.sh

meteor update --release 1.11 #ensure proper version of Meteor

npm install # install NPM dependencies
npm prune --production # remove development dependencies

rm -rf ~/bundle # remove the previous bundle

meteor build --directory ~ # build the current bundle

cd ~/bundle/programs/server # enter the bundle
npm install # install dependencies

mv ~/bundle ~/portal 

# make sure the logs directory exists
mkdir ~/logs 

# use forever to restart the Node.js server
export PORT=8080
cd ~/portal
forever stop main.js
forever start -a -l ~/logs/forever.log -o ~/logs/portal.out -e ~/logs/portal.err main.js
站点\u可用/app

# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}
# HTTP
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
        
        location = /favicon.ico {
          root /home/webapp/portal/programs/web.browser/app;
          access_log off;
        }
        
        location ~* "^/[a-z0-9]{40}\.(css|js)$" {
          gzip_static on;
          root /home/webapp/portal/programs/web.browser;
          access_log off;
        }
        
        location ~ "^/packages" {
          root /home/webapp/portal/programs/web.browser;
          access_log off;
        }

        # pass requests to Meteor
        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade; #for websockets
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
        }
}
  • 您应该使用
    node main.js
    运行它,而不是
    main.js

  • 在运行之前,应定义以下环境变量:

    出口端口=8080

    导出根目录URL=http://your.site.name

    导出MONGO_URL=mongodb://127.0.0.1/your.database.name

  • 您应该使用
    node main.js
    运行它,而不是
    main.js

  • 在运行之前,应定义以下环境变量:

    出口端口=8080

    导出根目录URL=http://your.site.name

    导出MONGO_URL=mongodb://127.0.0.1/your.database.name


  • 您可以创建一个
    .service
    文件,这样如果服务停止,它将在Ubuntu中重新启动。以下是一个例子:

    [Unit]
    Description=Meteor app
    
    [Service]
    ExecStart=/usr/bin/node /home/user/meteorapp/bundle/main.js
    User=user
    Group=user
    WorkingDirectory=/home/user/meteorapp/bundle
    Restart=always
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=meteorapp
    Environment=PWD=/home/user/meteorapp/
    Environment=MONGO_URL=mongodb://localhost:27017/meteorapp
    Environment=HTTP_FORWARDED_COUNT=1
    Environment=PORT=8094
    Environment=apiPort=4080
    Environment=ROOT_URL=http://192.168.1.1
    Environment=BIND_IP=127.0.0.1
    Environment='METEOR_SETTINGS={"private": {"key": "value"}}'
    
    [Install]
    WantedBy=multi-user.target
    
    将此文件放入
    /etc/system/systemd
    中,您可以使用
    sudo-service-meteorapp-start
    启动

    如果您在本地运行,则不需要使用nginx。我一直在本地运行meteor应用程序,只需
    meteor
    ,所有设备都可以在内部访问它

    *注意:以上脚本仅在您已经构建meteor应用程序时有效。但我会只运行meteor命令,并以这种方式访问。如果要使用单独的MongoDB数据库,可以创建一个简单的
    /start
    脚本

     export MONGO_URL=mongodb://localhost:27017/meteorapp
     meteor --settings settings.json --port 3004
    

    将该文件设置为可执行文件,这样您就可以在本地运行。

    您可以创建一个
    .service
    文件,这样,如果服务停止,它将在Ubuntu中重新启动。以下是一个例子:

    [Unit]
    Description=Meteor app
    
    [Service]
    ExecStart=/usr/bin/node /home/user/meteorapp/bundle/main.js
    User=user
    Group=user
    WorkingDirectory=/home/user/meteorapp/bundle
    Restart=always
    StandardOutput=syslog
    StandardError=syslog
    SyslogIdentifier=meteorapp
    Environment=PWD=/home/user/meteorapp/
    Environment=MONGO_URL=mongodb://localhost:27017/meteorapp
    Environment=HTTP_FORWARDED_COUNT=1
    Environment=PORT=8094
    Environment=apiPort=4080
    Environment=ROOT_URL=http://192.168.1.1
    Environment=BIND_IP=127.0.0.1
    Environment='METEOR_SETTINGS={"private": {"key": "value"}}'
    
    [Install]
    WantedBy=multi-user.target
    
    将此文件放入
    /etc/system/systemd
    中,您可以使用
    sudo-service-meteorapp-start
    启动

    如果您在本地运行,则不需要使用nginx。我一直在本地运行meteor应用程序,只需
    meteor
    ,所有设备都可以在内部访问它

    *注意:以上脚本仅在您已经构建meteor应用程序时有效。但我会只运行meteor命令,并以这种方式访问。如果要使用单独的MongoDB数据库,可以创建一个简单的
    /start
    脚本

     export MONGO_URL=mongodb://localhost:27017/meteorapp
     meteor --settings settings.json --port 3004
    

    使该文件可执行,您就可以在本地以这种方式运行它。

    我已经用本文中的信息处理了这种情况。它没有运行meteor的捆绑版本,但实际上这是一种更好的方法,可以使它更容易在本地网络上进行测试。

    我已经用本文中的信息处理了这种情况。它没有运行meteor的捆绑版本,但实际上这是一种更好的方法,可以让它更容易在本地网络上测试。

    什么不起作用?什么不起作用?我如何只使用meteor命令就可以做到这一点,这看起来是一个更简单的解决方案,我将在本地运行应用程序而不捆绑,对吗?我也可以把它写成脚本,这样系统就可以在启动时运行它了吗?谢谢你,我对此做了更多的研究,这解决了我的问题。我怎么能只用meteor命令就完成它呢,这看起来是一个更简单的解决方案,我将在本地运行应用程序,而不捆绑,对吗?我也可以把它写成脚本,这样系统就可以在启动时运行了吗?谢谢你,我对此做了更多的研究,这解决了我的问题。