配置 Nginx 环境变量

Siona2023-12-06

配置 Nginx 环境变量

将 nginx 配置到环境变量,这样的话就可以在任何目录使用 nginx 命令,而不是只能使用 /usr/local/nginx/sbin/nginx 操作 nginx。

1. 修改 /etc/profile

vim /etc/profile

# 末尾添加
# Nginx ENV
export NGINX_HOME=/usr/local/nginx
export PATH=${NGINX_HOME}/sbin:$PATH

ESC
:wq

2. 使 /etc/profile 生效

source /etc/profile
Last Updated 3/25/2024, 3:44:55 PM