简体   繁体   中英

PermissionError: [Errno 13] Permission denied in Ubuntu with flask

I am trying to save a file to my static folder with flask running on ubuntu 20.4 to the following directory: /var/www/webApp/webApp/static/temp/3.png' When I try to save it gives me the following error log:

[wsgi:error] [pid 1696:tid 139769597695744] [client xxxxxxxxxxx] PermissionError: [Errno 13] Permission denied: '/var/www/webApp/webApp/static/temp/3.png', referer: http://xx.xx.xxx.xx/upload

I have set the folder premission to 777, and in the webapp.conf folder I have the following code:

<VirtualHost *:80>
    ServerName 34.65.173.45
    ServerAdmin email@mywebsite.com
    WSGIScriptAlias / /var/www/webApp/webapp.wsgi
    <Directory /var/www/webApp/webApp/>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /var/www/webApp/webApp/static
    <Directory /var/www/webApp/webApp/static/>
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined

I save my file with the following code:

file.save(os.path.join(app.root_path, 'static', 'temp', filename))

This is working on local host.

Can someone help? Thanks

Can you go to the project folder /var/www/webApp/webApp/ and run

sudo chmod 777 -Rv static

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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