首页  >  问答  >  正文

centos7 - centos 7,添加nginx为开机启动?

在vmware11中,安装centos 7 minimal,编译安装的nginx 1.6.3,添加开机启动不知道怎么回事,总是不行啊?

虽然centos 7 是用systemctl管理的了,但是我的mysql与php-fpm都能成功,但是nginx就是不行,不知道要怎样才行,求大神。

phpcn_u1582phpcn_u15822713 天前760

全部回复(4)我来回复

  • 滿天的星座

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

    如果你采用编译安装的方式,直接在/etc/rc.local 增加如下代码即可:

    /usr/local/nginx/sbin/nginx 
    

    前提是你的nginx是安装到/usr/local/nginx 下

    另外,如果使用yum 安装的话,默认是作为服务器,开机自动启动的。可以用chkconfig 查看

    回复
    0
  • 黄舟

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

    如果在centos7中是用yum 安装nginx,在/etc/init.d 是没有它相关的文件的

    直接用systemctl启动就是:

    sudo systemctl enable nginx
    sudo systemctl start nginx
    

    回复
    0
  • PHP中文网

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

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

    回复
    0
  • 大家讲道理

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

    开机自启动Nginx服务:
    sudo systemctl enable nginx.service
    提示:ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'

    回复
    0
  • 取消回复