Category: Life

  • 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;
     }
    }
  • 大学生,四不像

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

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

    没有什么故事

  • 事情弄的差不多,毕业了

    大四这一年,起初上学期的享乐生活,一节课也没有

    后来找工作急急忙忙,找的差不多,后来又回校做毕业设计,答辩

    6月5号,班级聚餐

    6月6号,拍毕业照

    6月11号,求索聚餐

    6月14号,出发,去黄山,毕业旅行,15号,向上爬,晚上睡山上又下雨,16号下山回常州。

    6月22号,拿毕业证,从楼上扔东西,晚上一起逛了最后一次校园。

    6月23号,收拾东西,把他们没拿走的东西贪污掉,卖掉电风扇和被子,交宿舍钥匙,买票离别兄弟们,回南京。

    接下来清理电脑里面的和工作、生活无关的软件和文件

    各种用不到的vpn,宽带上网助手,网银插件,vs2008,sybase power desiner,会声会影。

    清理通讯录,办一张南京的手机号,银行卡,开始南京的生活

    graduate from cczu

  • httpd重启输入key的问题

    [root@sls-bb21p18 private]# openssl rsa < managed.name.key > managed.name.key.nopw
    Enter pass phrase:
    writing RSA key

    openssl rsa -in server.key -out server.key

    回到/etc/httpd/conf.d/ssl.conf,把证书改为managed.name.key.nopw就可以了

  • mysql多表查询

    内部连接 inner join 两表都满足的组合
    full outer 全连 两表相同的组合在一起,A表有,B表没有的数据(显示为null),同样B表有
    A表没有的显示为(null)
    A表 left join B表 左连,以A表为基础,A表的全部数据,B表有的组合。没有的为null
    A表 right join B表 右连,以B表为基础,B表的全部数据,A表的有的组合。没有的为null
    查询分析器中执行:
    –建表table1,table2:
    create table table1(id int,name varchar(10))
    create table table2(id int,score int)
    insert into table1 select 1,’lee’
    insert into table1 select 2,’zhang’
    insert into table1 select 4,’wang’
    insert into table2 select 1,90
    insert into table2 select 2,100
    insert into table2 select 3,70
    如表
    ————————————————-
    table1|table2|
    ————————————————-
    idname|idscore|
    1lee|190|
    2zhang|2100|
    4wang|370|
    ————————————————-

    以下均在查询分析器中执行

    一、外连接
    1.概念:包括左向外联接、右向外联接或完整外部联接

    2.左连接:left join 或 left outer join
    (1)左向外联接的结果集包括 LEFT OUTER 子句中指定的左表的所有行,而不仅仅是联接列所匹配的行。如果左表的某行在右表中没有匹配行,则在相关联的结果集行中右表的所有选择列表列均为空值(null)。
    (2)sql 语句
    select * from table1 left join table2 on table1.id=table2.id
    ————-结果————-
    idnameidscore
    ——————————
    1lee190
    2zhang2100
    4wangNULLNULL
    ——————————
    注释:包含table1的所有子句,根据指定条件返回table2相应的字段,不符合的以null显示

    3.右连接:right join 或 right outer join
    (1)右向外联接是左向外联接的反向联接。将返回右表的所有行。如果右表的某行在左表中没有匹配行,则将为左表返回空值。
    (2)sql 语句
    select * from table1 right join table2 on table1.id=table2.id
    ————-结果————-
    idnameidscore
    ——————————
    1lee190
    2zhang2100
    NULLNULL370
    ——————————
    注释:包含table2的所有子句,根据指定条件返回table1相应的字段,不符合的以null显示

    4.完整外部联接:full join 或 full outer join
    (1)完整外部联接返回左表和右表中的所有行。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含空值。如果表之间有匹配行,则整个结果集行包含基表的数据值。
    (2)sql 语句
    select * from table1 full join table2 on table1.id=table2.id
    ————-结果————-
    idnameidscore
    ——————————
    1lee190
    2zhang2100
    4wangNULLNULL
    NULLNULL370
    ——————————
    注释:返回左右连接的和(见上左、右连接)

    二、内连接
    1.概念:内联接是用比较运算符比较要联接列的值的联接

    2.内连接:join 或 inner join

    3.sql 语句
    select * from table1 join table2 on table1.id=table2.id
    ————-结果————-
    idnameidscore
    ——————————
    1lee190
    2zhang2100
    ——————————
    注释:只返回符合条件的table1和table2的列

    4.等价(与下列执行效果相同)
    A:select a.*,b.* from table1 a,table2 b where a.id=b.id
    B:select * from table1 cross join table2 where table1.id=table2.id (注:cross join后加条件只能用where,不能用on)

    三、交叉连接(完全)

    1.概念:没有 WHERE 子句的交叉联接将产生联接所涉及的表的笛卡尔积。第一个表的行数乘以第二个表的行数等于笛卡尔积结果集的大小。(table1和table2交叉连接产生3*3=9条记录)

    2.交叉连接:cross join (不带条件where…)

    3.sql语句
    select * from table1 cross join table2
    ————-结果————-
    idnameidscore
    ——————————
    1lee190
    2zhang190
    4wang190
    1lee2100
    2zhang2100
    4wang2100
    1lee370
    2zhang370
    4wang370
    ——————————
    注释:返回3*3=9条记录,即笛卡尔积

    4.等价(与下列执行效果相同)
    A:select * from table1,table2