启动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-CSDN博客

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#相关开发 、云计算、运维测试、网络安全相关技术分享与服务,有意向可联系。 2648

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

【愚公系列】《AIGC辅助软件开发》041-如何使用 AI技术提升工作效率:AI辅助软件架构师实践

在数字化转型的浪潮中,软件架构师作为技术团队的核心,承载着系统设计与架构优化的重要责任。然而,随着项目复杂度的增加和技术环境的变化,架构师面临着前所未有的挑战。幸运的是,人工智能(AI)技术的迅猛发展为这一行业带来了新的机遇,帮助架构师提升工作效率、优化决策过程,并改善团队协作。本文将深入探讨AI如何辅助软件架构师的实际工作,具体分析AI在需求分析、架构设计、代码生成、测试和优化等环节的应用。

愚公智库 15万+

使用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的博客 791

通过PXE的方式实现Ubuntu 24.04 自动安装

之前都是通过PXE来自动化安装Redhat系列的,例如:Rocky9、Rocky10、CentOS7、银河麒麟 Kylin-V10、Kylin-V11、OpenEuler 24.03等。现在安装Ubuntu系列的跟红帽的不太一样,所以在这里介绍下。

邢宇宇的博客 1499

【驱动适配】高通sa522平台tac5x1x驱动适配全指南

本手册详细介绍了TAC5301-Q1音频编解码器在高通sa525平台Linux系统下的驱动适配流程。主要内容包括:1)TAC5301-Q1核心特性(车载级音频Codec、关键接口和功能);2)驱动适配依赖(高通声卡驱动、ALSA SoC框架等);3)I2S协议原理及主从模式说明;4)硬件准备与检查要点;5)完整的驱动移植步骤(代码移植、Kconfig/Makefile修改、设备树配置)。该手册适用于嵌入式音频开发工程师快速完成TAC5301-Q1芯片的驱动移植与验证工作。

嵌入式博哥的博客 308

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万+

Vercel静态站被墙别慌!手把手教你用Cloudflare免费CDN+域名解析搞定DNS污染

本文详细介绍了如何利用Cloudflare免费CDN和域名解析解决Vercel静态网站遭遇DNS污染的问题。通过诊断DNS污染、设计Cloudflare解决方案架构、实战配置步骤以及高级调优技巧,帮助用户快速恢复站点访问并提升防护能力。

weixin_27442001的博客 711

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

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

Edidaughter的博客 1万+

一起玩转GNU Radio:调制解调大合集

本文汇总了GNU Radio中多种常见的调制解调方法及其参考文献链接,便于今后查看,供大家参考!

无线通信实验室 1万+

STM32实战:用定时器触发ADC+DMA双缓冲实现电机电流采样(附避坑指南)

本文详细介绍了如何利用STM32的定时器触发ADC注入组采样,结合DMA双缓冲机制实现电机电流的高效采样。通过PWM触发和双缓冲架构,解决了开关噪声干扰、实时性要求和数据一致性等核心挑战,显著降低CPU负载并提升采样精度。附有完整的代码示例和避坑指南,适用于无人机电调、工业伺服驱动器等高精度电机控制场景。

weixin_33737134的博客 524

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的博客 7468

D457深度相机调试记录(max96712+max9295A)

使用max96712解串器解4路D457相机。采集深度相机Depth和RGB流。

navy2015_163的博客 1278

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

1篇1章4节:生成对抗网络GAN和图像生成领域的StyleGAN

AI图像生成技术的革命性突破:从GAN到StyleGAN 近年来,人工智能在图像生成领域取得显著进展,尤其是生成对抗网络(GAN)的发展推动了技术的飞跃。从早期的基础GAN到渐进式GAN(Progressive GAN),再到革命性的StyleGAN,AI生成图像的逼真度已接近人类创作水平。StyleGAN通过引入风格潜向量和自适应实例归一化,实现了对图像风格与内容的精细控制,广泛应用于人脸生成、艺术创作及影视行业。后续的StyleGAN2解决了“斑点”问题,StyleGAN3进一步优化纹理过渡,提升了图像

MD Code 227

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

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的博客 349

深度学习工具包 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的博客 6037

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

在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(蓝深李)的博客 8548

启动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的博客 2793

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

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

爱折腾的技术人 2157

启动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的专栏 2517

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的博客 3278
上一篇: 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、付费专栏及课程。

余额充值