Answer the question
In order to leave comments, you need to log in
Need advice on creating a chat (PHP or Node)?
Hello everybody!
At the end of the working Friday afternoon, I decided to ask a question after all.
There is a site on a normal hosting.
There is VPS hosting.
We are trying to create a chat on the site, ideally similar to slack Five Open-Source Slack Alternatives .
But instead of one of the ready-made solutions, colleagues threw their own on node.js + socket.io, so far very primitive, in order to figure it all out.
The rest of the site (authorization) on php + mysql.
Everyone has little experience with this, yesterday I managed to fill in a chat on a VPS, where Apache is already configured.
It turned out that on port 80 we have everything as on a regular hosting, and on port 3000 we have a chat.
Accordingly, you will have to write a page with a chat in node.js completely, additionally solve the problem with authorization ( one of the solutions ).
But it’s more unclear to me what to do with this 3000 port, how to make it display like a regular page and not have problems with those who have this port closed? a solution that I still can't figure out
But they sing to me that it will be a crutch, is it so?
With these thoughts, I began to look for solutions in php. As I understand it, there are two of them:
1) Comet server comet-server.ru
2) php sockets, which are still a dark forest for me. I
came across an article Creating a chat in PHP , github . But I don’t understand if this solution is suitable for our project?
Well, actually questions:
1) Will it be correct that the entire site and logic are in php and mysql, and one page with a chat is in node.js?
If rather yes than no, then:
2) Do we solve the issue with a port other than 80?
3) Is it better to use ready-made solutions (I like lets-chat , but it’s not clear whether we can handle customization) or write our own?
4) If it’s your own (not a bad option, since I really want to understand node.js), then how can messages be organized with a history? Should I use nosql for messages, which one? Maybe membercash? As I understand it, at first everything is stored in Nosql or member, then after a while, it is written in a bunch in mysql and cleaned, in general, here I need an educational program article.
If it would be better to write everything in php:
2) Should I use the chat from the article Creating a chat in PHP ? Is your comet server written here?
3) Is it better to have a third-party comet server or your own?
4) Write everything in mysql, or should I use nosql for messages, which one? Maybe membercash? As I understand it, at first everything is stored in Nosql or member, then after a while, it is written in a bunch in mysql and cleaned, in general, here I need an educational program article.
Thanks in advance for the answers, and sorry for such a big question, I do not have enough experience, knowledge, I will be glad to help.
Other solutions found from toaster answers:
socketo.me/docs/flow
https://github.com/btford/angular-socket-io-seed
https://github.com/kryoz/sociochat
Answer the question
In order to leave comments, you need to log in
A lot of questions. I will answer only regarding the port. Nginx can proxy websocket traffic.
location /wsapp/ {
proxy_pass http://wsbackend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Change the Apache port to any other: /etc/apache2/ports.conf
Open the server JS file on the node through the editor and find server.listen( ... 3000 ... );
Where dots - you understand, everything can be. Change this port and restart node and apache.
Profit
Article on Habré how to make websockets in PHP: https://habrahabr.ru/post/209864/
Ready-made library: https://github.com/morozovsk/websocket (there are also examples and demos of chats and games)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question