How to Setup FTP to use in locally hosted wordpress

I have installed wordpress on my ubuntu 10.10 desktop edition and I am trying to install plugin from the browser (I know I can drop it to the wp-content/plugin but I want to do it via the web browser using FTP) I get this screen when I am trying to set auto update or install a plugin from web browser.

alt text

I provide the hostname 127.0.0.1
and Username and password the ones that I use to login to wordpress. I get the error

Username/password Incorrect and cannot connect to 127.0.0.1:20

I think i’ll have to grant a user with ftp password but I dont know how.
I have already installed vsftp but when I try “ftp 127.0.0.1” I get –

$ ftp 127.0.0.1
Connected to 127.0.0.1.
220 (vsFTPd 2.3.0)
Name (127.0.0.1:gaurav): root
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
ftp> 

WordPress is running locally on my Ubuntu Desktop.

Asked By: Gaurav Butola

||

Well your WordPress login and your FTP login are two different things. I have see that you use vsFTPd, so one easy thing that you can do it this :

Edit the vsFTPd configuration file :

gksu gedit /etc/vsftpd.conf

Add this at the end :

local_enable=YES

Restart your vsFTPd server :

sudo /etc/init.d/vsftpd restart

Now you should be able to connect to your FTP using your Ubuntu login.

To configure vsftpd, open vsftpd.conf in /etc and
copy paste the following into your vsftpd.conf

listen=YES
anonymous_enable=YES
anon_root=/srv/ftp
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
ftpd_banner=Welcome to my FTP server.
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem

Note:
You should create a new directory inside /srv in the name ftp or what ever name you prefer.If you prefer another name then you should change the line anon_root=/srv/ftp to anon_root=/srv/toyourfoldername Now place all your files inside the folder /srv/ftp

To test your settings in localhost type:

ftp://127.0.0.1
If you have any problems let me know.

To start/stop/restart vsftpd:

sudo service vsftpd start
sudo service vsftpd stop
sudo service vsftpd restart
Answered By: karthick87

If you are using the default file the problem I had was not seeing enable write access. That resolved my problems.

listen=YES
local_enable=YES
write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/private/vsftpd.pem
Answered By: Chris Schafer

I had the same issue.

When I created my Ubuntu server I installed a wordpress site and everytime I wanted to update a plugin I needed ftp access which was really annoying. I knew I could just add the ftp details in the config for wordpress but I was Like NAH!
So It turned out that wordpress can’t write files to the wp-content directory because apache doesn’t have permission to edit the directory so this is how I fixed it.

Copy group file to groups in the same directory

sudo cp /etc/group /etc/groups

Then give Recursive Permission to apache

sudo chown -R www-data:root /var/www

Thats it.

Another way of doing it is by editing apache envvars

sudo nano /etc/apache2/envvars

Edit the lines where it says

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

And replace www-data with your username for ubuntu

export APACHE_RUN_USER=USERNAME
export APACHE_RUN_GROUP=USERNAME

now restart apache

sudo service apache2 restart

and then make sure your account has permissions to the directory

sudo chown -R USERNAME:USERNAME /var/www

If this doesnt work for you then simply reply.

Answered By: user1116826

This worked for me:

Add this file to wp-config.php:

if(is_admin()) {
    add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
    define( 'FS_CHMOD_DIR', 0751 );
}

for more http://www.jamison.org/2010/12/04/how-to-configure-wordpress-for-automatic-ftps-updates-using-vsftp-in-ubuntu/

Answered By: Gulf State Software

Just add this line to wp-config.php

define('FS_METHOD', 'direct');

Then It will be OK.

Answered By: Abul Kashem Shamim

For me changing the ownership of the wordpress folder solved the issue.

sudo chown -R www-data wordpress
Answered By: Leszek

I had the same problem before and here how I resolved it.

1) You have to check what group owned that specific wordpress folder. i.e www-data. Then make sure the group owned recursively. You can can do

sudo chown -R www-data.www-data /var/www/wordpress

2) the ftpuser that you plan to use need to belong to www-data group. You can check by following.

groups ftpuser

If it is not in that group, just add it. here how i did it.

sudo usermod -a -G www-data ftpuser

The last thing is to set the default folder of the ftpuser to your wordpress folder.

usermod -d /var/www/wordpress ftpuser

that’s it…

Answered By: tempetai

Since you are running WordPress locally on your Ubuntu Desktop, you can use the following steps to enable FTP access and resolve the plugin installation issue:

  1. Install vsftpd:
    First, make sure that you have the vsftpd package already installed on your Ubuntu Desktop. And If it’s not already there, don’t worry, you can install it using this command:

    sudo apt-get update
    sudo apt-get install vsftpd
    
  2. Configure vsftpd:
    Open the vsftpd configuration file for editing:

    sudo nano /etc/vsftpd.conf
    

    Now enable FTP access:

    anonymous_enable=NO
    local_enable=YES
    write_enable=YES
    

    Now save the file and get out of text editor.

  3. Restart vsftpd:
    After making changes to the vsftpd configuration, restart the vsftpd service for the changes to take effect:

    sudo service vsftpd restart
    
  4. Create a New FTP User:
    As I said before, Do not use the root user for FTP access because of security reasons. Instead of that, create a new user (specifically) for FTP purposes:

    sudo adduser ftpuser
    

    Follow the prompts to set a password for the new user.

  5. Grant FTP Access to WordPress Directory:
    Give the new FTP user access to the WordPress directory. Assuming your WordPress files are in the /var/www/html directory, run the following commands:

    sudo usermod -aG www-data ftpuser
    sudo chown -R ftpuser:www-data /var/www/html
    sudo chmod -R 755 /var/www/html
    
  6. Test FTP Access:
    Now, connect to your FTP server using that new FTP user account:

    ftp 127.0.0.1
    

    Provide the FTP username and password you set during the user creation process.

Once you have successfully logged in via FTP with the new user, you can use these credentials in the WordPress plugin installation section to install plugins through the web browser using FTP.

Again, please be cautious when enabling FTP access, especially on a local development environment, as it may expose security risks. Make sure to use strong passwords for the FTP user and consider disabling FTP access once you are done with the plugin installation if it’s not required for other purposes.

Answered By: FruitBowl Digital
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.