![nginx 变量端口号](https://linux22.com/image/632822/nginx%20%E5%8F%98%E9%87%8F%E7%AB%AF%E5%8F%A3%E5%8F%B7.png)
我希望能够在普通用户启动时在端口 8080 上运行 nginx 服务器,在 root 启动时在端口 80 上运行。如何在配置文件中或通过使用 bash 脚本对其进行参数化?
答案1
如果您想通过命令行提供配置文件,请查看命令行帮助:
$ /usr/sbin/nginx -h
nginx version: nginx/1.2.1
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /etc/nginx/)
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
所以也许您正在寻找-c
这里的选项。