刚写篇博文《清明上河园游记》,要传几张照片,突然发现上传有2M的限制,大部分照片都是大像素的,早超过这个值了,去网上搜索各种突破限制的方法,总结一下。
首先要判断是wordpress的限制还是空间提供商在限制。
最简单的方法,先突破wordpress的限制,如果失败,那就是空间商在限制了。
方法一:
在functions.php中添加如下代码,这样上传限制就是32M
@ini_set( 'upload_max_size' , '32M' );
@ini_set( 'post_max_size', '32M');
@ini_set( 'max_execution_time', '300' );
方法二:
在主机空间根目录新建一个php.ini文件,添加如下代码
upload_max_filesize = 32M
post_max_size = 32M
max_execution_time = 300
方法三:
使用.htaccess文件,添加如下代码
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 300
php_value max_input_time 300
其中以上三种方法中的upload_max_filesize含义一看就知道了,post_max_size表示每篇博文的最大限制,后两者表示上传执行最长时间。
修改完后,可以检查wordpress的媒体上传是否显示为32M。
可悲的是,我的仍没有突破2M,这只能说明空间商对此做了限制。好吧,只好修改空间商提供的配置文件了,也有多种方法:
这里提供了具体操作,但是按照作者所言自行修改,发现博客打不开了,返回500错误。只好硬着头皮找客服去修改,想着ix有中文客服,还是不考验我蹩脚的英文了吧,直接找中文客服,打开网址竟然发现中文客服晚上21点就拜拜了,还得用我的蹩脚英语……
说到这里,不得不赞下大洋彼岸ix的客服,解决问题很快,临走还不忘宣传下~~~
下面是livechat:
Dmitriy Shevtsov: Hello! My name is Dmitriy. How may I help you today?
you: Hi!I w ant to modify the upload restrictions
you: now it’s 2 M ,I want more
Dmitriy Shevtsov: Please provide domain name.
you: www .nankor.org
you: please set it to be 20M
Dmitriy Shevtsov: Please hold on, let me check
Dmitriy Shevtsov: Increased up to 32M.
you: ok, I have seen it.thank you
Dmitriy Shevtsov: You are welcome.
Dmitriy Shevtsov: Please feel free to contact us if you need further assistance. We are available
24/7.
you: ok ,it’s nice
Dmitriy Shevtsov: Bye.
you: Bye.
在他修改时,我也一直注视着我根目录的变化,果不其然,他添加了两个文件,与刚那个作者所言相似:
在我的域名目录下新建了一个文件夹,cgi-bin,添加了两个文件:我的域名/cgi-bin/php.ini 我的域名/cgi-bin/php5-custom-ini.cgi,算是重新配置了我的php.ini,修改了上传大小的限制。
php5-custom-ini.cgi文件内容,用去执行php的修改:
#!/bin/sh
export PHP_FCGI_CHILDREN=3
exec /hsphere/shared/php5/bin/php-cgi -c 我的域名目录/cgi-bin/php.ini
php.ini php配置文件
; |PIG v0.3.1.7|
[PHP]
open_basedir =
engine = 1
zend.ze1_compatibility_mode =
short_open_tag = 1
asp_tags =
precision = 14
y2k_compliance = 1
output_buffering = 4096
zlib.output_compression =
implicit_flush =
unserialize_callback_func =
serialize_precision = 100
allow_call_time_pass_reference =
safe_mode =
safe_mode_gid = 1
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = "PHP_"
safe_mode_protected_env_vars = "LD_LIBRARY_PATH"
disable_functions =
disable_classes =
highlight.string = "#DD0000"
highlight.comment = "#FF9900"
highlight.keyword = "#007700"
highlight.bg = "#FFFFFF"
highlight.default = "#0000BB"
highlight.html = "#000000"
expose_php = 1
max_execution_time = 30
max_input_time = 60
memory_limit = 50M
error_reporting = 6135
display_errors = 1
display_startup_errors =
log_errors = 1
log_errors_max_len = 1024
ignore_repeated_errors =
ignore_repeated_source =
report_memleaks = 1
track_errors =
html_errors =
error_log = "/hsphere/local/var/httpd/logs/php_error.log"
variables_order = EGPCS
register_globals = 0
register_long_arrays = 1
register_argc_argv = 1
auto_globals_jit = 1
post_max_size = 32M
magic_quotes_gpc = 1
magic_quotes_runtime =
magic_quotes_sybase =
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
always_populate_raw_post_data = 1
include_path = ".:/hsphere/shared/apache/libexec/php5ext/php/"
doc_root =
user_dir =
extension_dir = "/hsphere/shared/apache/libexec/php5ext/"
cgi.fix_pathinfo = 1
file_uploads = 1
upload_tmp_dir =
upload_max_filesize = 32M
allow_url_fopen = 1
allow_url_include =
default_socket_timeout = 60
auto_detect_line_endings = 1
[Syslog]
define_syslog_variables =
[mail function]
sendmail_path = "/usr/sbin/sendmail -t -i"
mail.force_extra_parameters =
[SQL]
sql.safe_mode =
[ODBC]
odbc.allow_persistent =
odbc.check_persistent = 1
odbc.max_persistent = "-1"
odbc.max_links = "-1"
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[MySQL]
mysql.allow_persistent =
mysql.max_persistent = "-1"
mysql.max_links = "-1"
mysql.default_port = 3306
mysql.default_socket = "/var/lib/mysql/mysql.sock"
mysql.default_host = localhost
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode =
[MySQLi]
mysqli.max_links = "-1"
mysqli.default_port = 3306
mysqli.default_socket = "/var/lib/mysql/mysql.sock"
mysqli.default_host = localhost
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect =
[PostgresSQL]
pgsql.allow_persistent =
pgsql.auto_reset_persistent =
pgsql.max_persistent = "-1"
pgsql.max_links = "-1"
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[dbx]
dbx.colnames_case = lowercase
[bcmath]
bcmath.scale = 0
[Session]
session.save_handler = files
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = "/"
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[Assertion]
assert.active = 1
assert.warning = 1
assert.bail =
assert.callback = 0
assert.quiet_eval = 0
[Sockets]
sockets.use_system_read = 1
[mbstring]
mbstring.language = neutral
mbstring.internal_encoding = "EUC-JP"
mbstring.http_input = pass
mbstring.http_output = pass
mbstring.encoding_translation =
mbstring.detect_order = auto
mbstring.substitute_character =
mbstring.func_overload = 0
[exif]
exif.encode_unicode = "ISO-8859-15"
exif.decode_unicode_motorola = "UCS-2BE"
exif.decode_unicode_intel = "UCS-2LE"
exif.encode_jis =
exif.decode_jis_motorola = JIS
exif.decode_jis_intel = JIS
[soap]
soap.wsdl_cache_enabled = 1
soap.wsdl_cache_dir = "/tmp"
soap.wsdl_cache_ttl = 86400
zend_extension = "/usr/local/Zend/lib/ZendOptimizer.so"
好了,这样以后自己想修改upload_max_filesize 为多大的就修改为多大的。