Błędy odmowy dostępu
Problemy z uprawnieniami plików i katalogów są powszechne w instalacjach XOOPS, szczególnie po przesłaniu lub migracji serwera. Ten przewodnik pomaga zdiagnozować i rozwiązać problemy z uprawnieniami.
Understanding File Permissions
Dział zatytułowany „Understanding File Permissions”Linux/Unix Permission Basics
Dział zatytułowany „Linux/Unix Permission Basics”File permissions are represented as three-digit 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)Common Permission Errors
Dział zatytułowany „Common Permission Errors””Permission denied” in Upload
Dział zatytułowany „”Permission denied” in Upload”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”Unable to write file"
Dział zatytułowany „”Unable to write file"”Error: Unable to write file to /var/www/html/xoops/cache/"Cannot create directory”
Dział zatytułowany „"Cannot create directory””Error: mkdir(/var/www/html/xoops/uploads/temp/): Permission deniedCritical XOOPS Directories
Dział zatytułowany „Critical XOOPS Directories”Directories Requiring Write Permissions
Dział zatytułowany „Directories Requiring Write Permissions”| Directory | Minimum | Purpose |
|---|---|---|
/uploads | 755 | User uploads |
/cache | 755 | Cache files |
/templates_c | 755 | Compiled templates |
/var | 755 | Variable data |
mainfile.php | 644 | Configuration (readable) |
Linux/Unix Troubleshooting
Dział zatytułowany „Linux/Unix Troubleshooting”Step 1: Check Current Permissions
Dział zatytułowany „Step 1: Check Current Permissions”# 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/Step 2: Identify Web Server User
Dział zatytułowany „Step 2: Identify Web Server User”# 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 nginxStep 3: Fix Ownership
Dział zatytułowany „Step 3: Fix Ownership”# 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/Step 4: Fix Permissions
Dział zatytułowany „Step 4: Fix Permissions”Option A: Restrictive Permissions (Recommended)
Dział zatytułowany „Option A: Restrictive Permissions (Recommended)”# 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/Option B: All-at-once Script
Dział zatytułowany „Option B: All-at-once 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."Permission Issues by Directory
Dział zatytułowany „Permission Issues by Directory”Uploads Directory
Dział zatytułowany „Uploads Directory”Problem: Can’t upload files
# 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 {} \;Cache Directory
Dział zatytułowany „Cache Directory”Problem: Cache files not being written
# Solutionsudo chown www-data:www-data /var/www/html/xoops/cache/chmod 755 /var/www/html/xoops/cache/Templates Cache
Dział zatytułowany „Templates Cache”Problem: Templates not compiling
# Solutionsudo chown www-data:www-data /var/www/html/xoops/templates_c/chmod 755 /var/www/html/xoops/templates_c/Windows Troubleshooting
Dział zatytułowany „Windows Troubleshooting”Step 1: Check File Properties
Dział zatytułowany „Step 1: Check File Properties”- Right-click file → Properties
- Click “Security” tab
- Click “Edit” button
- Select user and verify permissions
Step 2: Grant Write Permissions
Dział zatytułowany „Step 2: Grant Write Permissions”Via GUI:
Dział zatytułowany „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 Command Line (PowerShell):
Dział zatytułowany „Via Command Line (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 to Check Permissions
Dział zatytułowany „PHP Script to Check Permissions”<?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>";?>Best Practices
Dział zatytułowany „Best Practices”1. Principle of Least Privilege
Dział zatytułowany „1. Principle of Least Privilege”# 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. Backup Before Changes
Dział zatytułowany „2. Backup Before Changes”# Backup current stategetfacl -R /var/www/html/xoops > /tmp/xoops-acl-backup.txtQuick Reference
Dział zatytułowany „Quick Reference”# 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 {} \;Related Documentation
Dział zatytułowany „Related Documentation”- White-Screen-of-Death - Other common errors
- Database-Connection-Errors - Database issues
- ../../01-Getting-Started/Configuration/System-Settings - XOOPS configuration
Last Updated: 2026-01-31 Applies To: XOOPS 2.5.7+ OS: Linux, Windows, macOS