Fix Joomla 3.0 directory permissions



  • NOTE: this post is for Joomla 3.0, for 2.5 and prior versions, jump to Setting Joomla Directory Permissions for Joomla 2.5

    After a fresh Joomla! 3.0.x or RocketLauncher J30 installation you may face the situation where you cannot install any new extension (component, module or plugin). In case of RocketLauncher (at this time only Metropolis RocketLauncher J30 is available), the fresh installation will cause this issue on most cPanel/WHM servers.

    The symptom:

    Warning
    Warning: Failed to move file!

    JFolder: :files: Path is not a folder. Path: /home/ … /public_html/tmp/install_50aec7556dcbf
    JFolder: :folder: Path is not a folder. Path: /home/ ... /public_html/tmp/install_50aec7556dcbf
    JFolder: :files: Path is not a folder. Path: /home/ ... /public_html/tmp/install_50aec7556dcbf
    JInstaller: :Install: Cannot find Joomla XML setup file

    Error
    Archive does not exist

    There could be several reasons for such messages but in case of a new Joomla 3.0 installation or Metropolis RocketLauncher J30 the problem is the Joomla 3.0 directory permissions.

    The solution:
    Setting Joomla Directory Permissions - updated 11/22/2012 for Joomla 3.0
    After installing Joomla! 3.0.x you may need to fix the directory permissions in order to have Joomla! working without "Permission denied" errors and/or "Failed to move file!" warnings. I couldn't find a simple way to view the list of folders that need RW (read, write) rights. In previous Joomla versions used to be "Site" >> "System Information" and the "Directory Permissions" tab, where you could see the full list of directories with the "Writable" or "Unwritable" status. Not there any more but you may still need to change the file permissions for these directories.

    You can achieve this one-by-one via the cPanel File Manager or via FTP, refer to the list of directories at the end of this post, change them all to 0777 rw (read-write).

    If you have SSH acces, it is easier and by running the following bash script, where you need to change the "username" for SERVERUSER and optionally add the INSTALLDIR, it is just a minute:
    *the username is same as your cPanel username, if you are on SSH /home/[username]/public_html/…
    *the INSTALLDIR is used in case you installed Joomla under a folder or subdomain, ex. /home/[username]/public_html/[mypage] for mypage.mydomain.com or mydomain.com/mypage

    #!/bin/bash
    
    SERVERUSER="username"     #username on your server (same as login name for cPanel) /home/SERVERUSER
    INSTALLDIR=""            #optional, always start with "/" example: /myjoomla will point to www.your-domain.com/myjoomla directory
    
    #change JOOMLAPATH to point to your Joomla! installation directory, the setting below works on default cPanel servers
    #if SERVERUSER and INSTALLDIR is correctly set
    
    JOOMLAPATH="/home/$SERVERUSER/public_html$INSTALLDIR"
    echo "Home Directory: /home/"$SERVERUSER 
    echo "Joomla Install:" $JOOMLAPATH
    
    #verify and accept before running chmod on Joomla! directories
    read -p "Continue with chmod (y/n)?"
        if [ $REPLY != "y" ]; then
        echo "Exiting..."
        exit 1
        fi
    
    chmod -v 0777 $JOOMLAPATH/administrator/components
    chmod -v 0777 $JOOMLAPATH/administrator/language
    chmod -v 0777 $JOOMLAPATH/administrator/language/en-GB
    chmod -v 0777 $JOOMLAPATH/administrator/language/overrides
    chmod -v 0777 $JOOMLAPATH/administrator/manifests/files
    chmod -v 0777 $JOOMLAPATH/administrator/manifests/libraries
    chmod -v 0777 $JOOMLAPATH/administrator/manifests/packages
    chmod -v 0777 $JOOMLAPATH/administrator/modules
    chmod -v 0777 $JOOMLAPATH/administrator/templates
    chmod -v 0777 $JOOMLAPATH/components
    chmod -v 0777 $JOOMLAPATH/images
    chmod -v 0777 $JOOMLAPATH/images/banners
    chmod -v 0777 $JOOMLAPATH/images/sampledata
    chmod -v 0777 $JOOMLAPATH/language
    chmod -v 0777 $JOOMLAPATH/language/en-GB
    chmod -v 0777 $JOOMLAPATH/language/overrides
    chmod -v 0777 $JOOMLAPATH/libraries
    chmod -v 0777 $JOOMLAPATH/media
    chmod -v 0777 $JOOMLAPATH/modules
    chmod -v 0777 $JOOMLAPATH/plugins
    chmod -v 0777 $JOOMLAPATH/plugins/authentication
    chmod -v 0777 $JOOMLAPATH/plugins/captcha
    chmod -v 0777 $JOOMLAPATH/plugins/content
    chmod -v 0777 $JOOMLAPATH/plugins/editors
    chmod -v 0777 $JOOMLAPATH/plugins/editors-xtd
    chmod -v 0777 $JOOMLAPATH/plugins/extension
    chmod -v 0777 $JOOMLAPATH/plugins/finder
    chmod -v 0777 $JOOMLAPATH/plugins/quickicon
    chmod -v 0777 $JOOMLAPATH/plugins/search
    chmod -v 0777 $JOOMLAPATH/plugins/system
    chmod -v 0777 $JOOMLAPATH/plugins/user
    chmod -v 0777 $JOOMLAPATH/templates
    chmod -v 0777 $JOOMLAPATH/configuration.php
    chmod -v 0777 $JOOMLAPATH/cache
    chmod -v 0777 $JOOMLAPATH/administrator/cache
    chmod -v 0777 $JOOMLAPATH/logs
    chmod -v 0777 $JOOMLAPATH/tmp
    
    exit 0
    
    
    • as result, all directories should be "Writable":
      administrator/components - Writable
      administrator/language - Writable
      administrator/language/en-GB - Writable
      administrator/language/overrides - Writable
      administrator/manifests/files - Writable
      administrator/manifests/libraries - Writable
      administrator/manifests/packages - Writable
      administrator/modules - Writable
      administrator/templates - Writable
      components - Writable
      images - Writable
      images/banners - Writable
      images/sampledata - Writable
      language - Writable
      language/en-GB - Writable
      language/overrides - Writable
      libraries - Writable
      media - Writable
      modules - Writable
      plugins - Writable
      plugins/authentication - Writable
      plugins/captcha - Writable
      plugins/content - Writable
      plugins/editors - Writable
      plugins/editors-xtd - Writable
      plugins/extension - Writable
      plugins/finder - Writable
      plugins/quickicon - Writable
      plugins/search - Writable
      plugins/system - Writable
      plugins/user - Writable
      templates - Writable
      configuration.php - Writable
      cache (Cache Directory) - Writable
      administrator/cache (Cache Directory) - Writable
      /logs (Log directory) - Writable
      /tmp (Temp directory) - Writable

    NOTE: there may be other directories that need the rw permission, I will add them as I encounter any other errors.



  • You may still encounter errors when installing extensions, errors like:

    An error has occurred.
    -1 Copy file failed

    Go to "System" > "Global Configuration" and select the "System" tab. Too see the logs generated by Joomla, turn the Debug System on (Yes) under "Debug Settings" and Save settings. Now try to install the component again and check the logs it may help finding the issue.

    An example:

    Joomla! Debug Console
    Errors

    Copy file failed
    Call stack
    # Function Location
    1 JAdministrator->dispatch() JROOT/administrator/index.php:54
    2 JError::raiseError() JROOT/administrator/includes/application.php:169
    3 JError::raise() JROOT/libraries/legacy/error/error.php:242



  • Sometimes there is no clear sign of what could cause the "-1 Copy file failed" message. Instead of reading the code and logs to find the directory or file without the right permissions, I found Akeeba Admin Tools very useful. After installing the Admin Tools component, go to "Components" > "Admin Tools" and select the "Joomla! Core" icon under Updates. Select "Reinstall 3.0.x".

    This will start a reinstall process (Write directly to files, don't use FTP) and will give you error messages that are much easier to understand. Ex.:

    Alert:

    The page at www. domain.com says:
    ERROR:
    Could not open /home/username/public_html/CONTRIBUTING.md for writing.

    Solution (cPanel CentOS):

    chown nobody:nobody /home/username/public_html/CONTRIBUTING.md
    
    or (change it back afterwards!)
    chmod 0777 /home/username/public_html/CONTRIBUTING.md
    
    ```*set the file permissions for Joomla to have write rights
    
    To set all files and directories to have the correct permissions, use the following while **INSIDE!** your home directory (/home/username/public_html/):
    

    find . -type f -exec chmod 644 {} ;
    find . -type d -exec chmod 755 {} ;



  • If all the above fails, here is what will help (cPanel CentOS) but make sure you understand file permissions:

    1. change all files to have nobody as owner and group
    (!replace [username] with your username - /home/this_is_your_username/public_html)

    chown -vR nobody:nobody /home/[username]/public_html
    
    

    2. give write permissions to /public_html folder

    chmod 0777 /home/[username]/public_html
    
    

    3. Reinstall (update) Joomla 3.0. If you have the latest Joomla installed, read about Admin Tools above, it will give the option to reinstall.

    4. restore permissions for /public_html folder

    chmod 0750 /home/[username]/public_html
    
    

    5. restore user and group for /public_html folder

    chown [username]:nobody /home/[username]/public_html
    
    

    6. you may want restore any other file-rights (read above)


 

Looks like your connection to H7 was lost, please wait while we try to reconnect.