Home  >  Q&A  >  body text

centos7 - centos 7, add nginx to start at boot?

In vmware11, install centos 7 minimal, compile and install nginx 1.6.3, and add boot startup. I don’t know why, but it always doesn’t work?

Although centos 7 is managed with systemctl, my mysql and php-fpm can be successful, but nginx just can’t. I don’t know how to do it. Please ask someone.

phpcn_u1582phpcn_u15822713 days ago761

reply all(4)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 17:25:57

    If you use compilation and installation, just add the following code directly to /etc/rc.local:

    /usr/local/nginx/sbin/nginx 
    

    The premise is that your nginx is installed under /usr/local/nginx

    In addition, if you use yum to install it, it will start automatically as a server by default. You can use chkconfig to check

    reply
    0
  • 黄舟

    黄舟2017-05-16 17:25:57

    If you use yum to install nginx in centos7, there are no related files in /etc/init.d

    Start directly with systemctl:

    sudo systemctl enable nginx
    sudo systemctl start nginx
    

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:25:57

    systemctl enable nginx.service难道不行?会将所有级别生效。或者推荐下载sysv-rc-conf

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:25:57

    Start Nginx service automatically after booting:
    sudo systemctl enable nginx.service
    Tip: ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'

    reply
    0
  • Cancelreply