Fixing session_start(): Permission Denied (13) in XAMPP — SELinux/AppArmor Restrictions
Check SELinux Status
SELinux (Security-Enhanced Linux) enforces security policies that can restrict access to session files.
For closely related XAMPP and session_start topics, see XAMPP session_start — sysadmin guide variant, session_start() failed: Permission denied (13), and Verify PHP Configuration (php.ini).
Run:
sestatus
If it returns:
SELinux status: enabled
SELinux mode: enforcing
SELinux is blocking access to /opt/lampp/temp/.
Allow Apache/PHP to Access the Session Directory
Since PHP sessions are stored in /opt/lampp/temp/, grant the necessary SELinux permissions.
Check SELinux Logs for Denied Requests
Run:
sudo journalctl -xe | grep AVC
or:
sudo grep "denied" /var/log/audit/audit.log
Look for entries related to /opt/lampp/temp/.
Grant Access to the Session Directory
Run the following command:
sudo chcon -R -t httpd_sys_rw_content_t /opt/lampp/temp/
This assigns the correct SELinux context to allow Apache (httpd) to read and write session files.
Check and Modify AppArmor (Ubuntu/Debian)
If you're running Ubuntu or Debian, AppArmor may be blocking PHP.
Check AppArmor Profiles
Run:
sudo aa-status
If AppArmor is enforcing restrictions on /opt/lampp/temp/, switch it to complain mode:
sudo aa-complain /usr/sbin/apache2
sudo aa-complain /usr/sbin/php-fpm
Restart Apache & PHP
sudo systemctl restart apache2
sudo systemctl restart php8.0-fpm
Test again to see if the session issue is resolved.
Disable SELinux Temporarily (For Testing)
If SELinux still blocks access, temporarily disable it to confirm.
Run:
sudo setenforce 0
Then restart XAMPP:
sudo /opt/lampp/lampp restart
If sessions now work, then SELinux is the problem, and you should configure SELinux properly instead of disabling it permanently.
Check & Fix File Permissions
If SELinux/AppArmor is not the issue, fix the session folder permissions.
sudo chmod -R 770 /opt/lampp/temp/
sudo chown -R daemon:daemon /opt/lampp/temp/
For Apache on Linux:
sudo chown -R www-data:www-data /opt/lampp/temp/
Restart services and test again.
Debugging Further Issues
If the error persists, check logs:
- Check Apache Logs:
sudo tail -f /opt/lampp/logs/error_log - Check PHP Logs:
sudo tail -f /opt/lampp/logs/php_error_log - Check System Logs for Security Blocks:
sudo dmesg | grep php
Summary of Fixes
| Issue | Fix |
|---|---|
| SELinux blocking session directory | chcon -R -t httpd_sys_rw_content_t /opt/lampp/temp/ |
| AppArmor restricting access | aa-complain /usr/sbin/apache2 |
| Wrong folder permissions | chmod -R 770 /opt/lampp/temp/ |
| Incorrect ownership | chown -R daemon:daemon /opt/lampp/temp/ |
| Still not working? | setenforce 0 (temporary SELinux disable) |
By following these server-level fixes, you can resolve SELinux/AppArmor restrictions and restore PHP session functionality in XAMPP.


