stable-diffusion-multi-user icon indicating copy to clipboard operation
stable-diffusion-multi-user copied to clipboard

为什么会出现403?

Open Marootc opened this issue 2 years ago • 5 comments

按照大佬的方法配置下去 当访问api的时候出现403?

Marootc avatar Apr 22 '23 17:04 Marootc

一般是因为权限没给到位,apache服务器运行的时候是www-data用户身份而不是root用户。可以尝试以下方法:

  • 可以将整个项目的文件都放在/var/www 目录下,避免不必要的权限问题(移动项目目录之后需要重新配置)
  • 授予apache项目目录的权限:
sudo chgrp www-data /var/www
sudo chmod g+w /var/www
  • 检查一下gen_http_conf.py中最后的几行授权命令是否成功运行了,如果没成功的话,可以手动在命令行里sudo运行一下。具体是文件里的这两行命令(手动运行的话记得加上sudo)
os.system("chmod -R 644 {}".format(main_path))
os.system("find {} -type d | xargs chmod 755".format(main_path))

最后,可以查看apache的错误日志来定位具体的问题,日志路径:/var/log/apache2/error.log

wolverinn avatar Apr 23 '23 04:04 wolverinn

access to /favicon.ico denied (filesystem path '/root/var') because search permissions are missing on a component of the path, referer: http://region-9.seetacloud.com:47763/txt2img

Marootc avatar Apr 23 '23 05:04 Marootc

@wolverinn access to /favicon.ico denied (filesystem path '/root/var') because search permissions are missing on a component of the path, referer: http://region-9.seetacloud.com:47763/txt2img 错误日志 还是显示403 我的用apache2 版 Apache/2.4.41 (Ubuntu)

Marootc avatar Apr 23 '23 05:04 Marootc

@wolverinn <VirtualHost *:6006> WSGIApplicationGroup %{GLOBAL}

WSGIScriptAlias / /root/var/www/sd_multi/wsgi.py

Alias /static/ /root/var/www/static/

<Directory /root/var/www/static>
    Require all granted
</Directory>

<Directory /root/var/www/sd_multi>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>

WSGIPythonHome /root/var/www/venv

~ 这是自动生成的配置文件

Marootc avatar Apr 23 '23 05:04 Marootc

你这个报错还是权限问题。/root/var 没给apache权限肯定读不到啊。参考这篇讲django部署到apache服务器的文章吧:https://www.jianshu.com/p/ad47ea981e3e

wolverinn avatar Apr 23 '23 11:04 wolverinn