13 Jun, 2014

Ubuntu with Webmin and Virtualmin, public_html owners

On a clasical Linux Ubuntu Server LAMP (Linux, Apache, Mysql, PHP) with Webmin and Virtualmin installed, when creating subdomains, sometimes files and folders ownership issues appear. In WordPress, this is translated into trouble while updateing plugins, wordpress itself or even when running the install script after uploading the files via FTP. A quick remedy for this problem is:

chown -R www-data:www-data /home/<user>/domains/<subdomain>/public_html
chmod -R 0755 /home/<user>/domains/<subdomain>/public_html

A more elaborate way is using a bash script. Here is an example:

Save the above code into a file and then run it using the first command of the following to make it executable and the second to execute it every time you need:

chmod +x /path/to/file.sh
./path/to/file.sh user subdomain.domain.com