可能问题表述上不对,是这样的:现在有一个阿里云的服务器,环境搭好了apache+mysql+php,但我没有用php,又装了nodejs,写了点东西,listen3000端口 也可以用。
但是每次访问都要先 执行一次 nodejs app.js,这个3000端口才能访问。
怎么做才能向 80端口一样 ,不用执行什么语句随时都可以访问呢? 或者 只要输入:地址:3000 就可以一直访问也行,怎么做呢?
找了很多地方,nodejs的讲解 都是 到http://localhost:8000 就不讲了,linux的 改端口 重新运行 httpd也没有用,又看到什么阿里云服务器 有 aliyundun 所以不好改。。
求指点
天蓬老师2017-04-17 13:31:12
Executing node app.js should start the node.js service and let it listen on port 3000.
You need to execute it every time because you do not keep the node process running.
One of the easiest ways is to use nohup to start:
nohup node app.js &
(the & background running behind).
It can also be run on screen.
You can also use supervisor or forever.
It’s simple, I recommend trying it with forever. Look at this: https://cnodejs.org/topic/5021c2cff767cc9a51e684e3
天蓬老师2017-04-17 13:31:12
The reason why port 80 can always be accessed is because you installed apache, which has been silently listening to port 80.
So, it doesn’t matter which port you use node to listen to, the key is to make it run