将脚本 nginx 复制到 /etc/init.d 目录下,然后执行下面的脚本 for CentOS chkconfig nginx on for Ubuntu sudo update-rc.d nginx defaults 99