标签 副本 下的文章

Do not bind to a specific port. Instead, bind to port 0:

sock.bind(('', 0))

The OS will then pick an available port for you. You can get the port that was chosen using sock.getsockname()[1], and pass it on to the slaves so that they can connect back.


import socket
from contextlib import closing

def find_free_port():
    with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
        s.bind(('', 0))
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        return s.getsockname()[1]
https://stackoverflow.com/questions/1365265/on-localhost-how-do-i-pick-a-free-port-number

利用 typecho 上传文件(附件)时,提示上传失败。

环境

Ubuntu 16.04
typecho 1.1
PHP7.0
Nginx

失败的原因

  • PHP 限制了上传文件的大小
  • Nginx 限制了上传文件的大小

现目前在网上能够搜索到的信息,90%的都只提到了错误原因是由PHP的配置文件引起的,我看到的就一篇文章(参考文献2)提到了Nginx的问题,并在其文章的帮助使得我将问题有效地解决掉了,在此表示感谢。

- 阅读剩余部分 -