简体   繁体   English

拒绝访问文件 [apache2、flask、python]

[英]Denied accsess to file [apache2, flask, python]

Raspberian, apache2, python3, flask, I need to change network settings. Raspberian、apache2、python3、flask,我需要更改网络设置。

But when I try:但是当我尝试:

f = open('/etc/network/settings.txt', 'w') \
f.write('1234')

It gives me an error:它给了我一个错误:

PermissionError: [Errno 13] Permission denied: '/etc/network/settings.txt'

I really dont understand what is going on.我真的不明白这是怎么回事。

I try to change apache2 settings :我尝试更改 apache2 设置:

<Directory />
    AllowOverride All
    Require all granted
    Allow from all
</Directory>

Add to apache2.conf and to /sites-avialable/webapp.conf , but it is doesn't work添加到apache2.conf/sites-avialable/webapp.conf ,但它不起作用

Looks like you don't have write-access to /etc/network/settings.txt.看起来您没有对 /etc/network/settings.txt 的写访问权限。 You need to either run the script as root/sudo or give your account permission to write the file with chown and chmod.您需要以 root/sudo 身份运行脚本或授予您的帐户权限以使用 chown 和 chmod 写入文件。

Tutorials with examples on how to change ownership and permissions on files: https://www.howtoforge.com/linux-chown-command/ https://www.howtoforge.com/tutorial/linux-chmod-command/有关如何更改文件所有权和权限的示例教程: https : //www.howtoforge.com/linux-chown-command/ https://www.howtoforge.com/tutorial/linux-chmod-command/

  1. Created file named settings.txt创建名为 settings.txt 的文件

    chmod 777 settings.txt chmod 777 设置.txt

  2. add to apache2/sites-enabled/webApp.conf:添加到 apache2/sites-enabled/webApp.conf:

    <Directory /etc/network/> <目录/etc/network/>
    Order deny,allow订单拒绝,允许
    Allow from all所有人都允许
    </Directory> </目录>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM