一、首先第一个改的是配置文件wp-config.php,这里我是直接复制官方应用仓库的WP配置文件。
(
- define(‘DB_NAME’,
SAE_MYSQL_DB); - define(‘DB_USER’,
SAE_MYSQL_USER); - define(‘DB_PASSWORD’,
SAE_MYSQL_PASS); - define(‘DB_HOST’,
SAE_MYSQL_HOST_M.’:’.SAE_MYSQL_PORT); - define(‘DB_CHARSET’,
’utf8′); - define(‘DB_COLLATE’,
”); - define(‘WP_USE_MULTIPLE_DB’,
true); -
- $db_list
= array( -
’write’=> array( -
array( -
’db_host’ => SAE_MYSQL_HOST_M.’:’.SAE_MYSQL_PORT, -
’db_user’=> SAE_MYSQL_USER, -
’db_password’=> SAE_MYSQL_PASS, -
’db_name’=> SAE_MYSQL_DB, -
’db_charset’=> ’utf8′ -
) -
), -
’read’=> array( -
array( -
’db_host’ => SAE_MYSQL_HOST_S.’:’.SAE_MYSQL_PORT, -
’db_user’=> SAE_MYSQL_USER, -
’db_password’=> SAE_MYSQL_PASS, -
’db_name’=> SAE_MYSQL_DB, -
’db_charset’=> ’utf8′ -
) -
), -
); - $global_db_list
= $db_list['write']; - define(‘AUTH_KEY’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’AUTH_KEY’, SAE_SECRETKEY )); - define(‘SECURE_AUTH_KEY’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’SECURE_AUTH_KEY’, SAE_SECRETKEY )); - define(‘LOGGED_IN_KEY’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’LOGGED_IN_KEY’, SAE_SECRETKEY )); - define(‘NONCE_KEY’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’NONCE_KEY’, SAE_SECRETKEY )); - define(‘AUTH_SALT’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’AUTH_SALT’, SAE_SECRETKEY )); - define(‘SECURE_AUTH_SALT’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’SECURE_AUTH_SALT’, SAE_SECRETKEY )); - define(‘LOGGED_IN_SALT’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’LOGGED_IN_SALT’, SAE_SECRETKEY )); - define(‘NONCE_SALT’,
hash_hmac(‘sha1′, SAE_ACCESSKEY . ’NONCE_SALT’, SAE_SECRETKEY )); - $table_prefix
= ’wp_’; - define
(‘WPLANG’, ’zh_CN’); - define(‘WP_DEBUG’,
false); - if
( !defined(‘ABSPATH’) ) -
define(‘ABSPATH’, dirname(__FILE__) . ’/'); - require_once(ABSPATH
. ’wp-settings.php’);
二、WP会自动创建上传目录,而sae的storage写文件的时候会自动创建目录,所以得改掉
在wp-includes/functions.php
搜索“function wp_mkdir_p( $target )”,函数内容,把原函数代码全部删除,写上一条代码
接下来是文件上传代码,还是在wp-includes/functions.php
找到wp_upload_dir函数,将
- if
( empty($upload_path) ) { -
$dir = WP_CONTENT_DIR . ’/uploads’; - }
else { -
$dir = $upload_path; -
if ( ’wp-content/uploads’ == $upload_path ) { -
$dir = WP_CONTENT_DIR . ’/uploads’; -
} elseif ( 0 !== strpos($dir, ABSPATH) ) { -
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH -
$dir = path_join( ABSPATH, $dir ); -
} - }
- if
( !$url = get_option( ’upload_url_path’ ) ) { -
if ( empty($upload_path) || ( ’wp-content/uploads’ == $upload_path ) || ( $upload_path == $dir ) ) -
$url = WP_CONTENT_URL . ’/uploads’; -
else -
$url = trailingslashit( $siteurl ) . $upload_path; - }
- if
( defined(‘UPLOADS’) && !$main_override && ( !isset( $switched ) || $switched === false ) ) { -
$dir = ABSPATH . UPLOADS; -
$url = trailingslashit( $siteurl ) . UPLOADS; - }
- if
( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) { -
if ( defined( ’BLOGUPLOADDIR’ ) ) -
$dir = untrailingslashit(BLOGUPLOADDIR); -
$url = str_replace( UPLOADS, ’files’, $url ); - }
直接替换成下面两条语句
- $dir
= ’saestor://wordpress/uploads’; //wordpress是你的storage domain - $url
= ’http://’ . $_SERVER['HTTP_APPNAME'] . ’-wordpress.stor.sinaapp.com/uploads’;
这样就全部修改完毕了,上传图片创建目录问题就可以解决了,但后台的插件和主题安装、升级都是不能正常使用的,请看下一篇。