启动nginx报错Failed to start nginx.service: Unit is not loaded properly: Bad message

CentOS7 安装nodejs,redis,nginx CentOS7安装nodejs,redis,nginx及配置 阅读详情
AI摘要

文章讲述了在配置nginx.service文件时遇到的错误,主要原因是语法错误,如拼写错误和格式问题。作者详细解释了错误原因并提供了修正后的脚本,展示了如何重启、检查状态及设置开机自启动的过程。

1.报错分析

使用创建服务脚本:

vi /usr/lib/systemd/system/nginx.service
systemctl daemon-reload
systemctl start nginx.service

报错是因为我的配置文件:
/usr/lib/systemd/system/nginx.service没有被按正确格式编写导致。改好之后重新加载就可以了.
具体问题分析一下。

通过报错日志看第2行、第8行、第9行报错。主要是我在编写nginx.service文件时,把第2行的单词“Description”写成“Descri ption”了,第8行的单词“ExecStartPre”写成“ExecstartPre”,还有第9行的ExecStartPre的“-t -c ”后面的内容“/usr/local/nginx/conf/nginx.conf”不能换行。

2.正确的nginx.service内容

[Unit]
Description=nginx - web server
After=network.targt

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

修改完脚本后执行命令:

systemctl daemon-reload
systemctl start nginx.service
systemctl status nginx.service

执行成功后查看运行状态:

最后设置开机自启:

systemctl enable nginx.service

参考地址:

https://www.cnblogs.com/pengsay/p/16206920.html

Failed to start nginx.service: Unit is not loaded properly: Bad message-优快云博客

Failed to start tomcat.service: Unit is not loaded properly: Bad message 如何解决? 错误 “Failed to start tomcat.service: Unit is not loaded properly: Bad message” 通常意味着的systemd 配置文件存在语法错误或配置不正确。为了解决这个问题,一步步检查和修正这个服务文件。 阅读详情

相关推荐

prometheus设置为服务后启动时总是失败

在我们下载完成prometheus程序包,使用二进制的prometheus测试启动正常,但是将prometheus程序设置为服务开机自启时,该prometheus服务并没有启动,并且手动设置启动该服务也是失败提示【Failed to start "prometheus".】

提供C#相关开发 、云计算、运维测试、网络安全相关技术分享与服务,有意向可联系。 2645

nginx启动报错

Redirecting to /bin/systemctl start nginx.service Failed to start nginx.service: Unit not 解决方法: 是因为nginx没有有添加到系统服务,手动手动添加一个即可。 在 /etc/init.d/下创建名为nginx的启动脚本即可,内容如下: nginx=/usr/local/nginx/sbin/nginx conf=/usr/local/nginx/conf/nginx.conf case $1 in start) e

jeson 2610

(nginx) nginx5 nginx https部署实战

综上所述,相比 HTTP 协议,HTTPS 协议增加了很多握手、加密解密等流程,虽然过程很复杂,但其可以保证数据传输的安全。所以在这个互联网膨胀的时代,其中隐藏着各种看不见的危机,为了保证数据的安全,维护网络稳定,建议大家多多推广HTTPS。SSL 证书费用很高,以及其在服务器上的部署、更新维护非常繁琐HTTPS 降低用户访问速度(多次握手)网站改用HTTPS 以后,由HTTP 跳转到 HTTPS 的方式增加了用户访问耗时(多数网站采用302跳转)

weixin_50382197的博客 1504

使用systemctl进行服务管理

以nginx为例 操作命令 # 添加一个.service文件 vim /usr/lib/systemd/system/nginx.service # 重载系统服务 systemctl daemon-reload nginx.service文件内容 [Unit] # 服务描述 Description=The nginx HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-look

qq_37377082的博客 789

Keil MDK安装NRF52832开发环境全攻略(附系统时间错误解决方案)

本文详细介绍了如何使用Keil MDK搭建NRF52832开发环境,包括基础软件安装、项目配置关键步骤以及常见问题解决方案。特别针对系统时间错误导致的编译失败问题提供了实用解决方法,帮助开发者快速上手NRF52832开发。

weixin_29168153的博客 505

实战篇(一):从零构建领域知识图谱——基于Protege的本体建模与知识表示

本文详细介绍了如何从零构建领域知识图谱,重点讲解了基于Protege的本体建模与知识表示方法。通过游戏和电影领域的实战案例,展示了类层次结构设计、属性关系定义、推理验证等关键步骤,帮助读者掌握知识图谱构建的核心技术。

weixin_42613501的博客 479

