I run Linux Mint, with Apache2, PHP and MySQL.  I've activated modules for Apache so that users' public_html can be used and that PHP-scripts can be run from them.  I installed WordPress in my public_html (i.e. ~/public_html/wordpress), but it didn't work fully.When I tried to change the background image or the header image, I got an error message that stated that a directory (either year/month or month/year) - where uploads are stored - could not be created.Obviously my web server doesn't have permission to create directories - and probably not to create files - in public_html or its subdirectories (like some directories under ~/public_html/wordpress).I'm therefore wondering what my options are here. Is there some module I must add or some config file I must fix, so that the web server can write?  Or must I perhaps change the owner and/or group of public_html - and its subdirectories (is there a way to ensure that subdirectories belong to the same owner/group)?  ...obviously without locking me out from making changes to my webpage.  Suggestions, advice and best practices very welcome.I know I probably would get less trouble if I installed WordPress as root under /var/www, but I would prefer to avoid that solution.
WordPress on LinuxMint: Can't create directory (or write file)
linux mint;apache httpd;php;wordpress
Obviously my web server doesn't have permission to create directories - and probably not to create files - in public_html or its subdirectories (like some directories under ~/public_html/wordpress).This is indeed very likely to be the problem. However you don't have to lock yourself out of the directory: there are many options that allows you to keep the files in that directory and allow the web server to write to it:Put yourself in the www-data group: sudo gpasswd -a $(whoami) www-data, and then change the group of the public_html directory: sudo chown -R $(whoami):www-data ~/public_html. This way both you and the web server will share that directory.Using the sticky bit: this will allow the web server to write files to the directory while also carrying the group of the folder, allowing you to still access the uploads directory as your user: chmod g+rws,o+rwx ~/public_html/wordpress/wp-content.Use ACLs to specify advanced permissions to allow the server to write to the directory: setfacl -m u:www-data:rwx ~/public_html/wordpress/wp-content. If you go that route, I recommand reading the manual for the ACLs as they are quite powerful and there's a lot you can do with them.WarningNote however that none of the above solutions are really well suited for a production environment, as all of them will allow any user on the server that's allowed to run PHP code will also have web server permissions and thus could drop malicious files in your uploads directory. Make sure to only make the uploads directory writable, and also make sure to put a .htaccess that disallows any code execution from that uploads directory. For production servers, I recommend running PHP as the user's system user using suexec, php-fpm, or any other way to execute the PHP code outside of the web server.