I get a 500 error, it was after I tried to set chown to www-data over my html folder.
OpenEMR Version
7.0.1
Browser:
I’m using:Chrome
Operating System
I’m using: Ubuntu
Search
Logs
PHP Fatal error: Uncaught RuntimeException: Directory "/var/www/html/sites/default/documents/smarty/gacl" was not created in /var/www/html/interface/globals.php:243\nStack trace:\n#0 /var/www/html/interface/login/login.php(41): require_once()\n#1 {main}\n thrown in /var/www/html/interface/globals.php on line 243
I ran ls-l
/var/www/html/sites/default/documents/smarty# ls -l
total 8
drwxr-xr-x 2 www-data www-data 4096 Sep 17 15:59 gacl
drwxr-xr-x 7 www-data www-data 4096 Sep 17 12:47 main
I have fixed it.
I think it is not the best practice, but I have set chown -R root:root /var/www then set it to chmod -R 777 /var/www.
Is there a script that may set appropiate folder and file permissions. Or there is a guide somewhere?
I’m glad to hear that you were able to resolve the issue you were facing with the 500 error. However, it’s important to note that setting folder and file permissions to 777 (read, write, and execute for everyone) is generally not recommended for security reasons, as it grants wide-open access to your files and directories.
Instead of setting such permissive permissions, you can follow best practices for setting up permissions in a more secure way. Here’s a more secure approach:
Ownership: Change ownership of the web directory to the web server user (www-data in your case). You already did this with the chown command:
chown -R www-data:www-data /var/www/html
Directory Permissions: Set the directory permissions to 755. This allows the owner (www-data) to read, write, and execute while giving read and execute permissions to others:
find /var/www/html -type d -exec chmod 755 {} \;
File Permissions: Set the file permissions to 644. This allows the owner (www-data) to read and write while giving read-only access to others:
find /var/www/html -type f -exec chmod 644 {} \;
This is a more secure setup that follows the principle of least privilege, ensuring that only necessary permissions are granted. It’s essential to prioritize security when managing file and directory permissions.
Remember to always exercise caution when changing permissions on your server, as improper configuration can introduce security vulnerabilities.