nginx启动失败:Redirecting to /bin/systemctl start nginx.service Failed to start nginx.service: Unit not

解决方法: 是因为nginx没有有添加到系统服务,手动手动添加一个即可。 在 /etc/init.d/下创建名为nginx的启动脚本即可,内容如下: #!/bin/bash # # chkconfig: - 85 15 # description: Nginx is a World Wide Web server. # processname: nginx nginx=/usr/local/n...

花语无痕的博客 1万+

从零搭建智能车竞赛卡丁车:自动驾驶科目中的锥桶识别与路径规划实战教程

本文提供了一份从零搭建智能车竞赛卡丁车的实战教程,重点解析了自动驾驶科目中的核心环节:锥桶识别与路径规划。内容涵盖硬件选型、传感器部署、基于单目视觉的识别算法,以及适用于嵌入式平台的轻量级路径规划与跟踪策略,旨在帮助参赛者与爱好者系统掌握关键技术,完成稳定可靠的自动驾驶系统搭建。

lg888的博客 1166

Failed to start nginx.service: Unit is not loaded properly: Bad message

我的这个报错是因为我的配置文件: /usr/lib/systemd/system/nginx.service没有被正确加载.改好之后重新加载就可以了. 具体问题应该还是要具体分析一下.

Edidaughter的博客 1万+

SuperMap iObjects Java组件开发——环境部署(IntelliJ IDEA)

SuperMap iObjects Java 是面向GIS应用系统开发者的组件式GIS开发平台,具有强大的地理数据管理、编辑、显示、分析等功能,并且其具有极强的易用性和丰富的帮助资源,适宜快速开发大型GIS应用系统。本文将介绍如何在IntelliJ IDEA集成开发环境中进行SuperMap iObjects Java组件的环境部署。

nan620403的博客 1081

麻辣香锅病毒分析

Spicy Hot Pot浏览器劫持病毒(麻辣香锅病毒)从2020年初被安全公司监测到,因其病毒模块带有MLXG_KM被安全行业代称麻辣香锅病毒。目前通过各种激活工具传播, 包括暴风激活、小马激活和KMS激活等诸多工具,疑似与下载站进行合作推广此类激活工具。Spicy Hot Pot 是一个浏览器劫持 Rootkit,它会将用户的主页更改为指向恶意软件操作员控制的页面,此外还会将内存转储从机器上传到预定义的服务器,并结合本地更新功能以确保其保持更新。通常浏览器劫持者会通过更改用户主页的恶意可执行文件或注册表

不忘初心,护天下安全! 4787

nginx启动失败:Redirecting to /bin/systemctl start nginx.service Failed to start nginx.service: Unit not ...

解决方法: 是因为nginx没有有添加到系统服务,手动手动添加一个即可。 在/etc/init.d/下创建名为nginx的启动脚本即可,内容如下: #!/bin/bash # # chkconfig: - 85 15 # description: Nginx is a World Wide Web server. # processname: ngi...

dianchanhe0596的博客 7466

Agentic AI为教育行业赋能,提示工程架构师解析应用潜力

然而,即便是最先进的 LLMs,在面对复杂、动态、需要持续规划和调整的教育场景时,也常常显得力不从心,它们更像是强大的“问答机器”,而非真正意义上的“学习伙伴”或“教学助手”。在教育场景中,传统的 AI 工具可能只能回答学生提出的特定问题,或者根据预设的规则推送一些学习材料。无论您是教育技术领域的开发者、产品经理,还是一线的教育工作者、教育管理者,抑或是对 AI 教育应用充满好奇的研究者,本文都将为您提供宝贵的 insights,助您把握 Agentic AI 时代教育创新的脉搏。

架构师的AI之路,分享AI应用开发架构的学习与实践。 466

nginx重启错误

nginx重启的时候常见报错: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) emerg: 错误级别. 0.0.0.0.80: 错误IP地址和端口. 解决方法: nginx或者其它进程占用了nginx的80端口, 先杀掉占用进程, 然后再重启. $netstat -ntpl $ki...

aqc802886的博客 168

C#实战:从零搭建Vosk离线语音转文字系统

本文手把手教你用C#构建离线语音转文字系统,基于NAudio和Vosk实现全流程开发。首先介绍环境搭建,包括NuGet包安装和中文模型配置,强调16kHz单声道音频格式的关键性。接着详细解析音频预处理转换、Vosk模型初始化及识别过程的核心代码,提供多线程优化建议和实时识别扩展思路。文章包含80%以上代码注释,从常见问题排查到性能优化技巧,完整覆盖从"Hello World"到工业级部署的关键技术点,特别适合需要开发本地化语音识别应用的C#开发者。

