删除插件时 Wordpress 要求 FTP

删除插件时 Wordpress 要求 FTP

当我尝试删除或安装插件时,Wordpress 会要求我提供 FTP 凭据。我知道这与权限有关,但我一直无法弄清楚。我有一个 Linux 系统用户 XYZ,apache2 以 www-data 身份运行。这有效:

sudo chown www-data:www-data -R /path/to/wordpress
sudo chmod 700 -R /path/to/wordpress

但这不安全。我最初计划的配置是:

sudo chown XYZ:www-data -R /path/to/wordpress
sudo chmmod 750 -R /path/to/wordpress
sudo chmod 770 -R /path/to/wordpress/wp-content

根据 wordpress 文档,wp-content 是 web 服务器唯一应具有写入权限的文件夹。它包含插件和主题文件夹。

但它不起作用。我花了几个小时在网上研究,但到目前为止没有任何帮助,我不知道该再尝试什么了。什么是正确的权限,可以允许自动更新和插件安装,而无需授予 Web 服务器对所有内容的写访问权限?

编辑:无论出于何种原因,以下内容均不起作用:

sudo chown XYZ:www-data -R /path/to/wordpress
sudo chmod 770 -R /path/to/wordpress

我以为它与上面的第一种变体相同,即赋予 www-data 对所有内容的写访问权限。但它没有起到作用。

这是我的 wp-config:

<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'XXX' );

/** MySQL database username */
define( 'DB_USER', 'XXX' );

/** MySQL database password */
define( 'DB_PASSWORD', 'XXX' );

/** MySQL hostname */
define( 'DB_HOST', '127.0.0.1:XXX' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', 'utf8mb4_0900_ai_ci' );

define( 'AUTH_KEY',         'XXX' );
define( 'SECURE_AUTH_KEY',  'XXX' );
define( 'LOGGED_IN_KEY',    'XXX' );
define( 'NONCE_KEY',        'XXX' );
define( 'AUTH_SALT',        'XXX' );
define( 'SECURE_AUTH_SALT', 'XXX' );
define( 'LOGGED_IN_SALT',   'XXX' );
define( 'NONCE_SALT',       'XXX' );

/**#@-*/

/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'XXX';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

这是我的 php.ini(不包括注释):

engine = On

short_open_tag = Off

precision = 14

output_buffering = 4096

zlib.output_compression = Off

implicit_flush = Off

unserialize_callback_func =

serialize_precision = -1

open_basedir = "/var/www/"

disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,show_source,highlight_file,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,

disable_classes =

zend.enable_gc = On

zend.exception_ignore_args = On

expose_php = Off

max_execution_time = 30

max_input_time = 60

memory_limit = 128M

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

display_errors = Off

display_startup_errors = Off

log_errors = On

log_errors_max_len = 1024

ignore_repeated_errors = Off

ignore_repeated_source = Off

report_memleaks = On

variables_order = "GPCS"

request_order = "GP"

register_argc_argv = Off

auto_globals_jit = On

post_max_size = 256M

auto_prepend_file =

auto_append_file =

default_mimetype = "text/html"

default_charset = "UTF-8"

doc_root =

user_dir =

enable_dl = Off

file_uploads = On

upload_tmp_dir = "/tmp"

upload_max_filesize = 250M

max_file_uploads = 20

allow_url_fopen = Off

allow_url_include = Off

default_socket_timeout = 60

cli_server.color = On

pdo_mysql.default_socket=

SMTP = localhost

smtp_port = 25

mail.add_x_header = Off


odbc.allow_persistent = On

odbc.check_persistent = On

odbc.max_persistent = -1

odbc.max_links = -1

odbc.defaultlrl = 4096

odbc.defaultbinmode = 1

mysqli.max_persistent = -1

mysqli.allow_persistent = On

mysqli.max_links = -1

mysqli.default_port = 3306

mysqli.default_socket =

mysqli.default_host =

mysqli.default_user =

mysqli.default_pw =

mysqli.reconnect = Off

mysqlnd.collect_statistics = On

mysqlnd.collect_memory_statistics = Off

pgsql.allow_persistent = On

pgsql.auto_reset_persistent = Off

pgsql.max_persistent = -1

pgsql.max_links = -1

pgsql.ignore_notice = 0

pgsql.log_notice = 0

bcmath.scale = 0

session.save_handler = files

session.use_strict_mode = 0

session.use_cookies = 1

session.use_only_cookies = 1

session.name = PHPSESSID

session.auto_start = 0

session.cookie_lifetime = 0

session.cookie_path = /

session.cookie_domain =

session.cookie_httponly =

session.cookie_samesite =

session.serialize_handler = php

session.gc_probability = 0

session.gc_divisor = 1000

session.gc_maxlifetime = 1440

session.referer_check =

session.cache_limiter = nocache

session.cache_expire = 180

session.use_trans_sid = 0

session.sid_length = 26

session.trans_sid_tags = "a=href,area=href,frame=src,form="

session.sid_bits_per_character = 5

zend.assertions = -1

tidy.clean_output = Off

soap.wsdl_cache_enabled=1

soap.wsdl_cache_dir="/tmp"

soap.wsdl_cache_ttl=86400

soap.wsdl_cache_limit = 5

ldap.max_links = -1

我是这样安装 php 的:

sudo apt install php libapache2-mod-php php-mysql

这对@GeraldSchneider 有帮助吗?

答案1

添加

define('FS_METHOD','direct');

到您的wp-config.php文件中。

相关内容