Solving the “Your Web Server is Configured Incorrectly” Error in Magento
Introduction
When migrating or duplicating a live Magento setup to another domain on the same server, encountering the dreaded “Your web server is configured incorrectly” error can be frustrating. This error message occurs when sensitive configuration files are accessible from outside sources due to improper server settings.
In this guide, we’ll walk you through identifying and resolving this issue step-by-step.
Understanding the Error
The error occurs because Magento detects that certain critical system files or directories have permissions set incorrectly. These files contain sensitive information like database credentials, API keys, and other environment-specific details. If accessible via web requests (i.e., their permissions are too open), it poses a significant security risk.
Checking File Permissions the Right Way
Before diving into the solution, let’s ensure we’ve checked file permissions correctly:
-
SSH into your server.
-
Navigate to the Magento root directory:
cd /path/to/magento -
Verify file permissions using
ls -la:ls -la -
Critical directories should have permissions set as follows:
app/etc: 750 (read, write for owner; no access for group or world)var: 770 (read, write for owner and group)media: 770.htaccessfiles: 644
Resolving the Issue on a Fresh Setup
Step 1: Set Folders to Correct Permissions
If you’ve followed the above steps correctly but still encounter issues, proceed with setting permissions explicitly:
find . -type d -exec chmod 750 {} \;
This command recursively sets directory permissions to 750.
Step 2: Ensure Files Have Appropriate Permissions
For critical files like app/etc/config.php and var/.htaccess:
chmod 640 app/etc/config.php
chmod 640 var/.htaccess
Step 3: Check User and Group Ownership
Ensure the user running PHP (usually apache or www-data) owns these directories:
chown -R apache:apache /path/to/magento
Conclusion
Resolving this issue requires a systematic approach to checking and setting file permissions correctly. Always remember that security is paramount when dealing with e-commerce platforms like Magento.
If you’re still facing issues or need further assistance, consider reaching out to our team at Laravel Company. Our expert developers can help diagnose and fix complex permission problems on your Magento setup.
Happy coding!