如果ngxin不能使用service nginx start 开启
来源:互联网 发布:淘宝店铺评价好的包包 编辑:程序博客网 时间:2024/05/18 05:11
如果ngxin不能使用service nginx start 开启,报Starting nginx (via systemctl): Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details,则写入以下代码到nginx.service并放到/usr/lib/systemd/system下:
[unit]
Description=nginxAfter=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/nginx
ExecReload=/usr/local/nginx/nginx -s reload
ExecStop=/usr/local/nginx/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
以上环境在centos7,nginx版本为1.12.1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
通常来说如果不是必须可以不用上面的方法,当在当前环境下开启或关闭遇到问题时应先用以下命令看下nginx的状态,然后根据状态来解决问题:
命令 :systemctl status nginx
当不能使用service nginx start 开启或者使用service nginx stop 关闭时,查看systemctl status nginx 会有一定的错误提示,拿我遇到的来说有如下提示:
Jul 13 06:07:11 localhost.localdomain systemd[1]: PID file /var/run/nginx.pid not readable (yet?) after start.
这个提示是说在/etc/init.d/nginx这个文件中pidfile所指定的路径没有可读权限,当打开这个文件发现这行是被#所注释的,但想要解决这个问题还是需要把这个路径换为一个可读的,如下:
/usr/local/nginx/nginx.pid。
然后使用systemctl daemon-reload 更新下systemctl。
通过以上操作后发现service nginx start 不再有问题,但是stop还是不能停止,查看/etc/init.d/nginx这个文件后发现stop函数在运行后会删除掉$lockfile所指定的文件即:lockfile=/var/lock/subsys/nginx,而当打开这个目录发现在nginx停止后subsys目录下的nginx并没有被删除,所以导致使用service nginx stop 命令停止nginx不成功,解决这个问题只需使用root账户把此文件打开然后使用:wq保存一下即可。过后使用ll /var/local/subsys/nginx 发现这个文件的权限为644即可。
当然最好是在配置/etc/init.d/nginx时将其路径修改为有权限的目录下如:
lockfile=/usr/local/nginx/lock/nginx
这样即可。
- 如果ngxin不能使用service nginx start 开启
- ngxin
- MySQL 重装不能start service解决方法
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- 添加nginx为系统服务(service nginx start/stop/restart)
- Android -- service的开启方式, start开启和绑定开启服务,调用服务的的方法, aidl调用远程服务
- Nginx-start
- 把Nginx加为系统服务(service nginx start/stop/restart)
- nginx报错:nginx.service failed to run 'start-pre' task: No space left on device
- Linux添加nginx为系统服务(service nginx status/start/stop/restart)
- 服务器nginx开启并使用(初级)
- start方式开启服务
- 开启动画用start
- laragon 使用php5.* Service Apache can not start. Reason
- Centos7使用systemctl start iptables.service不起作用解决方法
- 使用Inten不能启动一个Service是怎么回事
- .安装 MySQL 5 后无法启动(不能 Start service) 的解决办法
- Dungeon Master-BFS
- 从零开始nodejs系列文章
- 2016-9月份至今读的小说记录
- @NotEmpty、@NotBlank、@NotNull的区别
- 解决fatal: unable to connect to github.com问题
- 如果ngxin不能使用service nginx start 开启
- 23种设计模式(9)-外观模式
- npm 配置
- Angular中$compile源码分析
- 你不知道的JavaScript(四)this(一)
- 使用dblink跨库导数据
- 如何在windows环境下使用ipython?
- Linux系统各个目录的作用详解
- Java中throws和throw的区别讲解