如何在CentOS 7上部署Rocket.Chat(2)

[Service]
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocket
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://linuxidc.com:3000/ PORT=3000
ExecStart=/usr/local/bin/node /opt/rocket/Rocket.Chat/main.js

[Install]
WantedBy=multi-user.target

通知systemd我们创建了一个新的单元文件并通过执行以下命令启动Rocket.Chat服务:

sudo systemctl daemon-reload
sudo systemctl start rocketchat

您可以使用以下命令检查服务状态:

sudo systemctl status rocketchat

示例输出:

● rocketchat.service - Rocket.Chat server
  Loaded: loaded (/etc/systemd/system/rocketchat.service; enabled; vendor preset: disabled)
  Active: active (running) since Tue 2018-04-10 20:30:56 UTC; 8s ago
 Main PID: 32356 (node)
  CGroup: /system.slice/rocketchat.service
          └─32356 /usr/local/bin/node /opt/rocket/Rocket.Chat/main.js

如果没有错误,您可以启用Rocket.Chat服务在启动时自动启动:

sudo systemctl enable rocketchat

如何在CentOS 7上部署Rocket.Chat

使用Nginx设置反向代理

如果您遵循了我们如何在CentOS 7上安装Nginx,以及如何在CentOS 7指南上使用Let's Encrypt来保护Nginx,则您应该已经安装并配置了带有SSL证书的Nginx。 现在我们只需要为我们的Rocket.Chat安装创建一个新的服务器块。

/etc/nginx/conf.d/linuxidc.com.conf

如何在CentOS 7上部署Rocket.Chat

upstream rocketchat_backend {
  server 127.0.0.1:3000;
}

server {
    listen 80;
    server_name linuxidc.com ;

include snippets/letsencrypt.conf;
    return 301 https://linuxidc.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name ;

ssl_certificate /etc/letsencrypt/live/linuxidc.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/linuxidc.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/linuxidc.com/chain.pem;
    include snippets/ssl.conf;

return 301 https://linuxidc.com$request_uri;
}

server {
    listen 443 ssl http2;
    server_name linuxidc.com;

ssl_certificate /etc/letsencrypt/live/linuxidc.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/linuxidc.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/linuxidc.com/chain.pem;
    include snippets/ssl.conf;

access_log /var/log/nginx/linuxidc.com-access.log;
    error_log /var/log/nginx/linuxidc.com-error.log;

location / {
        proxy_pass ;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/ebaa8bb1ccbfa59ad8a40f9f511703c9.html