'Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0' after uploading file to FTP

7,367

I managed to fix it. I just edited my vsftpd settings like so:

chown_upload_mode=0755
file_open_mode=0755
local_umask=000
Share:
7,367

Related videos on Youtube

xtremesmw
Author by

xtremesmw

Updated on September 18, 2022

Comments

  • xtremesmw
    xtremesmw almost 2 years

    Every time I edit a file (in this case a PHP file) and upload it via FTP to my VPS, via the user 'xtreme', the file, when accessed, outputs the following:

    Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Fatal error: Unknown: Failed opening required '/home/foo/www/bar/ul.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
    

    Entering chmod -R 2770 /home/foo via SSH fixes the problem, but it's not very practical at all. I have to do that every time I edit the file.

    I have Googled and searched Server Fault to no avail. Can somebody explain how to fix this?

    EDIT: After setting permissions to 755:

    drwxr-sr-x 2 xtreme www-data 4096 May  4 05:38 .
    drwxr-sr-x 4 xtreme www-data 4096 May  2 17:50 ..
    -rwxr-xr-x 1 xtreme www-data    0 May  2 17:11 index.php
    -rwxr-xr-x 1 xtreme www-data 1849 May  4 05:38 ul.php
    

    After uploading file to FTP:

    drwxr-sr-x 2 xtreme www-data 4096 May  4 05:41 .
    drwxr-sr-x 4 xtreme www-data 4096 May  2 17:50 ..
    -rwxr-xr-x 1 xtreme www-data    0 May  2 17:11 index.php
    -rwx------ 1 xtreme www-data 1849 May  4 05:41 ul.php
    

    So, after uploading the file the permissions are set to what I assume is 0700?

    • DerfK
      DerfK about 11 years
      What FTP server are you using?
    • xtremesmw
      xtremesmw about 11 years
      vsftpd, and if it matters, I'm using Rapid PHP's built in FTP client.