CentOS7 yum安装graphite+uwsgi+nginx时/opt/graphite/conf对应路径及配置问题
核心疑问解答
通过yum安装的graphite-web,对应源码/pip安装时/opt/graphite/conf/的等效路径为 /etc/graphite-web/,该目录下的local_settings.py就是graphite-web的核心配置文件。
故障修复步骤
1. 修正uWSGI配置
你当前/etc/uwsgi.d/graphite-web.ini的两个参数配置错误,修改为以下内容:
[uwsgi] processes = 2 socket = 127.0.0.1:3031 gid = nginx uid = nginx chdir = /usr/share/graphite/ module = graphite-web.wsgi:application
修改完成后重启uWSGI服务生效:systemctl restart uwsgi
2. 修复Nginx监听&访问异常问题
你遇到的8080端口未监听、访问/graphite路径报错的问题有两个原因:
- CentOS默认Nginx主配置未加载
/etc/nginx/sites-enabled/目录下的配置文件 - 你访问的路径和Nginx配置的路由规则不匹配
操作步骤:
- 编辑Nginx主配置文件
/etc/nginx/nginx.conf,在http配置块的末尾添加如下规则,加载自定义站点配置:
http { # 原有配置保留不变 include /etc/nginx/sites-enabled/*.conf; }
- 调整站点配置适配访问路径(二选一即可):
- 方案1:使用8080端口根路径访问
直接保留原有站点配置,访问时使用地址http://你的服务器IP:8080即可 - 方案2:适配
/graphite路径访问
修改/etc/nginx/sites-enabled/graphite-web配置:
server { listen 80; server_name graphite; root /usr/share/graphite/webapp; error_log /var/log/nginx/graphite-web-error.log; access_log /var/log/nginx/graphite-web-access.log; location /graphite/ { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; uwsgi_param SCRIPT_NAME /graphite; } }
同时编辑/etc/graphite-web/local_settings.py,添加如下配置适配路径前缀:FORCE_SCRIPT_NAME = '/graphite'
3. 验证Nginx配置语法无误后重启服务:
nginx -t systemctl restart nginx
内容的提问来源于stack exchange,提问作者NRaj
相关产品推荐
相关产品推荐

