Fouten met geweigerde toestemming
Problemen met bestands- en maprechten komen vaak voor bij XOOPS-installaties, vooral na upload- of servermigratie. Deze handleiding helpt bij het diagnosticeren en oplossen van toestemmingsproblemen.
Bestandsrechten begrijpen
Section titled “Bestandsrechten begrijpen”Basisprincipes van Linux/Unix-machtigingen
Section titled “Basisprincipes van Linux/Unix-machtigingen”Bestandsrechten worden weergegeven als driecijferige codes:
rwxrwxrwx||| ||| |||||| ||| +-- Others (world)||| +------ Group+--------- Owner
r = read (4)w = write (2)x = execute (1)
755 = rwxr-xr-x (owner full, group read/execute, others read/execute)644 = rw-r--r-- (owner read/write, group read, others read)777 = rwxrwxrwx (everyone full access - NOT RECOMMENDED)Veelvoorkomende toestemmingsfouten
Section titled “Veelvoorkomende toestemmingsfouten””Toestemming geweigerd” in Uploaden
Section titled “”Toestemming geweigerd” in Uploaden”Warning: fopen(/var/www/html/xoops/uploads/file.jpg): failed to open stream:Permission denied in /var/www/html/xoops/class/file.php on line 42”Kan bestand niet schrijven"
Section titled “”Kan bestand niet schrijven"”Error: Unable to write file to /var/www/html/xoops/cache/"Kan map niet aanmaken”
Section titled “"Kan map niet aanmaken””Error: mkdir(/var/www/html/xoops/uploads/temp/): Permission deniedKritieke XOOPS-mappen
Section titled “Kritieke XOOPS-mappen”Directory’s waarvoor schrijfrechten vereist zijn
Section titled “Directory’s waarvoor schrijfrechten vereist zijn”| Telefoonboek | Minimaal | Doel |
|---|---|---|
/uploads | 755 | Gebruikersuploads |
/cache | 755 | Cachebestanden |
/templates_c | 755 | Samengestelde sjablonen |
/var | 755 | Variabele gegevens |
mainfile.php | 644 | Configuratie (leesbaar) |
Linux/Unix-probleemoplossing
Section titled “Linux/Unix-probleemoplossing”Stap 1: Controleer de huidige machtigingen
Section titled “Stap 1: Controleer de huidige machtigingen”# Check file permissionsls -l /var/www/html/xoops/
# Check specific filels -l /var/www/html/xoops/mainfile.php
# Check directory permissionsls -ld /var/www/html/xoops/uploads/Stap 2: Identificeer de webservergebruiker
Section titled “Stap 2: Identificeer de webservergebruiker”# Check Apache userps aux | grep -E '[a]pache|[h]ttpd'# Usually: www-data (Debian/Ubuntu) or apache (RedHat/CentOS)
# Check Nginx userps aux | grep -E '[n]ginx'# Usually: www-data or nginxStap 3: Eigendom herstellen
Section titled “Stap 3: Eigendom herstellen”# Set correct ownership (assuming www-data user)sudo chown -R www-data:www-data /var/www/html/xoops/
# Fix only web-writable directoriessudo chown www-data:www-data /var/www/html/xoops/uploads/sudo chown www-data:www-data /var/www/html/xoops/cache/sudo chown www-data:www-data /var/www/html/xoops/templates_c/sudo chown www-data:www-data /var/www/html/xoops/var/Stap 4: machtigingen herstellen
Section titled “Stap 4: machtigingen herstellen”Optie A: Beperkende machtigingen (aanbevolen)
Section titled “Optie A: Beperkende machtigingen (aanbevolen)”# All directories: 755 (rwxr-xr-x)find /var/www/html/xoops -type d -exec chmod 755 {} \;
# All files: 644 (rw-r--r--)find /var/www/html/xoops -type f -exec chmod 644 {} \;
# Except writable directorieschmod 755 /var/www/html/xoops/uploads/chmod 755 /var/www/html/xoops/cache/chmod 755 /var/www/html/xoops/templates_c/chmod 755 /var/www/html/xoops/var/Optie B: Alles-in-één-script
Section titled “Optie B: Alles-in-één-script”#!/bin/bashXOOPS_PATH="/var/www/html/xoops"WEB_USER="www-data"
echo "Fixing XOOPS permissions..."
# Set ownershipsudo chown -R $WEB_USER:$WEB_USER $XOOPS_PATH
# Set directory permissionsfind $XOOPS_PATH -type d -exec chmod 755 {} \;
# Set file permissionsfind $XOOPS_PATH -type f -exec chmod 644 {} \;
# Ensure writable directorieschmod 755 $XOOPS_PATH/uploads/chmod 755 $XOOPS_PATH/cache/chmod 755 $XOOPS_PATH/templates_c/chmod 755 $XOOPS_PATH/var/
echo "Done! Permissions fixed."Toestemmingsproblemen per directory
Section titled “Toestemmingsproblemen per directory”Uploadmap
Section titled “Uploadmap”Probleem: Kan geen bestanden uploaden
# Solutionsudo chown www-data:www-data /var/www/html/xoops/uploads/chmod 755 /var/www/html/xoops/uploads/find /var/www/html/xoops/uploads -type f -exec chmod 644 {} \;find /var/www/html/xoops/uploads -type d -exec chmod 755 {} \;Cachemap
Section titled “Cachemap”Probleem: Cachebestanden worden niet geschreven
# Solutionsudo chown www-data:www-data /var/www/html/xoops/cache/chmod 755 /var/www/html/xoops/cache/Sjablonencache
Section titled “Sjablonencache”Probleem: Sjablonen worden niet gecompileerd
# Solutionsudo chown www-data:www-data /var/www/html/xoops/templates_c/chmod 755 /var/www/html/xoops/templates_c/Windows-probleemoplossing
Section titled “Windows-probleemoplossing”Stap 1: Controleer de bestandseigenschappen
Section titled “Stap 1: Controleer de bestandseigenschappen”- Klik met de rechtermuisknop op bestand → Eigenschappen
- Klik op het tabblad “Beveiliging”.
- Klik op de knop “Bewerken”.
- Selecteer een gebruiker en controleer de machtigingen
Stap 2: Verleen schrijfrechten
Section titled “Stap 2: Verleen schrijfrechten”Via GUI:
Section titled “Via GUI:”1. Right-click folder → Properties2. Select "Security" tab3. Click "Edit"4. Select "IIS_IUSRS" or "NETWORK SERVICE"5. Check "Modify" and "Write"6. Click "Apply" and "OK"Via opdrachtregel (PowerShell):
Section titled “Via opdrachtregel (PowerShell):”# Run PowerShell as Administrator
# Grant IIS app pool permissions$path = "C:\inetpub\wwwroot\xoops\uploads"$acl = Get-Acl $path$rule = New-Object System.Security.AccessControl.FileSystemAccessRule( "IIS_IUSRS", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow")$acl.SetAccessRule($rule)Set-Acl -Path $path -AclObject $aclPHP-script om machtigingen te controleren
Section titled “PHP-script om machtigingen te controleren”<?php$paths = [ XOOPS_ROOT_PATH . '/uploads' => 'uploads', XOOPS_ROOT_PATH . '/cache' => 'cache', XOOPS_ROOT_PATH . '/templates_c' => 'templates_c', XOOPS_ROOT_PATH . '/var' => 'var', XOOPS_ROOT_PATH . '/mainfile.php' => 'mainfile.php'];
echo "<h2>XOOPS Permission Check</h2>";echo "<table border='1'>";echo "<tr><th>Path</th><th>Readable</th><th>Writable</th></tr>";
foreach ($paths as $path => $name) { $readable = is_readable($path) ? 'YES' : 'NO'; $writable = is_writable($path) ? 'YES' : 'NO';
echo "<tr>"; echo "<td>$name</td>"; echo "<td style='background: " . ($readable === 'YES' ? 'green' : 'red') . "'>$readable</td>"; echo "<td style='background: " . ($writable === 'YES' ? 'green' : 'red') . "'>$writable</td>"; echo "</tr>";}
echo "</table>";?>Beste praktijken
Section titled “Beste praktijken”1. Principe van de minste privileges
Section titled “1. Principe van de minste privileges”# Only grant necessary permissions# Don't use 777 or 666
# Badchmod 777 /var/www/html/xoops/uploads/ # Dangerous!
# Goodchmod 755 /var/www/html/xoops/uploads/ # Secure2. Back-up vóór wijzigingen
Section titled “2. Back-up vóór wijzigingen”# Backup current stategetfacl -R /var/www/html/xoops > /tmp/xoops-acl-backup.txtSnelle referentie
Section titled “Snelle referentie”# Quick fix (Linux)sudo chown -R www-data:www-data /var/www/html/xoops/find /var/www/html/xoops -type d -exec chmod 755 {} \;find /var/www/html/xoops -type f -exec chmod 644 {} \;Gerelateerde documentatie
Section titled “Gerelateerde documentatie”- White-Screen-of-Death - Andere veel voorkomende fouten
- Databaseverbindingsfouten - Databaseproblemen
- ../../01-Aan de slag/Configuratie/Systeeminstellingen - XOOPS-configuratie
Laatst bijgewerkt: 31-01-2026 Van toepassing op: XOOPS 2.5.7+ Besturingssysteem: Linux, Windows, macOS