WordPress asking for my FTP credentials to install plugins

后端 未结 14 774
南旧
南旧 2020-11-30 17:52

I installed a WordPress blog in my local system. But when I try to add plugins from admin it asks for FTP access. What do I need to configure for WordPress to be able to up

相关标签:
14条回答
  • 2020-11-30 18:14

    I was facing the same problem! I've added the code below in wp-config.php file (in any line) and it's working now!

    define('FS_METHOD', 'direct');
    
    0 讨论(0)
  • 2020-11-30 18:15

    From the first hit on Google:

    WordPress asks for your FTP credentials when it can't access the files directly. This is usually caused by PHP running as the apache user (mod_php or CGI) rather than the user that owns your WordPress files.

    This is rather normal in most shared hosting environments - the files are stored as the user, and Apache runs as user apache or httpd. This is actually a good security precaution so exploits and hacks cannot modify hosted files. You could circumvent this by setting all WP files to 777 security, but that means no security, so I would highly advise against that. Just use FTP, it's the automatically advised workaround with good reason.

    0 讨论(0)
  • 2020-11-30 18:16

    We had the same problem as part of a bigger problem. The suggested solution of

    define('FS_METHOD', 'direct');
    

    hides that window but then we still had problems with loading themes and upgrades etc. It is related to permissions however in our case we fixed the problem by moving from php OS vendor mod_php to the more secure php OS vendor FastCGI application.

    0 讨论(0)
  • 2020-11-30 18:23

    "Whenever you use the WordPress control panel to automatically install, upgrade, or delete plugins, WordPress must make changes to files on the filesystem.

    Before making any changes, WordPress first checks to see whether or not it has access to directly manipulate the file system.

    If WordPress does not have the necessary permissions to modify the filesystem directly, you will be asked for FTP credentials so that WordPress can try to do what it needs to via FTP."

    Solution: In order to find out what user your instance of apache is running as, create a test script with the following content:

    <?php echo(exec("whoami")); ?>
    

    For me, it was daemon and not www-data. Then, fix the permission by:

    sudo chown -R daemon /path/to/your/local/www/folder
    
    0 讨论(0)
  • 2020-11-30 18:24

    If during installation of a plugin, Wordpress asks for your hostname or FTP details. Then follow these steps:

    Login to your server and navigate to /var/www/html/wordpress/. Open wp-config.php and add this line after define(‘DB_COLLATE’)

    define('FS_METHOD', 'direct');
    

    If you get "Could not create directory" error. Give write permissions to your wordpress directory in recursive as

    chmod -R go+w wordpress
    

    NOTE. For security, revoke these permissions once you install a plugin as

    chmod -R go-w wordpress
    
    0 讨论(0)
  • 2020-11-30 18:24

    The easiest way to solve this problem is add the following FTP information to your wp-config.php

    define('FS_METHOD', 'direct');
    define('FTP_BASE', '/usr/home/username/public_html/my-site.example.com/wordpress/');
    define('FTP_CONTENT_DIR', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/');
    define('FTP_PLUGIN_DIR ', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/plugins/');
    

    FTP_BASE is the full path to the "base"(ABSPATH) folder of the WordPress installation FTP_CONTENT_DIR is the full path to the wp-content folder of the WordPress installation. FTP_PLUGIN_DIR is the full path to the plugins folder of the WordPress installation.

    0 讨论(0)
提交回复
热议问题