How to deploy workerman to windows server

I have always been curious about php's instant messaging, but I actually don't know how to implement it. Later, I learned about the two artifacts, swoole and workerman, both of which can realize the function of instant messaging. Swoole is a php extension written in C language. It is more troublesome to configure, but the performance is still very powerful. You can search on the official website yourself, and the other is the workerman framework! It is indeed a framework written in php and uses what is in php socket. If it is to arrange the project project to the linux server, I think both can be used, but if you are using the windows server, you will face a difficulty - swoole does not support the windows environment, of course, if you have to arrange it, use docker It should be possible, but I always feel a little nondescript (not that docker is nondescript, docker is really powerful), so what should we do? ? At this time, the advantages of workerman are highlighted! It can run on windows system to download this chat room project

workerman chat room http://www.workerman.net/workerman-chat

Click start_for_win.bat and a black window will appear. Browse http://127.0.0.1:55151 in the browser to see the chat room page! But when we close the black window, we will find that there is nothing when browsing port 55151! When the project is actually deployed, I think this is very insecure, so we have to find a way to implement the daemon process and run this bat file as a windows service. Below I found nssm and use nssm to convert bat into a service

Download the nssm software first, and you can directly search for one on Baidu! After downloading, it is a compressed package. Unzip it and find the 32/64-bit nssm corresponding to your own system (find the nssm under the path in the cmd window) and execute nssm install <service name> For example: nssm install workerman


Then press Enter to appear the configuration interface of nssm, fill in the bat file address in your project in the interface, for example


Click install service, as shown in the figure


When it shows successful, it means that the service has been installed successfully! We can click on My Computer - "Management -" Service to check if this service exists, as shown in the figure, I can already see the service named workerman!


But at this time, browsing http://127.0.0.1:55151 still can’t browse normally, because we haven’t opened the service yet. Next, click the start button in the upper left corner, and browse http://127.0.0.1:55151 after the service is started. You can browse normally! No more annoying black windows! ! You're done! ! ! !


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883033&siteId=291194637