mobile traffic detection

这个应该算是老生常谈的问题了,再web design 上早就使用responsive design 来解决了,但是在在线广告领域,除了google 早早就开始使用自适应广告以外,其余的广告还是需要自己去判断的。

这里有两个类可以使用,但是我个人更加偏向于第一个

http://mobiledetect.net/

http://detectmobilebrowsers.com/

LNMP/A的open_basedir问题

军哥的LNMP/LNMPA的默认保护措施open_basedir挺不错的,就是无意中会错杀一些使用,95%的应用是不需要修改的,但是也有5%的例外

LNMP 1.2及更高版本防跨目录功能使用.user.ini,该文件在网站根目录下,可以修改open_basedir的值来设置限制目录的访问。
.user.ini文件无法直接修改,而且是隐藏文件可能在winscp下可能无法看到,建议使用vim编辑器或nano编辑器进行修改。
如要修或删除需要先执行:chattr -i /网站目录/.user.ini
修改完成后再执行:chattr +i /网站目录/.user.ini
.user.ini不需要重启一般5分钟左右生效。
如果要更改网站目录必须要按上述方法修改防跨目录的设置,否则肯定报错!!

LNMPA或LAMP 1.2上的防跨目录的设置使用的对应apache虚拟主机配置文件里的php_admin_value open_basedir参数进行设置。如果不需要设置可以在前面加 # 进行注释,或自行修改目录的限制。
重启apache生效。

The magic behind configure, make, make install

If you’ve used any flavour of Unix for development, you’ve probably installed software from source with this magic incantation:

./configure

make

make install

I know I’ve typed it a lot, but in my early days using Linux I didn’t really understand what it meant, I just knew that if I wanted to install software this was the spell to recite.

Recently I’ve been building my own Unix tools, and I wanted to tap into this standard install process; not only is it familiar to many Unix users, it’s also a great starting point for building a package for Homebrew and the various Linux and BSD package managers. It was time to dig into the Unix Grimoire and find out what the incantation does.更多

Nginx 安装SSL 以及其中的一些安全问题

以前都是图省事,直接使用cpanel 安装SSL,确实简单方便。现在除了两个server还在使用WHM 以外,其余的已经全部使用LNMP 架构了。

今天下午直接在nginx安装SSL,安装倒不麻烦,麻烦的是安装完成以后的安全隐患。

Nginx 在配置中就需要两个文件,一个是private key,这个是在生成CSR的时候一起生成的;另外一个是certification,这个就需要用生成的CSR 去一些SSL 服务商请求certificate

大概流程:

  1. 在服务器上使用Openssl 或者网上的一些工具,生成CSR 以及private Key. 建议使用在线工具直接生成2048 bits 的CSR 和 Private key,可以使用如下两个网站.

 

https://www.digicert.com/easy-csr/openssl.htm

https://www.thesslstore.com/ssltools/csr-generator.php

 

    2. 找一个txt 文档保存好CSR 以及private key

    3. 用生成的CSR 去SSL 服务商那里请求证书,这里建议使用rapidssl,来自于geotrust,便宜快速高效

    4. 等到rapidssl 把证书通过email 的形式发给你的时候,你就可以开始在nginx上安装SSL了

    5. 在nginx 的安装目录下,如果你是通过源代码编译的话,一般就是/usr/local/nginx, 建立一个SSL 文件,把通过email 得到的证书保存为ssl.crt, 把private key 保存为ssl.key

    6. 如果你使用rapidssl 的话,你还得把下载rapidssl intermediaCA certificate, 可以点击这里下载:https://knowledge.rapidssl.com/support/ssl-certificate-support/index?page=content&actp=CROSSLINK&id=INFO1548

使用SO28616

   7 在同一个目录下,把Intermediate CA certificate 保存为intermediate.crt, 然后把这个intermediate.crt 加在ssl.crt 后面才算完成整个证书

   cat intermediate.crt >> ssl.crt

   8 到目前为止,所有的准备工作都算完成,下一步就是配置nginx了,这个很简单,按照nginx 的官方文档

 

http://nginx.org/en/docs/http/configuring_https_servers.html

 

   主要是添加一下三个参数:

   listen XX.XX.XXX.XX:443 ssl;

   ssl_certificate /usr/local/nginx/ssl/ssl.crt;
   ssl_certificate_key /usr/local/nginx/ssl/ssl.key;

 

然后重新启动nginx 即可

一定不要忘记检查一下你的ssl 的安装是否正确: 

https://cryptoreport.rapidssl.com/checker/views/certCheck.jsp

这个网址会清楚的告诉你你安装的SSL 的安全隐患,其中比较著名的就是需要关闭SSLv3,也很简单, 在你的server 或者http block 里面加入如下命令即可:

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # omit SSLv3 because of POODLE (CVE-2014-3566)

ls 命令参数大全

1. List Files using ls with no option

ls with no option list files and directories in bare format where we won’t be able to view details like file types, size, modified date and time, permission and links etc.

2 List Files With option –l

Here, ls -l (-l is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and it’s permission.

3. View Hidden Files with option -a

List all files including hidden file starting with ‘.‘.

4. List Files with Human Readable Format with option -lh

With combination of -lh option, shows sizes in human readable format.

5. List Files and Directories with ‘/’ Character at the end

Using -F option with ls command, will add the ‘/’ Character at the end each directory.

6. List Files in Reverse Order

The following command with ls -r option display files and directories in reverse order.

7. Recursively list Sub-Directories

ls -R option will list very long listing directory trees. See an example of output of the command.

8. Reverse Output Order

With combination of -ltr will shows latest modification file or directory date as last.

9. Sort Files by File Size

With combination of -lS displays file size in order, will display big in size first.

10. Display Inode number of File or Directory

We can see some number printed before file / directory name. With -i options list file / directory with inode number.

11. Shows version of ls command

Check version of ls command.