简体   繁体   English

如何在生产中运行 Laravel Websockets(ubuntu + apache2)?

[英]How to run Laravel Websockets in production (ubuntu + apache2)?

I'm using the Laravel Websockets package https://beyondco.de/docs/laravel-websockets/getting-started/introduction .我正在使用 Laravel Websockets package https://beyondco.de/docs/laravel-websockets/getting-started/

In my local dev server I run it using php artisan websockets:server and it works fine, but I would like to know how can I run it in my production server (Ubuntu + Apache2).在我的本地开发服务器中,我使用php artisan websockets:server运行它,它工作正常,但我想知道如何在我的生产服务器(Ubuntu + Apache2)中运行它。

After run your websocket server, you need proxypass to your apache.运行 websocket 服务器后,您需要代理通行证到您的 apache。 like below config:像下面的配置:

<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName your.domain.com
ProxyPass / http://localhost:6001/
ProxyPassReverse / http://localhost:6001/
</VirtualHost>

change 6001 to your websocket port.将 6001 更改为您的 websocket 端口。

To run in background you need to add your websocket server in backround using nohup or pm2 .要在后台运行,您需要使用 nohup 或pm2在后台添加 websocket 服务器。 example:例子:

pm2 start "php artisan websockets:server"

or using nohup或使用 nohup

nohup php artisan websockets:server

You can use supervisord, you can install and have configuration file to run command php artisan web socket:serve您可以使用 supervisord,您可以安装并拥有配置文件来运行命令 php artisan web socket:serve

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM