问题
Thanks for your wonderful help with my code last week. I have a VPS running and for my server/website, for each new account I would like to give each user a 50 meg upload space and FTP credentials. The username and password for the FTP would be unique to each user and the folder would be easily accessible only by them and myself.
I have written a script that can connect to the FTP for my VPS but where would I need to go from here? Specifically for creating ftp login details for a user that will create a new folder on the ftp for that user and with a limit of 50 meg space.
Thanks
回答1:
FTP user's use the same login as other logins.
You can create new users using the following command:
# adduser -c 'FTP USER Tom' -m tom
Then, change tom's password:
# passwd tom
Note: For passwd, this is an interactive shell, so you may need to use passthru() or other methods - you can research these yourself.
Also, these sorts of questions are nothing to do with PHP, and more suited to http://www.superuser.com.
On the PHP side, you can use mkdir() for creating directories.
To do these things via PHP, you can use exec(): this basically executes shell commands for you. You would use:
exec("adduser -c 'FTP USER Tom' -m tom");
Make sure you escape your strings correctly, and if you're accepting user input into these commands, make sure you escape them with escapeshellarg().
来源:https://stackoverflow.com/questions/17524188/creating-ftp-user-accounts-using-ftp-on-server