Comment to 'Website can't update, marketplace isn't accessible'
  • cd una
    

    1. Changing Ownership of Files and Directories

    sudo chown -R www-data:www-data .
    
    • chown -R www-data:www-data .: Changes the ownership of all files and directories in the current directory (.) to www-data, which is typically the user and group under which the web server (e.g., Apache or Nginx) runs.

    2. Setting Permissions for Directories

    sudo find ./ -type d -exec chmod 755 {} \;
    
    • find ./ -type d: Searches for all directories in the current directory.
    • chmod 755 {}: Sets 755 permissions for each directory, meaning the owner can read, write, and execute, while others can only read and execute.

    3. Setting Permissions for Specific Directories

    sudo find ./storage -type d -exec chmod 775 {} \;
    sudo find ./tmp -type d -exec chmod 775 {} \;
    
    • chmod 775 {}: Sets 775 permissions for the storage and tmp directories. The owner and group have read, write, and execute permissions, while others have only read and execute permissions.

    4. Setting Permissions for Specific Directories

    sudo chmod 775 ./cache
    sudo chmod 775 ./cache_public
    sudo chmod 775 ./logs
    sudo chmod 775 ./periodic
    sudo chmod 775 ./storage
    sudo chmod 775 ./tmp
    
    • chmod 775: Sets 775 permissions for certain directories (typically for directories that store dynamic data or temporary files), allowing full access for the owner and group, while only read and execute access is allowed for others.

    5. Setting Permissions for the inc

    sudo chmod 755 ./inc
    
    • Sets 755 permissions for the inc directory, which likely contains critical application files. It must be readable and executable, but not writable for others.

    6. Setting Permissions for GitHub Folders

    sudo chown -R root:root ./.github
    sudo chown -R root:root ./.git
    sudo chmod -R 755 ./.github
    sudo chmod -R 755 ./.git
    
    • Sets the owner and group to root:root for the .github and .git directories, and grants 755 permissions to allow public read and execute access.

    7. Setting Permissions for Files

    sudo find ./ -type f -exec chmod 644 {} \;
    
    • chmod 644 {}: Sets 644 permissions for all files, meaning the owner can read and write, while others can only read.

    8. Setting Execute Permissions for Specific Files

    sudo chmod +x ./plugins/ffmpeg/ffmpeg.exe
    sudo chmod +x ./periodic/cron.php
    sudo chmod +x ./image_transcoder.php
    
    • chmod +x: Grants execute permissions to ffmpeg.exe, cron.php, and image_transcoder.php files, which must be executable for the server to run these scripts or applications.

    9. Setting Permissions for GitHub Files

    sudo chown root:root ./.gitignore
    
    • Changes the owner of the .gitignore file to root:root.

    10. Setting Permissions for Configuration Files

    sudo chown root:root ./docker-compose.yml
    sudo chown root:root ./.env
    sudo chown root:root ./set_permissions.sh
    sudo chown root:root ./rm_cache.sh
    
    • Sets the owner and group to root:root for configuration files (docker-compose.yml, .env, set_permissions.sh, rm_cache.sh).

    11. Setting Execute Permissions for Script Files

    sudo chmod +x ./docker-compose.yml
    sudo chmod +x ./set_permissions.sh
    
    • Grants execute permissions to the docker-compose.yml and set_permissions.sh files (typically to make them executable on the server).
    vim set_permissions.sh
    
    1. Write your script: In the file, add your script. For example, you can add the following:
    #!/bin/bash
    # Set permissions for all files and directories
    
    sudo chown -R www-data:www-data .
    sudo find ./ -type d -exec chmod 755 {} \;
    sudo find ./storage -type d -exec chmod 775 {} \;
    sudo chmod 775 ./cache
    
    1. After adding the script, save the file and exit the editor:
    • In nano, press CTRL + X, then press Y to confirm saving, and Enter to save the file.
    •  In vim After you’ve written or edited your content:
    • Press Esc to exit insert mode.
    • Type :wq! and press Enter.
    • w = write (save the file)
    • q = quit (close the editor)
    • ! = force the action (useful if the file is read-only or has restrictions)

    2. Make the script executable

    Now, you need to make the set_permissions.sh script executable:

    chmod +x set_permissions.sh 
    

    This command adds the execute (+x) permission to the script, allowing it to be run as a program.

    3. Execute the script

    Once the script is executable, you can run it like this:

    ./set_permissions.sh 
    

    If you need to run it with superuser privileges (e.g., if it includes commands like sudo), you can execute it with sudo:

    sudo ./set_permissions.sh 
    

    This will execute the script with root privileges.

    4. Verify the execution

    After running the script, you can check the permissions of the files and directories to ensure that the changes were applied correctly. You can use the ls -l command to list the files and their permissions:

    ls -l 
    

    This will show you the permissions for each file and directory.