zoukankan      html  css  js  c++  java
  • CentOS配置服务开机自启

    本例子以nginx作为举例:

    CentOS7中 以systemctl 替代了chkconfig 进行服务的管理,

    默认在CentOS6 中控制服务开机自启,是在vim /etc/rc.d/rc.local 这个文件中控制的,

    在CentOS7 中该服务基于systemctl管理,

    提供rc.local.service, 并通过配置/etc/rc.local该文件进行管理系统启动时完成相关自动任务。

    /usr/lib/systemd/system/rc-local.service 该文件是控制开机自启的配置文件。配置文件如下:

    [Unit]
    Description=/etc/rc.d/rc.local Compatibility
    ConditionFileIsExecutable=/etc/rc.d/rc.local
    After=network.target

    [Service]
    Type=forking
    ExecStart=/etc/rc.d/rc.local start
    TimeoutSec=0
    RemainAfterExit=yes

    [Install]
    WantedBy=multi-user.target

    【Install】为新增内容, multi-user.target 代表3 级别, graphical.target 代表5级别

    赋予该文件权限。

    systemctl enable rc-local

    systemctl status rc-local (查看服务状态)

    Nginx 设置开机自启:

    安装好nginx之后,测试curl localhost  看是否访问正常,

     通过systemctl status nginx.service 可以查看到控制nginx服务是否加载的配置文件路径为:/usr/lib/systemd/system/nginx.service

    然后systemctl enable nginx.service  该命令启动nginx服务

    systemctl is-enabled nginx.service 查看某个软件是否开机自启动

    设置了开机自启后查看状态的截图:

    以上,设置相关服务开机自启。

    systemctl list-unit-files  列出所有可用单元(服务)

    systemctl list-units  列出所有运行中的单元

  • 相关阅读:
    读取库中的所有表名
    ADOX学习
    自己寫的AccessDBHelper
    C#中Split用法~
    SQL Server:查看SQL日志文件大小SQL脚本
    MS SQL2005 How to find the top 50 cpu execution time.
    跨浏览器的本地存储解决方案
    這個SQL 語句你真的看明白了嗎?
    一个简单的SQL最优写法讨论(1)
    Gmail的标签容纳的邮件数量有限制。
  • 原文地址:https://www.cnblogs.com/Enzoo/p/10522652.html
Copyright © 2011-2022 走看看