Category: Web

  • nginx 504 Gateway Time-out

    在单纯php-fpm+ nginx的情况下,出现这个问题

    说明fastcgi设置超时时间太短

    在fastcgi_params中加入如下语句,问题解决

    fastcgi_buffers 8 128k;
    fastcgi_buffer_size 128k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
  • javascript跳转

    在header里写功能函数

    var secs =5;
    var URL;
    function Load(url){
    URL = url;
    for(var i=secs; i>=0; i--){
    window.setTimeout('doUpdate(' + i + ')', (secs-i) * 1000);
    }
    }
    function doUpdate(num){
    document.getElementById('timer').innerHTML= num;
    if(num == 0){ window.location = URL;}
    }

    写一个span,然后不断更新秒数

    span id="timer"
    javascript:
    Load("/login");
  • ruby连接mysql数据库

    以下操作在ubuntu下进行

    前提要安装好ruby-mysql

    gem install ruby-mysql
    require 'rubygems'
    require 'mysql'
    begin
      db = Mysql.new('localhost', 'username', 'password', 'password')
      puts "connected"
    rescue Mysql::Error
      puts "Oh noes! We could not connect to your database. -_-;;"
      exit 1
    end
    
    begin
      results = db.query "select * from blog.wp_users;"
      puts "blog has #{results.num_rows} users."
      puts results.class
      results.each do |row|
        puts row.join(" |  ")
      end
      results.free
    ensure
      db.close
    end

    结果将打印出wp_users这张表中的内容。

  • 常见的ipv6地址或前缀

    ::/128 0:0:0:0:0:0:0:0
    未指定地址。只能作为尚未获得正式地址的主机的源地址,不能作为目的地址,不能分配给真实的网络接口
    ::1/128 0:0:0:0:0:0:0:1
    回环地址,相当于ipv4中的localhost(127.0.0.1),在windows下,ping locahost可得到此地址

    2001::/16 全球可聚合地址,由 IANA 按地域和ISP进行分配,是最常用的IPv6地址。2001::/32- 用于Teredo tunneling。如

    ping6 cgbt.cn(2001:da8:205::100)

    ping6 ipv6.cczu.edu.cn(2001:da8:1008:1::2)。
    2002::/16 6to4地址,用于6to4自动构造隧道技术的地址。

    3ffe::/16 早期开始的IPv6 6bone试验网地址

    注:上面三类属于单播地址,都是目前互联网上广泛应用的IPv6地址

    fe80::/10 本地链路地址,用于单一链路,适用于自动配置、邻机发现等,路由器不转发。类似于IPv4中的169.254.0.0/16。

    ff00::/8 组播地址

    ::A.B.C.D 其中<A.B.C.D>代表ipv4地址,兼容IPv4的IPv6地址。自动将IPv6包以隧道方式在IPv4网络中传送的IPv4/IPv6节点将使用这些地址,目前已经被取消。

    ::FFFF:A.B.C.D 其中<A.B.C.D>代表ipv4地址,例如 ::ffff:202.120.2.30 ,是IPv4映射过来的IPv6地址,它是在不支持IPv6的网上用于表示IPv4节点

    分享一个ipv6的工具网站

    https://www.ultratools.com/tools/ipv4toipv6

  • PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted

    今天在用某程序生成html文章的时候,到46%的时候页面空白了。

    首先就是查nginx的日志

    2012/11/18 22:01:02 [error] 11485#0: *66546 FastCGI sent in stderr: “PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in ….

    网上一查,才发现设定的值偏小了,到php.ini查找,466行处

    memory_limit = 128M

    改为256M后,重新生成html,没有问题了。

    昨天刚学了vim的一个技巧:将光标定位在128上,按住ctrl+a,数字变大,这次正好用上了。(数字减小,按ctrl+x)

    另一种方法是修改程序,不建议这样操作。

    具体说明在:http://www.php.net/manual/en/ini.core.php#ini.memory-limit

    要设置不限制,则值为-1

     

  • 解决WHMCS的PDF账单中文字体乱码

    whmcs 版本 512 发的邮件附件里有PDF账单

    显示中文的地方全为  ???

    需要设置3个地方

    1.logo

    把logo制作成logo.png(250*90会比较好看),放入 目录/images/,之后生成的账单会自动加上logo.

    2.公司地址或标语等文字

    在后台General Settings->Pay To Text填写

    3.中文显示问题

    参考:http://www.yinzhili.com/2009/08/using-tcpdf-to-generate-pdf-in-chinese.html

    原理是利用tcpdf这个php程序来生成pdf,但是默认没有中文字库,现在要把中文字库的三个文件droidsansfallback.ctg.z droidsansfallback.php droidsansfallback.z 放入到目录/includes/fonts/下,然后回到whmcs设置字库General Settings->Invoices->TCPDF Font Family->Custom->droidsansfallback

    有好心网友放出了droidsansfallback字库载地址:http://download.csdn.net/download/huyuchengus/2455138

    之后就可以完整的生成pdf账单了