Hallo liebe Mitforisten!
[Vorab: Ich bediene Plesk und alle Accounts von Windows 10 via FTP into WLC - das hat allenfalls das seit ewigen Zeiten implementierte cmd.exe, also KEINE Linux-Ubuntu-Befehlszeile, KEIN "sudo" etc! Allenfalls habe ich eine Befehlszeile im Totalcommander, ob der auch Unix-Befehle nimmt, who knows... ich nicht.]
Ich habe im Zuge eines Umzugs meine Files in ZIP mit 268 MB, das im WCP unter Plesk unpacked und las anschließend bei Aufruf der Website
Ich gucke in den Webspace: KEIN FILE, KEIN FOLDER hat eine Berechtigung bzw. permission!
Dann habe ich wenigstens für die index.htm eine permission 0644 im Kontextmenü einzustellen versucht - natürlich fehlerhaft, ich kenne nur chmod am File. Egal, Hauptsache, bei Aufruf der Seite ist was zu sehen.
Dann habe ich natürlich gegoogelt und immerhin eine Übersicht über Chmod gefunden, aber das ist ja nur für einzelne Files praktikabel. Also habe ich AI befragt (gekürzt):
Q: This [= setting permissions manually] is a lot of handy work and a lot of errors can happen, i. e. it is an error-prone process, because the cms I use has dozens and dozens of subfolders and thousend or more files, beside my user files wich include hundreds of images. Isn't there any way to configure the EMPTY webspace so that permissions AUTOMATIcALLY are given by the system during the unpacking the zip which contains 268 megabyte files (and folders)?
MSCP: Yes, there is a way to configure your webspace so that permissions are automatically set during the unpacking of a ZIP file. This can be achieved by using default umask settings or custom scripts on the server. Here's how you can approach it:
Set Default umask:
The umask (user file-creation mode mask) determines the default permissions for newly created files and directories.
If you have access to the server's configuration, you can set the umask to ensure files are created with 0664 and directories with 0755.
For example, in a Linux environment, you can set the umask in the shell configuration file (e.g., .bashrc or .bash_profile) or in the FTP server configuration.
Use a Custom Unpacking Script:
Instead of relying on manual unpacking, you can create a script that unpacks the ZIP file and sets the desired permissions automatically.
For example, a simple shell script could:
Unpack the ZIP file using unzip.
Recursively set permissions for files (chmod 664) and directories (chmod 755).
Plesk File Manager Settings:
If you're using Plesk, you can check if there are options to set default permissions for uploaded files and directories. Some hosting providers allow you to configure these settings in the control panel.
CMS-Specific Configuration:
Some CMS platforms have built-in tools or plugins that handle file uploads and permissions. Check if your CMS offers such features.
By automating the process, you can minimize errors and ensure consistent permissions across all files and directories. Let me know if you'd like help with a specific script or configuration!
[Ich frage nach dem Script:]
Certainly! Below is an example of a shell script that you can use on your server to unpack a ZIP file and set permissions for files and directories automatically:
bash:
#!/bin/bash
# Define the ZIP file and target directory
ZIP_FILE="your-file.zip"
TARGET_DIR="/path/to/your/target/directory"
# Unpack the ZIP file
unzip "$ZIP_FILE" -d "$TARGET_DIR"
# Navigate to the target directory
cd "$TARGET_DIR" || exit
# Set permissions for files (0664)
find . -type f -exec chmod 0664 {} +
# Set permissions for directories (0755)
find . -type d -exec chmod 0755 {} +
echo "Files and directories unpacked and permissions set successfully."
```
Alles anzeigen
### Explanation:
1. **Unpack the ZIP file**: The `unzip` command extracts the contents of the ZIP file into the specified target directory.
2. **Set file permissions**: `find . -type f -exec chmod 0664 {} +` finds all files and sets their permissions to `0664`.
3. **Set directory permissions**: `find . -type d -exec chmod 0755 {} +` finds all directories and sets their permissions to `0755`.
### How to Use:
- Save this script as a file (e.g., `set_permissions.sh`) on your server.
- Upload the ZIP file to your server and place it in the same directory as the script.
- Make the script executable by running: `chmod +x set_permissions.sh`.
- Execute the script: `./set_permissions.sh`.
This will ensure that all files and directories extracted from the ZIP file have the appropriate permissions applied automatically.
;;;;
Was sagt ihr dazu? Eigentlich müsste Plesk doch eine implementierte Funktion haben, die einfach (mit Windows FTP
im WCP aktivierbar ist, aber wo?