I currently have a small Ubuntu Server 12.04 machine (test environment) with about 3 non-root users created. Each user has their own
public_html directory under their
home...thereby allowing them to deploy multiple apps as named virtual hosts. Each user belongs to the Apache
www-data group, set up as follows:
sudo usermod -a -G www-data [username] sudo chown -R [username]:www-data /home/[username]/public_html sudo chmod 2750 /home/[username]/public_html
Now as the root user, I am in the process of creating a bash script that will automate the creation of the folders for the VirtualHost under a prompted user's
public_html as well as creating an associated entry in
/etc/apache2/sites-available/. The script (run with
sudo) will prompt for the user (
$uzer) and the desired virtual host name (
$vhost). So far after running a few checks I eventually get to the following...
mkdir -vp /home/$uzer/public_html/$vhost mkdir -vp /home/$uzer/public_html/$vhost/www mkdir -vp /home/$uzer/public_html/$vhost/logs mkdir -vp /home/$uzer/public_html/$vhost/backups
I need to change the ownership of these newly created folders, so I'm unsure whether I should be doing the following:
chown -vR $uzer:www-data /home/$uzer/public_html/$vhost chmod 2750 /home/$uzer/public_html/$vhost
- Is my folder structure correct/ideal?
- I know I've used recursive (
-R) option, but should I be repeating the same for
- Am I correct in thinking that the chmod above is probably redundant?
- Is there a way I can run the
mkdircommands as the user