Using Webmin to Add Users, Create MySQL Databases, and Other Tasks
Christopher J. Pace
Webmin is a powerful and easy to use web-based software that allows you to easily add user accounts on your Linux server, as well as perform basic Linux administrative duties. Available though http://www.webmin.com, Webmin can be easily installed via two commands (Debian/Ubuntu):
wget -c http://prdownloads.sourceforge.net/webadmin/webmin_1.450_all.deb dpkg -i webmin_1.450_all.deb
Once Webmin is installed, the Webmin server service will run at system startup. To access Webmin, enter the address https://servername:10000 in your browser address bar. You will be presented with a security warning at this point, which you should allow (the server warning will simply state that the certificate is not signed by a trusted third party). At the Webmin login screen, enter the root username and password for your server:
Once you are logged into Webmin, you will be presented with the main server configuration screen. It is at this screen that you can configure all of the various services running on your Linux server, as well as add users, and perform simple system maintinance.
Most of the work will be spent in the Servers tab, which will allow you to configure Apache and MySQL, as well as any of the other services running on your Linux server. However, we will first add users onto the Linux server.
To add or remove users or groups from your Linux server, first click the System button on the navigational pane on the left, and then select Users and Groups:
Once you are on the Users and Groups page on Webmin, you can easily add or remove individual users from your Linux server. To do this, click on the Create User link at the top and bottom of the users list:
From here, you can select the user's home directory (/var/web_hosts/USERNAME), as well as enter the user's password. In addition, you can also change the user's default group membership (useful if a group of users are working on a particular website or project), and a variety of other options. In particular, we want to make sure that the option "Create Home Directory" is enabled, since we will need to have a home directory of /var/web_hosts/username of our user on this server.
Once you have entered all of the information, click "Create" to create the user account. Once successfull, you are now returned to the main Users and Groups page. To remove a user account, click on the checkbox next to the user account, and click "Delete Selected Users".
From here, you will be asked to confirm whether or not you wish to delete the selected user, as well as delete the user's data. Typically, you will want to delete the user's data as well as the user account, but Webmin gives you the option of both.
Once the user account is sucessfully deleted, you will then have the option of returning to the Users and Groups page. To add or remove user groups, select the "Local Groups" tab at the top of the Users and Groups page.
To add an additional Virtual Host on the Apache server, click on the "Servers" link on the left navigational pane, and then click on "Apache Webserver".
From this page, you can then click on "Create virtual host" to create an Apache Virtual Host. Of particular note in this section is the need to specify the server name (in our example, webmin_test.example.com), the DocumentRoot directory (in our case, /var/web_hosts/webmin_test), and we also want to copy the existing directives from another site (this will also copy over the PHP-specific settings, such as loading index.php with the DirectoryIndex directive). For the existing site template, use a working Virtual Host (in our example below I selected to use the "Automatic" Virtual Host- rarely is this what you will want to copy directives from). Once all of the pertinent information has been entered (don't forget to enter a specific IP address, if you only want this Virtual Host to listen on one IP address- otherwise leave the default "Any address" alone), you can click "Create Now" to create the Virtual Host.
Once you have created the Virtual Host, you must then enable the host, and restart Apache. To do this, click the "Apply Changes" link at the top right corner of the Apache Webserver configuration screen. Once you have done this, the Virtual Host should now work (don't forget to edit your local hosts file if necessary in order to test functionality prior to making DNS changes- /etc/hosts in Unix/Linux or %SYSTEMROOT%\System32\drivers\etc\hosts in Windows NT/2000/XP/Vista). To edit an existing Virtual Host (such as to change the directory that host uses for the DocumentRoot), click on the "Existing virtual hosts" link at the top of the Apache Webserver configuration page, and then click on the Virtual Host that you want to modify. Once you have made the desired changes, click "Save" to save the Virtual Host settings. In addition, you can also specify a custom log file for the Virtual Host (recommended), by clicking on the "Log Files" button on the Virtual Server Options page.
To manage the MySQL server installed on your Linux server, click on the "Servers" link on the left navigational pane, then click "MySQL Database Server".
From this main view, you can add new databases, add new MySQL users, drop databases, and change database permissions. In addition, you can also easily change MySQL system variables. To add a new MySQL user, click the "User Permissions" button, and then click "Create a new user".
From here, you can enter the desired user name, as well as the desired password. Typically, you will want to insert values similar to the values below. All permissions should be selected if this user will be an "administrator" of a database. In addition, the value "localhost" is extremely important as well.
Finally, click "Create" to create this user account on the MySQL server.
To create a MySQL database, click on the "Create New Database" while on the main MySQL configuration page. From here, you can enter the MySQL database name, and also create a table structure, if desired. For web applications, this is typically not necessary. In addition, you can also change the default character set if required.
Once you have created a new MySQL database, you must now assign permissions to this database. To do this, click on the "Database Permissions" button on the main MySQL configuration page. From there, click "Create new database permissions".
From here, you will enter the database name that you are creating these permissions for (in our example, it is the test1234 database that we created earlier), as well as also enter the desired username that we will assign as the "administrator" to this database (also, our user test1234). Again, make sure that you enter the hostname 'localhost' under Hosts, otherwise the permissions will not successfully work on the database. Finally, select all of the available database permissions, and click "Create".
Now that you have sucessfully created a new database, a new user, and set up a database permissions scheme for that database, your web application installation should be seamless. However, let's say that you now want to delete the database that we created, as well as the database user, test1234. To delete, or drop a database, click on the main MySQL configuration page, then click the checkbox next to the desired database, and finally click "Drop Selected Databases". You will then be presented with a confirmation on the next page (which does not confirm the database name, so be careful!). Clicking "Drop Databases" on this confirmation page will complete the database deletion. Please note that there is not an "undo" feature, so drop with care!
To delete a MySQL user, return to the main MySQL configuration page, and then click on "User Permissions". Click on the checkbox next to the username to delete, and then click "Delete Selected".
Finally, you will also want to remove the database permissions entry that you created earlier to grant access for test1234 on the test1234 database. To do this, click on "Database Permissions" on the main MySQL configuration page. From here, click the checkbox next to the permissions entry you wish to remove, and then click "Delete Selected".
For further reading on what Webmin can enable you to do with your server, please visit the following resources: