Can I install/update WordPress plugins without providing FTP access?

Viewed 434952

I am using WordPress on my live server which only uses SFTP using an SSH key.

I want to install and upgrade plugins, but it appears that you are required to enter your FTP login to install the plugins. Is there a way to install and upgrade plugins by manually uploading the files instead of having WordPress handle the entire process?

33 Answers
  1. In wp-config.php add define('FS_METHOD', 'direct');
  2. Make server writable the directories wp-content/, wp-content/plugins/.
  3. Install the plugin (copy the plugin dir into the wp-content/plugins dir).

Worked on version 3.2.1

Usually you can just upload your plugin to the wp-content\plugins directory. If you don't have access to this directory via SFTP I'm afraid you may be stuck.

WordPress 2.7 lets you upload a zip file directly (there's a link at the bottom of the plugins page) -- no FTP access needed. This is a new feature in 2.7, and it works for plugins only (not themes yet).

Yes, directly install the plugin in WordPress.

  1. Copy the plugin folder and paste in WordPress plugin folder.
  2. go to admin side (/test/wp-admin) then after go to on the plugin link and check the name of the plugin.
  3. Activate the plugin so Install the plugin easily.

other Option

  1. create the zip file for the plugin code.
  2. go to admin side (/test/wp-admin) then after go to on the plugin link and then click on the add new then browse the plugin zip folder and install the plugin then come out the option activate plugin so so do activate plugin and activate plugin.

We use SFTP with SSH (on both our development and live servers), and I have tried (not too hard though) to use the WordPress upload feature. I agree with Toby, upload your plugin(s) to the wp-content/plugins directory and then activate them from there.

Please add define('FS_METHOD','direct'); in wp-config.php

Yes you can do it.

You need to add

define('METHOD','direct');

in your wpconfig. But this method won't be preferable because it has security voilances.

Thanks,

Method 1: You can set this: 1. in wp-config.php you need to write this lines.

define('FS_METHOD', 'direct'); 

Note: put this after define( 'DB_CHARSET', 'utf8mb4' ).

  1. set wp-content permission or permission recursively 775 full permission you can give it via filezilla. write click on directory > permissions> check read-write and execute and also check Recurse into subdirectories

Method 2:

or You can also set this

define("FTP_HOST", "localhost");
define("FTP_USER", "yourftpusername");
define("FTP_PASS", "yourftppassword");

setting up a ftp or even an SFTP connection or chmod 777 are bad ways to go for anything other than a local environment. Opening even an SFTP method introduces more security risks that are not needed.

what is needed is a writeable permission to /wp-content/uploads & /wp-content/plugins/ by the owner of those directories. (linux ls -la will show you ownership).

Default apache user that runs is www-data.

chmod 777 allows any user on the machine to edit those file, not just the apache/php thread user.

SFTP if you are not already using it, will introduce another point of possible failure from an external source. Whereas you only need access by the local user running the apache/php process to complete the objective.

Didn't see anyone making these points, so I thought I would offer this info to help with our constant WP security issues online.

Here is a simple method.

Execute following commands.

This will enable your mod_rewrite module for Apache

$sudo a2enmod rewrite

This Command will change the owner of the folder to www-data

$sudo chown -R www-data [Wordpress Folder Location]

After You executing above commands you can install any themes without FTP.

The only reason by which WordPress won't allow you to upload any plugin via WordPress admin dashboard when you don't got permission to write on the /wp-content directory. Remember that your wordpress directory /wp-content requires 0755 permission level. There are various ways to change a folder's permission level.

Changing file permissions using cPanel:

Go to File Manager at open the public HTML folder where your wordpress website is supposed to be, or open the site root directory if your website is in some other folder. In your WordPress root directory navigate towards wp-content folder; at the end of wp-content folder row the very last box carries file permissions for this folder. Make sure to edit the folder permission level to 0755, and you are done.

Changing file permissions using SSH terminal:

In your terminal locate the root of WordPress site which in my case was /var/www/html so to move into WordPress root directory enter the following command:

cd /var/www/html 

Now you are in WordPress root directory where the required folder /wp-content is located. So to change the file permissions type the following command:

sudo chmod wp-content 755 

This will change your /wp-content directory file permission to 0755.

Now you won't get error message of uploading wordpress plugins via FTP.

You can add following in wp-config.php

define('METHOD','direct');

Here is a youtube video that explaining how to do it. https://youtu.be/pq4QRp4427c

The best way to install plugin using SSH is WPCLI.

Note that, SSH access is mandatory to use WP CLI commands. Before using it check whether the WP CLI is installed at your hosting server or machine.

How to check : wp --version [ It will show the wp cli version installed ]

If not installed, how to install it : Before installing WP-CLI, please make sure the environment meets the minimum requirements:

UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment. PHP 5.4 or later WordPress 3.7 or later. Versions older than the latest WordPress release may have degraded functionality

If above points satisfied, please follow the steps : Reference URL : WPCLI

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
[ download the wpcli phar ]

php wp-cli.phar --info [ check whether the phar file is working ]

chmod +x wp-cli.phar [ change permission ]
sudo mv wp-cli.phar /usr/local/bin/wp [ move to global folder ]
wp --info [ to check the installation ]

Now WP CLI is ready to install.

Now you can install any plugin that is available in WordPress.org by using the following commands :

wp install plugin plugin-slug
wp delete plugin plugin-slug
wp deactivate plugin plugin-slug

NOTE : wp cli can install only those plugin which is available in wordpress.org

Two steps

  1. Add below code in wp-config file

    define('FS_METHOD', 'direct');
    
  2. We need to give full permission to the folder like if server connected with SSH then paste below code in terminal and make sure you are inside on website folder and then run below code

    sudo chmod -R 775 wp-content/plugins 
    

    or give full permission to website folder

    sudo chown -R www-data:www-data website_folder
    

You can have fileZilla and use FTP Account to update plugins and themes. Or you can just login to Cpanel and access wordpress folder and then you can update theme by unzipping theme or plugin.

Related