慎用histats.com

对于正规站点来说, google analytics 无疑是最好的选择

但是对于很多做站群或者website farm 的同学来说, 使用google analytics 会增大被google 关联的机会

因此一直在使用histats,号称全免费

可是今天晚上再debug 源代码的时候发现,所有使用histats 的站点都被添加了 dtscout.com和 dtscdn.com 的CDN JS, 而dtscout.com则是一家数据发现公司

由此可见histats 的免费使用是建立在把数据卖给dtscout.com的基础上

发现了这个问题,就要进行改正

准备把使用histats.com的站点全部迁移到piwik上去

Revive Adserver 无法读取GEO Module

这两天用LNMP 1.3 来安装Revive Adserver,可是悲催的发现无法enable GEO Module。。。各种mysql 的格式都试了还是不行。。。

甚是苦恼。。。

然后啥都干不下。。一直在看Revive Adserver 的源码,想看看是怎么回事。。。没想到这套框架实在太复杂了。。。

今天中午无意间检查了一下debug log file, 无法里面有很多warning。。说是scandir这个功能无法使用。。。心里就大概知道怎么回事了。。

果然enable php scandir 以后,正常读取GEO module。。。

因为以前也是用LNMP 来安装revive adserver也一直没有什么问题。。就一直没有往环境这个问题去想。。

看来这又是LNMP1.3上新加的一个功能。。又是一个坑啊。。

Ubuntu 16.04 LTS 安装lavarel 环境, php7, nginx1.9, mysql5.7

最近有个小的项目是用laravel写的,本来想用虚拟机搞定,可是正好赶上朋友的公司淘汰一批12寸的本,有好多台跟新的差不多,就要了一台来安装ubuntu 来做开发.

Ubuntu 16.04 的repo 自带了最新版本的php7, nginx1.9, mysql5.7, 正合适laravel 的开发环境

下面是详细的安装过程,正好做一个备份方向以后查找

1.更新本地的repo index以及相关的程序

sudo apt-get update

sudo apt-get upgrade

更多

.htaccess 技巧

最近在开发站点时,为了让URL 好看有助于SEO, 仔细研究了一下 apache rewrite 的规则.

  1. mod_rewrite 需要在htaccess 或者 config 中启用FollowSymlinks, 这是rewrite引擎的安全要求
  2. mod_rewrite 可以重写URL ( rewrite) 或者 重定向 ( redirect) URL. 在对同一个domain 进行映射时,是重写, 如果需要重定向的话,需要在结尾加上FLAG R.  URL重写用于将页面映射到本站另一页面,若重写到另一网络主机(域名),则按重定向处理

 

更多

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.