墨夶的博客 752

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Ubuntu 20.04 Apache + Let‘s Encrypt 深度配置指南

HTTPS 是现代 Web 服务的基础安全层,其核心依赖于 TLS 协议、数字证书与 Web 服务器的协同配置。理解 SSL/TLS 握手原理、证书链验证机制及模块加载顺序,是解决 ERR_SSL_VERSION_OR_CIPHER_MISMATCH、AH00526 配置错误等典型问题的前提。在 Ubuntu 20.04 环境中,Apache 的 mod_ssl 和 socache_shmcb 模块状态、Certbot 自动生成配置与手动管理的冲突、以及 systemd 续期 hook 的权限边界,共同构成

weixin_30892763的博客 348

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

史上最强解决启动nginx出现Failed to start nginx.service:unit not found问题

1、错误原因是没有添加nginx服务,所以启动失败解决办法1、在etc/init.d/目录下创建文件,文件名叫nginx,内容为:/bin/sh。

LYF315013的博客 6035

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

在centos下启动nginx出现Failed to start nginx.service:unit not found

或者用命令在根目录下执行:# vim /etc/init.d/nginx (注意vim旁边有一个空格)# chkconfig --add nginx (注意add前面是两个短横线-)在/root/etc/init.d/目录下新建文件,文件名为nginx。错误的原因就是没有添加nginx服务,所以启动失败。2. 插入以下代码。3. 用命令进入此目录。4. 依此执行以下命令。5. 开启nginx。

weixin_46005650的博客 986

nginx1.9 在centos7.2下报Failed to restart nginx.service: Unit nginx.service failed to load: No 。。错误

错误描述: [root@www php-fpm.d]# service nginx restart Redirecting to /bin/systemctl restart  nginx.service Failed to restart nginx.service: Unit nginx.service failed to load: No such file or director

u012984663的专栏 2万+

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 st...

Lansonli(蓝深李)的博客 8545

启动Nginx出现Failed to start nginx.service:unit not found

启动nginx出现Failed to start nginx.service:unit not found。 错误的原因就是没有添加nginx服务,所以启动失败。 解决方法就是:在/root/etc/init.d/目录下新建文件,文件名为nginx;或者用命令在根目录下执行:# vim /etc/init.d/nginx (注意vim旁边有一个空格),随后插入代码: #!/bin/sh # nginx - this script starts and stops the nginx daemin

u011028557的博客 1万+

Failed to restart nginx.service: Unit nginx.service not found

你可以通过以下命令检查 Nginx 的安装路径:which nginx。sh2. 手动启动和停止 Nginx如果你是手动安装的 Nginx,可以使用 Nginx 的可执行文件来启动和停止 Nginx:启动 Nginx:sudo /usr/local/nginx/sbin/nginx。sh重新加载 Nginx 配置:sudo /usr/local/nginx/sbin/nginx -s reload。sh停止 Nginx:sudo /usr/local/nginx/sbin/nginx -s stop。

Smile_Gently的博客 2790

分享一个docker无法启动的小问题

文件的第一行存在一个 "Invalid section header" 错误。这意味着 systemd 在解析该文件时发现了问题。启动不了,我们运行下 systemctl status docker.service 看看报错。这些日志显示了 Docker 服务启动问题的原因。我们打开 docker.service文件看看第一行。这一看就是docker的进程崩了,我们启动下进程。可以查看服务了(服务就不展示了)准备看看docker服务怎么样。缺了一个括号,我们补上。保存退出后再次运行看看。

爱折腾的技术人 2156

启动nginx报错Failed to start nginx.service: Unit nginx.service not found.

在ubuntu上编译nginx成功后,通过sudo systemctl start ngin启动服务时报Failed to start nginx.service: Unit nginx.service not found.本篇记录解决方法。

chenyijun的专栏 2514

centos7.9--nginx--web相关基本操作

centos7.9–nginx1.18–web相关基本操作@YK

ksfbvv的博客 2231

nginx 启动失败Failed to start nginx.service:unit not found

nginx 启动失败Failed to start nginx.service:unit not found

joker19920330的博客 3277
上一篇: vue cmd执行报错 ‘vue‘ 不是内部或外部命令
下一篇: vue2引入brand.vue和brand-add-or-update.vue后重启项目报错解决方案
developerFBI
博客等级 码龄15年 174粉丝 105原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值