设置 nginx php-fpm 服务开机自启动

按照我的方法安装的nginx和php-fpm已经是系统服务,可以通过如下的两个命令来启停:

service nginx start
service php-fpm start

那么如何把这两个服务设置为开机自启动呢?真的要像某些人说的,加个什么狗屎的 /etc/init.d 文件进去,然后chkconfig --add nginx ,然后chkconfig nginx --level 35 on  ??????????

这是胡扯的。根本不是这样的,这些只适合非系统服务,山寨服务采用这种方式启动。

只需要试想一下就可以了,centos系统会做的这么脑残么?自己的系统服务,需要写一大堆脚本来启动?不动脑子是不行的。

不信么?运行一下这个命令:chkconfig --list

是不是有这个警告?

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.
      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

这就是告诉说,系统的服务,有人家自己的方式,这里不参与。而且还告诉说,如果你想要看看系统服务列表,那么运行这个命令:

systemctl list-unit-files

没错,这个systemctl就是管理系统服务的。运行人家说的那个服务,你就看到了nginx,php-fpm等等的了。

开启这两个服务的自启动,运行如下命令即可:

systemctl enable nginx.service
systemctl enable php-fpm.service
reboot试试吧。


你可能感兴趣的:(设置 nginx php-fpm 服务开机自启动)