Create linux user using php?

linux, php, variables

Solution

You should not create Unix user account for FTP service, You should integrate your `proFTP` server to use `MySQL` for authentication (store account in MySQL) so in that case you don't need to create Unix account and it would be far better and safe solution:

proFTP with MySQL

Problem

I'm currently working on creating a member system for my FTP server for close friends that I want to have access to the server, however the FTP server that I'm using(proFTPd) utilizes the linux users as each member's account. So I need to use an html form with php of course that will have access to the server and be able to create a user on the system. Right now I have the form completely setup with it validating the email/username/password and saving it to my sql database. The only thing I'm missing is creating the new user to finish it out. I know it's not always the safest thing however I do want to do it and I do know the dangers so any help would be nice... As of right now from what I've always used to create a user on linux(or my version of Ubuntu atleast) it's: ``` useradd [username] -p [password] -d [/path_to_home_directory] -s [/bin/false] ``` without the brackets of course. I also know the php commands: shell_exec, exec, system() However I have tried each one of these with the line to create the user in it and nothing will work. I did a little more research and noticed that the webserver is running on www-data(which it should be) and it does not have access to the useradd command. So I 'viduso' it and still had no change. From what I've seen I can give the www-data access to a script on the server that will then create the user as root however I do not know how to transfer the variables stored in php to the script. If you need more details to help just ask. This is the last thing I need to finalize my last 2 month project which includes a desktop application and all that. It's so close but I can't seem to get it.

Original source