Adding Pi FTP

Forums:

Ref: https://itsmereal.com/raspberry-pi-web-server-apache-php-mysql-phpmyadmi...

The one thing I love about nix'n is the complexity it takes to perform a simple task. I needed to add a module
to drupal which requires an FTP server. To me this is just silly because it allows you to add files already, so why is
FTP required? So after 3 hours of hunting and pecking I was able to come up with this ftp solution referenced from the URL above.
The one thing I did find (and noted) that was missing was the ftp login failure from the new user.

FTP Server Installation (Condensed)
Adding ProFTPD for FTP
sudo apt-get install proftpd
This will ask you to choose init.d or standalone, choose any one of them but I used standalone for this tutorial.

Change the config of proftpd.
sudo nano /etc/proftpd/proftpd.conf
You need to change the following lines. The ServerName should be the IP of your Raspberry Pi.
Here we used 192.168.1.88. Yours can be different.
Server Name "192.168.1.88"
Uncomment the # in front of DefaultRoot text. This is a good practice.
# Use this to jail all users in their homes
DefaultRoot

Restart proftpd service
sudo service proftpd restart

To make sure that FTP service runs automatically at startup, enter the following code
update-rc.d proftpd defaults

Add a user for FTP. I am using “real” as the username. You can choose anything you like.
sudo useradd real
Set password the user with the following command
sudo passwd real

Assign the “/var/www/html/” directory to the user. This is the directory where the files will need to be added and the user will see this directory when they login using FTP client. Ignore message that says the directory already exists
sudo usermod -m -d /var/www/html real

Run the following commands to give permissions to the user on the html folder.
247 Note: I am not sure if this is correct. www-data is the owner of that directory. It may affect your html site. I will need to investigate this part but instead temporarily added the user to the www-data group (which probably gives it way more permissions than it needs and not a long term solution).
(see note)cd /var/www
(see note)sudo chown real:real -R html

NOTE: I found that you have to add bin/bash to the user ID to allow it to ftp in int the passwd file.
No matter what I did, I could log in with pi but not my new user until I did this step.
sudo leafpad /etc/passwd
find your new ftp username, and on the end of line see: /bin/false
Add /bin/bash so the user can log in. It fixed it for me.
Example:
ftpuseraccount:x:1001:1001::/var/www/html:/bin/bash

247 Notice:
This next step may (probably) affect your apache server and not sure if it is advisable. By changing the vars which by the note in the conf file you are changing where apache2 looks for it's environment variables. If you open this file, you will see that it is probably pointing to the www-data group. If you change this, you could affect your apache2 webserver!
As in my note above, I added the user to www-data as a temporary solution, so I did not need to do this step.

FTP setup is done at this point. However, I found it is easier for me to do one extra step to avoid permissions.
I edited apache2.conf file to make Apache use the user and group that we created.
(see 247 note above)sudo nano /etc/apache2/apache2.conf
Look for the following line and add # in front of User and Group lines. After editing, it should look like the following

# These need to be set in /etc/apache2/envvars
# User ${APACHE_RUN_USER}
# Group ${APACHE_RUN_GROUP}
User real
Group real

37.8269817,-122.4251495,05-20-2019 01:20:19 AM,!Stopped for gas