Express应用程序中端口3000的意义
我注意到Express.js应用程序的几乎所有示例都使用端口3000作为HTTP服务器的默认侦听端口.仅仅是因为它是一个很少使用的端口,还是这个端口号有其他原因吗?
I noticed that almost all examples of Express.js applications use port 3000 as the default listening port for HTTP servers. Is this just because it's a rarely used port, or is there any other reason for this port number?
如果我要在本地计算机上并行运行多个应用程序,使用3000、3001、3002等端口是否是一种好习惯?
If I want to run multiple apps side-by-side on my local machine, is it good practice to use ports like 3000, 3001, 3002, etc.?
(我知道,理想情况下,您应该让系统分配端口.这只是一个简单的问题,为什么3000似乎是常规分配.)
(I understand that ideally, you'd let the system assign ports. This is just a question as a matter of simplicity, and why 3000 seems to be a conventional assignment.)
3000
是选择的某种任意端口号,因为它允许您在没有root访问权限(提升权限)的情况下尝试使用express
.端口80和443是默认的HTTP和HTTPS端口,但在大多数环境中它们要求提升的特权.
3000
is a somewhat arbitrary port number chosen because it allows you to experiment with express
without root access (elevated privilege). Ports 80 and 443 are the default HTTP and HTTPS ports but they require elevated privilege in most environments.
在示例中使用端口3000还可以间接强调您理想情况下希望将您的express
应用程序放置在nginx
或Apache httpd
或类似的可以监听端口80和/或443的内容之后.
Using port 3000 in examples also helps indirectly emphasize that you ideally want to put your express
app behind nginx
or Apache httpd
or something like that which would listen on port 80 and/or 443.
(无论如何,我没有理由)为什么3000比8000或4000或8080或任何其他没有提升特权的端口号要好.
There is no reason (that I'm aware of, anyway) why 3000 is better than 8000 or 4000 or 8080 or any of a number of other port numbers that are accessible without elevated privileges.