首页 文章

Wordpress docker - 无法安装主题?

提问于
浏览
0

我想使用wordpress docker image在本地开发我的网站 . 但是,当我尝试安装一个主题fromui,或上传一个主题时,Wordpress需要一些FTP凭据 . 我已经阅读了如何用 chown -R www-data.www-data /var/www/html 解决这个问题,但它根本不起作用,我仍然面临同样的问题

这是我的DockerFile

FROM library/wordpress:latest

RUN chown -Rf www-data.www-data /var/www/html/

这是我的docker-compose

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
      - ./db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
      - db
     image: my_docker
     ports:
      - "8000:80"
     restart: always
     volumes:
      - ./wp-content:/var/www/html/wp-content/
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress

可能的原因是我在Windows主机和docker镜像之间共享一个卷以在我的网站上保留更改?

2 回答

  • 0

    @Sagar解决方案不起作用

    FROM library/wordpress:latest
    
    COPY wp-config.php /var/www/html/
    RUN chown -Rf www-data.www-data /var/www/html/
    

    仍然需要ftp凭据

    <?php
    /**
     * The base configuration for WordPress
     *
     * The wp-config.php creation script uses this file during the
     * installation. You don't have to use the web site, you can
     * copy this file to "wp-config.php" and fill in the values.
     *
     * This file contains the following configurations:
     *
     * * MySQL settings
     * * Secret keys
     * * Database table prefix
     * * ABSPATH
     *
     * @link https://codex.wordpress.org/Editing_wp-config.php
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'wordpress');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'wordpress');
    
    /** MySQL hostname */
    define('DB_HOST', 'db:3306');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         'f9b05f002d64acc443807833ad1f195305eb7c9e');
    define('SECURE_AUTH_KEY',  '43de95418a997851708b525bb7b282f4c9fbbc2f');
    define('LOGGED_IN_KEY',    '3984d29a6007406a3484f136476b7e5dd570cee9');
    define('NONCE_KEY',        'ddf8564f0e7926f374ae3eed4af174ab472c47d2');
    define('AUTH_SALT',        'ab89b2d3d53107bdf8499b45c5f215b013eda7cf');
    define('SECURE_AUTH_SALT', 'b439656f7240971592c053ae7a9c1f3a0d15ebc6');
    define('LOGGED_IN_SALT',   'a40e0a96dda4802c309475ec35f9955d2c2b3b35');
    define('NONCE_SALT',       '219827cb4ccd4709d5c700ce6e8890ab9cdbbd67');
    
    /**#@-*/
    
    /**
     * 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  = 'wp_';
    
    /**
     * 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 Codex.
     *
     * @link https://codex.wordpress.org/Debugging_in_WordPress
     */
    define('WP_DEBUG', false);
    
    // If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact
    // see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
    if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
        $_SERVER['HTTPS'] = 'on';
    }
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    
    define('FS_METHOD', 'direct');
    
  • 0

    您可以将以下代码放在wp-config.php文件中,以直接上传绕过FTP的文件 .

    define('FS_METHOD','direct');

    https://codex.wordpress.org/Editing_wp-config.php

相关问题