CentOS7下启动Nginx出现Failed to start nginx.service:unit not found
错误的原因就是没有添加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
CentOS7下启动Nginx出现Failed to start nginx.service:unit not found相关推荐
- 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 ...
- kali搭建bind9 dns服务器启动问题:Failed to restart bind9.service: Unit bind9.service not found.
安装的名字虽然是bind9,但是启动要用named. 就是service named restart 国内找不到答案 参考答案:https://gitlab.isc.org/isc-projects/ ...
- centos7 安装mysql 解决:Failed to restart mysqld.service: Unit not found
解决方法如下: 首先需要安装mariadb-server~]# yum install -y mariadb-server启动服务~]# systemctl start mariadb.service ...
- Failed to start firewalld.service: Unit is masked
centos7 启动防火墙失败:Failed to start firewalld.service: Unit is masked. 解决: 执行" systemctl start fire ...
- Centos7 Failed to start xxx.service: Unit not found
Centos7 Failed to start xxx.service: Unit not found 一.查看 systemctl list-unit-files --type=service // ...
- 【QA】启动时间同步服务失败:Failed to start ntpd.service: Unit not found
Failed to start ntpd.service: Unit not found 重启大数据集群后,启动时间同步服务,出现异常: 解决办法: 首先看一下服务列表里有没有这个服务: system ...
- 【Linux - mysql】linux下mysql报Failed to restart mysqld.service: Unit not found
笔者使用 service mysqld restart 重启mysql服务的时候,报了Failed to restart mysqld.service: Unit not found 估计也就是服务名 ...
- Failed to start mongod.service: Unit not found
其实自己用惯的是MYSQL,然后项目最后一步完善数据读写的部分,本来打算用mysql的,然而在centOS系统上发现安装总是出问题,后来查找一下资料,发现centOS系统上一般用的是Mariadb,这 ...
- 【已解决】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 ...
- Failed to restart docker.service: Unit is masked.真正的解决办法
启动docker时报错 [root@localhost deployScript]# systemctl restart docker Failed to restart docker.service ...
最新文章
- Vcenter一次性将服务器四个网卡从端口组迁移到分布式交换机的方法
- 使用Ant Design 和Vue,React中后台开发套餐
- Linux xds100,【图片】【吧主帖】在LINUX(ubuntu)系统下装CCSv6方法(原创)【dsp吧】_百度贴吧...
- 使用CArchive类进行序列化
- 物联网可编程高灵活度IoT网关或集线器是解决方案
- jboss项目导入idea_JBoss BPM Suite快速指南–将外部数据模型导入BPM项目
- 导致溢出_邯郸一司机,溢出的“5毫克”导致A2被降级,老司机自吞“苦酒”
- The Importance of Money in Life
- 初始C语言——完数问题
- C++学习系列(二)—— 核心编程(面向对象)
- lighttpd 使用
- Rust 有问有答之 crate 是什么
- hdu 6438 - 贪心
- 聚合支付机构备案情况分析(截至22年1月27日)
- 漫谈CRM体系化建设2 – 如何开发客户?
- 安装python卡到不动了_pip卡住不动的解决方案
- vue实现调查问卷一页一题,上一题下一题形式
- 超萌小萝莉因为不好好吃饭向妈妈道歉,超可爱!
- PCL实现Alpha Shapes算法
- 疫后如何激活消费?上海和阿里打了个样板