Blog

  • apache开启gzip压缩和浏览器缓存功能

    http://witmax.cn/apache-deflate-expires.html

    1、开启gzip压缩

    开启gzip功能能大大降低网络传输的带宽,从而提高网页加载速度;一般对纯文本内容可压缩到原大小的40%。

    (1) 编辑Apache配置文件httpd.conf,查找下面这一行

    #LoadModule deflate_module modules/mod_deflate.so

    删除前面的#;如没有就查找LoadModule位置,加入上述行
    (2) 在httpd.conf末尾增加以下内容:

    <ifmodule mod_deflate.c>
    DeflateCompressionLevel 9
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
    AddOutputFilter DEFLATE css js
    </ifmodule>

    具体配置内容可参考mod_deflate模块手册。

    (3) 重启Apache服务

    2、开启浏览器缓存功能

    开启浏览器缓存后,在内容未过期前,浏览器不会重复从服务器提取数据文件,从而减少网页内容传输,提高网页打开速度。

    (1) 编辑Apache配置文件httpd.conf,查找下面这一行

    #LoadModule expires_module modules/mod_expires.so

    删除前面的#;如没有就查找LoadModule位置,加入上述行

    (2) 在httpd.conf末尾增加以下内容:

    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 12 month"
    ExpiresByType text/html "access plus 12 months"
    ExpiresByType text/css "access plus 12 months"
    ExpiresByType image/gif "access plus 12 months"
    ExpiresByType image/jpeg "access plus 12 months"
    ExpiresByType image/jpg "access plus 12 months"
    ExpiresByType image/png "access plus 12 months"
    EXpiresByType application/x-shockwave-flash "access plus 12 months"
    EXpiresByType application/x-javascript "access plus 12 months"
    ExpiresByType video/x-flv "access plus 12 months"
    </IfModule>

    具体配置内容可参考mod_expires模块手册。

    (3) 重启Apache服务

  • apache/nginx某目录abc强制https访问

    apache

    把如下代码写一个.htaccess,丢到/abc/里面

    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)?$ https://%{SERVER_NAME}/abc/$1 [L,R]

    nginx

    配置文件里写

    location /abc/ {
     if ( $scheme = 'http' ) {
     rewrite ^(.*)$ https://$host$1 permanent;
     }
    }
  • 解决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账单了

  • 大学生,四不像

    毕业一个多月了,怎么才能走出这种无耐

    发现自己做不了的事情太多太多了

    没有什么故事

  • ipad2 wifi

    从ttyo那里以男朋友的价格买来了ipad2 wifi 白色。

    ttyo条件比我好,也知道我喜欢苹果的产品,这小妞对我很好。

    我也不能总把面子放在前面,好好工作,好好对她。

    ipad2 wifi
    ipad2 wifi
  • vim查看和更改文件的编码格式

    在Vim中查看文件编码

    :set fileencoding

    即可显示文件编码格式。
    如果你只是想查看其它编码格式的文件或者想解决 用Vim查看文件乱码的问题,那么在
    ~/.vimrc 文件中添加以下内容:

    set encoding=utf-8 fileencodings=utf-8

    这样,就可以让vim自动识别文件编码(可以自动识别UTF-8或 者GBK编码的文件),其实就是依照fileencodings提供的编码列表尝试,如果没有找到合适 的编码,就用latin-1(ASCII)编码打开。

    以指定的编码打开某文件

    如打开windows中以ANSI保存的文件

    vim file.txt -c "e ++enc=GB18030"

    文件编码转换

    在Vim中直接进行转换文件编码,比如将一个文件转换成utf-8格式

    :set fileencoding=utf-8

    查看文件格式

    :set fileformat?

    设置文件格式为 unix

    :set fileformat=unix

    设置 Byte Order Mark (BOM)

    :set bomb
    

    只保留文件 file a.txt 为 UTF-8 Unicode (with BOM) text, with CRLF line terminators

    :e ++ff=dos