错误的原因就是没有添加nginx服务,所以启动失败。

解决方法:

1. 在/root/etc/init.d/目录下新建文件,文件名为nginx

  或者用命令在根目录下执行:# vim /etc/init.d/nginx (注意vim旁边有一个空格)

2. 插入以下代码

#!/bin/sh
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15# description:  Nginx is an HTTP(S) server, HTTP(S) reverse
#               proxy and IMAP/POP3 proxy server# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0nginx="/usr/local/nginx/sbin/nginx"prog=$(basename $nginx)NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"lockfile=/var/lock/subsys/nginxstart() {[ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6echo -n $"Starting $prog: "daemon $nginx -c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval}stop() {echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retval}restart() {configtest || return $?stopstart}reload() {configtest || return $?echo -n $"Reloading $prog: "killproc $nginx -HUPRETVAL=$?echo}force_reload() {restart}configtest() {$nginx -t -c $NGINX_CONF_FILE}rh_status() {status $prog}rh_status_q() {rh_status >/dev/null 2>&1}case "$1" instart)rh_status_q && exit 0$1;;stop)rh_status_q || exit 0$1;;restart|configtest)$1;;reload)rh_status_q || exit 7$1;;force-reload)force_reload;;status)rh_status;;condrestart|try-restart)rh_status_q || exit 0;;*)echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"exit 2esac

3. 用命令进入此目录

cd /etc/init.d

4. 依此执行以下命令

chmod 755 /etc/init.d/nginx

chkconfig --add nginx (注意add前面是两个短横线-)

5. 开启nginx

service nginx start

nginx reload命令_nginx:Failed to start nginx.service:unit not found相关推荐

  1. Failed to restart docker.service: Unit is masked.真正的解决办法

    启动docker时报错 [root@localhost deployScript]# systemctl restart docker Failed to restart docker.service ...

  2. Centos7 Failed to start xxx.service: Unit not found

    Centos7 Failed to start xxx.service: Unit not found 一.查看 systemctl list-unit-files --type=service // ...

  3. CentOS 7报错:Failed to start xxx.service: Unit is masked

    如果开启服务的时候遇到Failed to start xxx.service: Unit is masked. 意识是这个服务锁定了,可执行如下命令开启: systemctl unmask xxx.s ...

  4. Failed to start mongod.service: Unit mongod.service not found

    Failed to start mongod.service: Unit mongod.service not found sudo systemctl enable mongod sudo serv ...

  5. 【Linux - mysql】linux下mysql报Failed to restart mysqld.service: Unit not found

    笔者使用 service mysqld restart 重启mysql服务的时候,报了Failed to restart mysqld.service: Unit not found 估计也就是服务名 ...

  6. mysqld服务启动失败, Failed to restart mysqld.service: Unit not found.

    mysqld服务启动失败, Failed to restart mysqld.service: Unit not found. -bash-4.2# service mysqld restart Re ...

  7. Failed to start mongod.service: Unit not found

    其实自己用惯的是MYSQL,然后项目最后一步完善数据读写的部分,本来打算用mysql的,然而在centOS系统上发现安装总是出问题,后来查找一下资料,发现centOS系统上一般用的是Mariadb,这 ...

  8. 【已解决】Failed to start cron.service: Unit cron.service not found.

    问题 输入sudo service cron start 重启下cron服务,报错: Failed to start cron.service: Unit cron.service not found ...

  9. Failed to start firewalld.service: Unit is masked

    centos7 启动防火墙失败:Failed to start firewalld.service: Unit is masked. 解决: 执行" systemctl start fire ...

最新文章

  1. 分享3个好用到爆的 Python 模块,点赞收藏
  2. Linux系统主要目录及作用
  3. 在AE10.1环境下调试其他版本的程序
  4. C++ reinterpret_cast,const_cast等 显式类型转换总结
  5. JAVA常用框架和插件
  6. Django 模型 —— 模型介绍
  7. 基于Visual C++2010与windows SDK fo windows7开发windows7平台的tabletpc应用(1)-手写数学公式输入...
  8. Samba服务器(一):windows访问samba服务器共享文件的简单实现(图文并茂)
  9. HTML文件属于void值吗,使用HTML :: TreeBuilder查找html文件中的值
  10. 求一个任意实数c的算术平方根g的算法设计思想_算法复习第四篇——贪心法
  11. 【转载】自动化测试:为什么受伤的总是我?
  12. 微软想让所有人都成为开发者?
  13. windows和linux 修改 hosts的路径
  14. 51Nod-1080 两个数的平方和【暴力法】
  15. TCP的三次握手和四次挥手(超详解)
  16. assign ur here php,ecshop源码分析01
  17. Failed to recurse into submodule path 'third_party/onnx'
  18. 怒肝最新保姆级前端学习路线,速成贴心全面!
  19. 阿里云 搭建flink 后 web界面可以访问 但是没有task manager节点存活
  20. 阶梯形矩阵(Echelon Matrix)

热门文章

  1. 用大数据讲商业地产新故事
  2. 天猫官方再推巨作 《玩转天猫》助力商家备战双11
  3. R语言绘图 | 折线图画法,如何画出你满意的图?
  4. 发布 python-message,一个面向消息编程的程序库
  5. CDMA 原理与计算
  6. GPS 校验和 代码_高精度GNSS服务每个人:安卓智能 手机提供GPS原始测量数据实现高精度定位...
  7. WinZip 6 for Mac 强大的压缩解压缩工具 | 正版序列号
  8. NCDA和计算机设计大赛,“未来设计师”全国高校数字艺术设计大赛(NCDA大赛)参赛流程...
  9. mysql数据库index权限_MySQL数据库权限体系入门(4)---管理全局权限
  10. MATLAB指纹识别系统GUI界面实现