Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, so I'm building a webserver and MySQL server from scratch...

Server A is going to have Apache and PHP Server B is going to have MySQL Both servers are running Ubuntu 12.04 LTS server

I plan on letting my family and friends have their own accounts (like a REAL web host!) and have decided to attempt to script the account creation process. Now, I can do simple one liners in Linux or DOS batch script the heck out of what I want to do, but full blown shell scripts scare me.

So, here's what I have... Will it work without catastrophic meltdown???

REM Lets prompt for the user info...

echo -n "Please enter the new username: "
read user
echo -n "Enter the default password: "
read password

REM Create the user and assign the password

sudo useradd $user
net user $user $password

REM Create them an account on the MySQL server

mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "create user '$user'@'%' identified by '$password';"
mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "create database $database;"
mysql [mysql-server-hostname] -u root@[hostname] -p [pass] -e "grant all on '$database'.* to '$user'@%;"

REM Making some dirs

mkdir $home
mkdir $home/public_html
mkdir $home/public_ftp
usermod -m -d $home

REM Gotta let them have access

chown -R $user:$user $home
chmod 755 $home/public_html
chmod 755 $home/public_ftp

REM Add to some groups

useradd -G sftp $user
useradd -G ftp $user
useradd -G ssh $user

/etc/init.d/apache2 restart
share|improve this question

closed as off-topic by gronostaj, slhck Jul 5 '13 at 19:48

  • This question does not appear to be about computer software or computer hardware within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

I'm asking if it will work because I've written up the script while at work, will test tonight once I get home... just anxious and I know there's at least a million things I didn't do right – Joshua Parnell Jul 5 '13 at 19:11
bash is not batch: change REM to # (or, to be fancy, add REM() { :; } – glenn jackman Jul 5 '13 at 19:17
This question is much too localized in its current form. Questions should be helpful to a broader audience, but posting a full script that you haven't tested and asking others to fix or review it is not within the scope of Super User. Please test the script, and if you have specific issues getting some things to work, feel free to ask about that instead by editing your question. Thanks. – slhck Jul 5 '13 at 19:48
You might want to post the question on – glenn jackman Jul 5 '13 at 19:49
up vote 0 down vote accepted

You're better off using an existing product. One that comes to mind is ISPConfig. I've used it in the past and has worked great. You can even provide a GUI to your end users to manage their portion of the server. You also have Quota restrictions on the number of domains and/or sites that can be hosted.

share|improve this answer
wow, ISPconfig is pretty awesome. A little different (I'm used to cPanel), especially with user management, but overall exactly what I was looking for! Thanks! – Joshua Parnell Jul 8 '13 at 13:19

Not the answer you're looking for? Browse other questions tagged .