在安装wordpress之前需要配置wp-config.php文件,(只需修改$dbname『在百度bae上新建的mysql数据库』和$bcs_bucket『在百度bae上新建的云存储bucket服务』),具体配置如下:
配 置wp-config.php完成后,打开wp-admin/includes/file.php,
改成使用BAE提供的Mysql服务,
在文件中找 到 function wp_handle_upload( &$file, $overrides = false, $time = null )函数,
在该函数中找到$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); 删除下面的代码:
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
// Set correct file permissions
$stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
@ chmod( $new_file, $perms );
// Compute the URL
$url = $uploads['url'] . "/$filename";
if ( is_multisite() )
delete_transient( 'dirsize_cache' );
return apply_filters( 'wp_handle_upload', array( 'file' => $new_file,'url' => $url, 'type' => $type ), 'upload' );
然后在该行下添加如下代码:
$tmp_file = wp_tempnam($filename);
// Move the file to the uploads dir
if ( false === @ move_uploaded_file( $file['tmp_name'], $tmp_file ) )
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
// If a resize was requested, perform the resize.
$image_resize = isset( $_POST['image_resize'] ) && 'true' == $_POST['image_resize'];
$do_resize = apply_filters( 'wp_upload_resize', $image_resize );
$size = @getimagesize( $tmp_file );
if ( $do_resize && $size ) {
$old_temp = $tmp_file;
$tmp_file = image_resize( $tmp_file, (int) get_option('large_size_w'), (int) get_option('large_size_h'), 0, 'resized');
if ( ! is_wp_error($tmp_file) ) {
unlink($old_temp);
} else {
$tmp_file = $old_temp;
}
}
//新版采用百度云存储
//上传到云存储
$bucket = constant('BCS_BUCKET');
$opt = array();
$baidu_bcs = new BaiduBCS();
$object = "/$filename";
$fileUpload = $tmp_file;
if( !file_exists($fileUpload) )
{
die('file is not existed!!!!!!!!!!!!!');
}
$re = $baidu_bcs->create_object ( $bucket, $object, $fileUpload, $opt);
trigger_error( print_r($re, true) );
unlink($tmp_file);
$url = $baidu_bcs->generate_get_object_url($bucket, $object);
//echo '??????'; exit;
if ( is_multisite() )
delete_transient( 'dirsize_cache' );
//exit("$new_file !! $url");
return apply_filters( 'wp_handle_upload', array( 'file' => $new_file,'url' => $url, 'type' => $type ), 'upload' );
配置完成后,在打开浏览器中输入第四步中申请的域名,开始安装wordpress,配置blog。
当然,如果博客上出现中文乱码的情况,可以采用下面的方法解决:
在 wp-includes文件夹下找到wp-db.php文件,使用文字编辑器打开,在文件第1063行 $this->select( $this->dbname,$this->dbh ); 后面加上:$this->query(“set names utf8″); 然后重新上传到云服务上,使用。(如果您已创建了数据库,请先删除原来创建的数据库,如果不删除,官方文字依然是乱码)请一定注意。
支付宝 扫码打赏
加油哈 http://www.xunte888.com