Mac下用XAMPP本地部署Laravel遇UnexpectedValueException权限错误求助
Hey there, this is a super common snag when setting up Laravel on XAMPP for Mac—let’s get this sorted out step by step! That UnexpectedValueException is telling you your XAMPP Apache server doesn’t have write access to Laravel’s critical storage and bootstrap/cache directories (these are where logs, cache files, and other runtime data live).
1. Set Proper Directory Permissions
First, fire up your Terminal and navigate straight to your Laravel project root:
cd /opt/lampp/htdocs/app
Run these two commands to lock in the right access levels:
- The first command sets safe, standard permissions: read/write/execute for the owner and group, read/execute for others (no overexposing your files):
sudo chmod -R 775 storage bootstrap/cache - The second command ensures the XAMPP Apache user owns these directories (Mac’s XAMPP runs Apache as the
_wwwuser/group by default):sudo chown -R _www:_www storage bootstrap/cache
2. Verify the Fix
Refresh your localhost:8080/app/public page after running those commands—your error should vanish! If it’s still hanging around, double-check:
- Did you run the commands from the correct project root (
/opt/lampp/htdocs/app)? - Is
_wwwthe right user/group? If not, open XAMPP’s Apache config file (/opt/lampp/etc/httpd.conf) and look for theUserandGroupdirectives to confirm the correct owner.
A Quick Note on Security
You might see random suggestions to use chmod -R 777 storage—don’t do this. It gives full read/write access to every user on your system, which is a massive security risk (especially if you ever deploy this app to production). Stick with the 775 + proper ownership method—it’s safe and industry standard.
内容的提问来源于stack exchange,提问作者Vikash PR

