使用指定配置启动 Nginx 的步骤:
1. 编辑 Nginx 配置文件:
编辑文件 /etc/nginx/nginx.conf 或 /usr/local/etc/nginx/nginx.conf,根据您的操作系统。
2. 添加 include 指令:
在配置文件中添加 include 指令,以包含自定义配置。
例如:
include /etc/nginx/conf.d/.conf;
3. 创建自定义配置文件:
在 /etc/nginx/conf.d/ 目录下创建自定义配置文件,例如 custom.conf。
4. 添加自定义配置:
在自定义配置文件中添加所需的配置指令,例如服务器块、位置块或其他指令。
例如:
server {
listen 8080;
location / {
root /var/www/mysite;
}
}
5. 使用指定配置启动 Nginx:
使用 -c 选项指定自定义配置启动 Nginx。
例如:
nginx -c /etc/nginx/nginx.conf
下一篇:nginx配置的顺序