Shell找不到nginx

get*_*yId 2 linux shell ubuntu nginx server

尝试提示此命令nginx -V但 shell 返回fish: Unknown command “nginx”

如果我尝试sudo service nginx status 我可以看到Usage: /etc/init.d/nginx {start|stop|restart|reload|force-reload}

为什么nginx -V不工作?

hel*_*loV 6

/etc/init.d/nginxstart/stop/...nginx 服务的 shell 脚本

$ file /etc/init.d/nginx
/etc/init.d/nginx: POSIX shell script, ASCII text executable
Run Code Online (Sandbox Code Playgroud)

nginxbinary 是不同的,通常存在于/usr/sbin/. 将该目录添加到您的PATH.

$ file /usr/sbin/nginx
/usr/sbin/nginx: ELF 64-bit LSB  executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=c14e988f9696733869b790f49e27a488b0aff4c2, stripped
Run Code Online (Sandbox Code Playgroud)

或者查看文件/etc/init.d/nginx找出nginx的安装位置。