CMD Line:systemctl start nginx.service
Failed to start nginx.service: Unit not found.

Solution:

1.vim /etc/init.d/nginx

#!/bin/sh
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - # 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 nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit [ -f $NGINX_CONF_FILE ] || exit echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null >& } case "$1" in start) rh_status_q && exit
$
;; stop) rh_status_q || exit
$
;; restart|configtest)
$
;; reload)
rh_status_q || exit
$
;; force-reload)
force_reload
;;
status)
rh_status
;; condrestart|try-restart) rh_status_q || exit
;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit esac

3. cd /etc/init.d

4

# chmod 755 /etc/init.d/nginx

# chkconfig --add nginx

5. service nginx start

[ISSUE] [Centos] Centos Start Nginx Show: Failed to start nginx.service:unit not found的更多相关文章

  1. CentOS 7 防火墙 出现Failed to start iptables.service: Unit iptables.service failed to load

    错误信息如下: [root]# service iptables start Redirecting to /bin/systemctl start iptables.service Failed t ...

  2. CentOS 7出现Failed to start firewalld.service: Unit is masked的解决办法和firewalld 防火墙开关

    说明:刚刚使用systemctl start firewalld命令开启防火墙的时候,却开不成功,出现Failed to start firewalld.service: Unit is masked ...

  3. Failed to stop iptables.service: Unit iptables.service not loaded.解决方法

    CentOS7中执行 service iptables start/stop 会报错Failed to start iptables.service: Unit iptables.service fa ...

  4. centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not foundc

    现象: 在centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not found [明明已经安装了,为什么提示不存在呢?] 原因: 在 ...

  5. centos7安装MariaDB以及Failed to start mariadb.service: Unit not found的错误解决

    centos7下yum安装MariaDB CentOS 7下mysql下替换成MariaDB了.MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权 许可 Mari ...

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

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

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

    Failed to start ssh.service: Unit not found. 报错内容: [Centos7@localhost ~]$ service ssh start Redirect ...

  8. Failed to restart ssh.service: Unit not found.

    环境 操作系统:CentOS 7 问题 重启ssh服务,启动报错:Failed to restart ssh.service: Unit not found. 操作步骤 1. 编辑sshd_confi ...

  9. Failed to stop iptables.service: Unit iptables.service not loaded.

    redhat 7 [root@lk0 ~]# service iptables stop Redirecting to /bin/systemctl stop iptables.service Fai ...

  10. centos7 Failed to start firewalld.service: Unit is masked.

    centos7 启动防火墙失败:Failed to start firewalld.service: Unit is masked.   ---- 刚yum安装了iptables 解决: 执行”sys ...

随机推荐

  1. Google代码规范

    文件名 文件名须全部小写,下划线(_)和短横线(-) 源文件采用 UTF-8 编码. 非空代码块:K&R 风格 左花括号不另起新行 左花括号后紧跟换行 右花括号前需要换行 如果右花括号结束了语 ...

  2. jmeter基本组成原件介绍

    jmeter基本组成原件介绍 参考地址:https://wenku.baidu.com/view/d4986ca2aaea998fcc220ec1.html 从性能工具的原理划分: Jmeter工具和 ...

  3. ECMA Script 6_函数的扩展

    ES6规定只要函数参数使用了默认值.解构赋值.或者扩展运算符, 那么函数内部就不能显式设定为严格模式,否则会报错 1. 参数的默认值 ES6 允许为函数的参数设置默认值,即直接写在参数定义的后面 函数 ...

  4. html中的列表

    无序列表(什么前面默认一个实心的黑原点) <ul> <li>什么</li> <li>什么</li> <li>什么</li& ...

  5. Nginx负载均衡后端健康检查(支持HTTP和TCP)

    之前有一篇文章记录nginx负载均衡后端检查,链接为 https://www.cnblogs.com/minseo/p/9511456.html 但是只包含http健康检查不包含tcp下面安装ngin ...

  6. 关于vue页面多了之后,webpack热更新速度慢的解决办法

    vue项目大了之后,每次热更新都要10多秒的时间, 网上找了一大堆发现一个有用的办法 "env": { "development":{ "plugin ...

  7. 上传及更新代码到github(以及如何在vscode上提交自己的代码)

    上传本地代码 第一步:去github上创建自己的Repository,创建页面如下图所示: 红框为新建的仓库的https地址 第二步: echo "# Test" >> ...

  8. [Day24]IO(转换流、缓冲流)

    1. 转换流 1.1 OutputStreamWriter类-字符流通向字节流的桥梁,可使用指定的字符编码表,将要写入流中的字符编码成字节. 1.2 InputStreamReader类-字节流通向字 ...

  9. Source Insight相关设置

    #Source Insight中按快捷键在其他编辑器中打开当前文件 "D:\Program Files\Zend\ZendStudio-5.5.0\bin\ZDE.exe"  %f ...

  10. windows 启动停止 java进程

    本案例以 xxx.jar    为列子 我们一般启动的jar 在任务管理器中查看进程都是javaw.exe ,无法用命令来 kill,所以我们得给自己的java 进程设置个新 title 1:  首先 ...