前端老生

nginx command not found

-bash: nginx: command not found

在Centos中无法在任意路径中执行nginx命令,需进入nginx目录才可以执行,解决方案是:在/etc/profile中增加nginx的执行路径的环境变量

添加nginx环境变量

vim /etc/profile

# 增加nginx的执行文件路径

# nginx

export PATH="/usr/local/nginx/sbin:$PATH"

# 保存环境变量

source /etc/profile

验证nginx.conf配置

nginx -t

无痛重启nginx

nginx -s reload