Directadmin平滑升级nginx版本,添加nginx–http–concat模块

作者:@ouyang 发布时间:2016年02月20日 阅读: 3,071 分类:学习笔记 暂无评论

[root@server ~]#nginx -V   //查看Nginx安装信息以及目录
nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt=''-D FD_SETSIZE=32768''

下载nginx-http-concat模块以及nginx最新版本

[root@server ~]# git clone git://github.com/alibaba/nginx-http-concat.git  //下载nginx-http-concat模块
[root@server ~]# mv nginx–http–concat/ /usr/local/src/nginx-http-concat   //将模块移动到指定目录
[root@server ~]# wget http://nginx.org/download/nginx-1.9.11.tar.gz  //下载最新nginx版本
[root@server ~]# tar zxvf nginx-1.9.11.tar.gz  //解压
[root@server ~]# cd nginx-1.9.11   //进入nginx最新目录

这里需要修改一下nginx-http-concat的ngx_http_concat_module.c文件,因为nginx最新的js类别已经修改成application/javascript。所以需要将ngx_http_concat_module.c里的application/x-javascript修改成application/javascript。不然js无法合并,并会提示400错误。

[root@server nginx-1.9.11]# vi /usr/local/src/nginx-http-concat/ngx_http_concat_module.c
找到
ngx_string("application/x-javascript")
将其修改为
ngx_string("application/javascript")
:wq  //保存

现在可以进行编译了,将nginx-http-concat一起与nginx编译。

[root@server nginx-1.9.11]# ./configure  --user=nginx --group=nginx --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt="-D FD_SETSIZE=32768" --add-module=/usr/local/src/nginx-http-concat
make

make以后进入objs

[root@server nginx-1.9.11]# cd ./objs
[root@server objs]# mv /usr/sbin/nginx /usr/sbin/nginx.old   //移动1.8版本nginx为nginx.old
[root@server objs]# cp nginx /usr/sbin/nginx  //将刚编译的1.9.11的nginx复制原地址。

这个时候基本就升级完成了。

[root@server objs]# nginx -V
nginx version: nginx/1.9.11
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr --user=nginx --group=nginx --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --with-ipv6 --without-mail_imap_module --without-mail_smtp_module --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-cc-opt='-D FD_SETSIZE=32768' --add-module=/usr/local/src/nginx-http-concat

这时候看到nginx版本升级到指定版本,并且看到nginx-http-concat已经成功编译进去。
但还没有完成,我们还需要在nginx.conf里面进行配置。
举例:

server
{
        listen 120.0.0.1:80;
        server_name ouyang.wang www.ouyang.wang ;
        access_log /var/log/nginx/domains/ouyang.wang.log;
        access_log /var/log/nginx/domains/ouyang.wang.bytes bytes;
        error_log /var/log/nginx/domains/ouyang.wang.error.log;
        root /home/domains/ouyang.wang/public_html;
        index index.htm index.html index.php;
        include /usr/local/directadmin/data/users/news/nginx_php.conf;
        location / {
        concat on;
        concat_max_files 20;
        concat_unique off;  //允许不同类型文件合并
        }
        include /etc/nginx/webapps.conf;
}

只需要将下列加入server里即可。

        location / {
        concat on;
        concat_max_files 20;
        concat_unique off; 
        }

参数说明:

# nginx_concat_module 开关
concat on; 

# 最大合并文件数
# concat_max_files 10;

# 允许不同类型文件合并
# concat_unique off;

# 允许合并的文件类型,多个以逗号分隔。如:application/javascript, text/css
# concat_types application/javascript, text/css;

配置保存完成后,启动nginx即可。

 systemctl reload nginx.service

PHP获取当前日期和时间格式化方法

作者:@ouyang 发布时间:2016年01月24日 阅读: 3,352 分类:学习笔记 暂无评论

使用函式 date() 实现


显示的格式: 年-月-日 小时:分钟:妙

相关时间参数:
a - "am" 或是 "pm"
A - "AM" 或是 "PM"
d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"
D - 星期几,三个英文字母; 如: "Fri"
F - 月份,英文全名; 如: "January"
h - 12 小时制的小时; 如: "01" 至 "12"
H - 24 小时制的小时; 如: "00" 至 "23"
g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"
G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"
i - 分钟; 如: "00" 至 "59"
j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"
l - 星期几,英文全名; 如: "Friday"
m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"
n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"
M - 月份,三个英文字母; 如: "Jan"
s - 秒; 如: "00" 至 "59"
S - 字尾加英文序数,二个英文字母; 如: "th","nd"
t - 指定月份的天数; 如: "28" 至 "31"
U - 总秒数
w - 数字型的星期几,如: "0" (星期日) 至 "6" (星期六)
Y - 年,四位数字; 如: "1999"
y - 年,二位数字; 如: "99"
z - 一年中的第几天; 如: "0" 至 "365"

phpcms其中获取内容也时间方式为:{date('Y-m-d H:i:s', $rs['inputtime'])}

修改phpsso_server的工作路径

作者:@ouyang 发布时间:2016年01月12日 阅读: 3,414 分类:学习笔记 暂无评论

1、移动phpsso_server目录

将根目录下的phpsso_server移动到其他文件路径下。
2、给该目录绑定新的域名,一级域名或者二级域名均可。
3、修改 phpsso_server 下面的配置文件。

阅读剩余部分...

phpcms v9文章排序功能的方法

作者:@ouyang 发布时间:2016年01月02日 阅读: 3,096 分类:学习笔记 暂无评论

phpcms v9自带的相关文章、专题等模块不支持order排序,调用的相关文章、专题默认为升序,这样就造成了一个问题,调出来的相关文章是最早的文章,没有时效性。我们只能通过修改程序文件,只需简单修改一个文件,就能达到我们的需求。
修改相关文章排序的方法:
打开根目录下的phpcms/modules/content/classes/content_tag.class.php,找到

$r = $this->db->select($sql2, '*', $limit, '','','id');

修改为:

$r = $this->db->select($sql2, '*', $limit, $order,'','','id');

PC标签格式如下:

{pc:content action="relation" relation="$relation" id="$id" catid="$catid" num="5" order="inputtime DESC" keywords="$rs[keywords]"}

阅读剩余部分...

利用TTL将WDR4310刷回官方固件

作者:@ouyang 发布时间:2015年10月21日 阅读: 4,156 分类:技术相关,发现分享 暂无评论

TTL链接步骤就直接省略。
修改IP为192.168.1.100 子网掩码为255.255.255.0
将固件复制到tftp文件夹(不带uboot的固件,一般大小为7.75M,如果有uboot请使用winhex软件进行处理。)
把固件改名为“6F01A8C0.img”,启动tftp软件

阅读剩余部分...

话说QQ群签到玩法一二技巧

作者:@ouyang 发布时间:2015年08月25日 阅读: 3,599 分类:热点话题 暂无评论

QQ推出了群签到,连续签名15天会有橙色名字赐予,对于VIP党来说这可以忽略了。当然最重要的是可以批量进行签名,只要一个PHP文件即可,在服务器上做个定时任务,执行PHP,每天就能够自动签名了,一劳永逸的方法。
将下面代码存为PHP文件即可,放到服务器上或本地运行PHP即可执行你全部的群签到。
Github项目地址:https://github.com/xqin/qiandao

un = preg_replace('/^o0*/', '', $uin);//数字QQ号码
        $this->cookie = sprintf('Cookie: uin=%s; skey=%s;', $uin, $skey);//Cookie

        $this->g_tk = $this->getGTK($skey);//计算 g_tk

        $this->sign($this->getQunList());//获取群列表并签到
    }

    function getGTK($skey){
        $len = strlen($skey);
        $hash = 5381;

        for($i = 0; $i < $len; $i++){
            $hash += ($hash << 5) + ord($skey[$i]);
        }

        return $hash & 0x7fffffff;//计算g_tk
    }

    function getQunList(){
        $html = @file_get_contents(
                sprintf('http://qun.qzone.qq.com/cgi-bin/get_group_list?uin=%s&g_tk=%s', $this->un, $this->g_tk),
                false,
                stream_context_create(array(
                    'http'=>array(
                        'method'=>'GET',
                        'header'=>$this->cookie
                    )
                ))
            );

        preg_match('/(\{[\s\S]+\})/', $html, $qunList);

        if(count($qunList) == 0){
            return NULL;
        }

        $qunList = json_decode($qunList[1]);

        if($qunList == NULL || $qunList->code != 0){
            return NULL;
        }

        return $qunList->data->group;
    }

    function sign($groups){
        if($groups == NULL)return;

        $i = 1;
        foreach($groups as $qun){
            $this->qiandao($qun->groupid);//签到
            printf("%d\t%s(%d)\tok\r\n", $i++, $qun->groupname, $qun->groupid);//输出群信息
        }
    }

    function qiandao($qin){
        @file_get_contents($this->signUrl, false,
            stream_context_create(
                array('http' => array(
                    'method'  => 'POST',
                    'header'  => $this->cookie,
                    'content' => sprintf('gc=%s&is_sign=0&bkn=%s', $qin, $this->g_tk)
                ))
            )
        );
    }
}

这样玩不够爽?能自定义签到内容吗?这当然可以。
准备工具:Chrome和一个抓包工具,可以用Fiddler。
先打开Fiddler,然后打开想要签到的QQ群,点击签到功能(不要点击签到),然后在Fiddler里面能够找到gc和bkn的值。
QQ群BKN值

OK,打开Chrome,然后打开http://qiandao.qun.qq.com/,登录QQ,F12打开开发工具,先引入jq.
引入jq代码:

;(function(d,s){d.body.appendChild(s=d.createElement('script')).src='http://code.jquery.com/jquery-1.9.1.min.js'})(document);

然后(实现自定义签名说明的代码来了。)

$.post("http://qiandao.qun.qq.com/cgi-bin/sign",
	{
		gc:"XX55XXX", //这里填写你获取到的gc值
		is_sign:"0",
		from:"1",
		bkn:"XXX88XXXX", //这里填写你获取到的bkn值
		poi:"群也好久了,对于签到,其实是个苦力活,要签到起码要能够做点广告吧?来吧,来友链一个吧?http://www.joming.com 欢迎来换友链,就这样吧,Joming在此",
	},
	function(data,status)
		{
		alert("数据:"+ data.ec);
		}
	);

好了,检查你刚才打开的群吧。是不是签到成功了?

Centos安装oracle 11g R2详解

作者:@ouyang 发布时间:2015年08月10日 阅读: 3,130 分类:Linux摘要 暂无评论

安装所需要的组建环境

yum install gcc libaio libaio-devel libstdc++ libstdc++-devel libgcc elfutils-libelf-devel glibc-devel glibc-devel gcc-c++ compat-libstdc++-33 unixODBC unixODBC-devel

Oracle安装还需要一个必要的rpm包,pdksh-5.2.14-37.el5_8.1.x86_64,解压rpm -ivh安装即可。

创建oinstall组
groupadd oinstall

创建dba组
groupadd dba

创建oracle用户
useradd -g oinstall -G dba oracle

修改oracle用户的密码
passwd oracle (设立会提示输入自己的密码)

阅读剩余部分...

网站检测爆任意文件解析问题解决方法

作者:@ouyang 发布时间:2015年08月09日 阅读: 3,246 分类:技术相关 暂无评论

在一张图片地址后面加 www.domain.com/test.jpg/p.php 居然能够解析显示出来,被网站检测提示高危漏洞,红红一大列表,吓死宝宝了。任意文件解析解决方法很简单,将php配置文件php.ini中设置cgi.fix_pathinfo=0即可。重启nginx或者apache即可。

多屏幕操作神器之Synergy

作者:@ouyang 发布时间:2015年08月04日 阅读: 3,594 分类:发现分享 暂无评论

有时候想如果能够在笔记本上同时控制台式电脑就像分屏一样控制那该多好,于是乎找了一下Google,发现神器Synergy。之所以称之为神器,因为确实太方便了。
共享屏幕

synergy下载地址,http://synergy-project.org/nightly
我这里下载的是synergy-v1.7.4-rc4-f81e88b-Windows-x64.msi,Synergy夸平台,MACOS,Linux都可以使用。

安装步骤很简单,一路Next,安装完后,会自动运行,选择中文节目,选择模式即可。
在使用过程中走了不少弯路,中间一直运行不起来,提示错误。

阅读剩余部分...

ESXi环境安装的CentOS6.5出现connect: Network is unreachable

作者:@ouyang 发布时间:2015年07月31日 阅读: 4,515 分类:Linux摘要 暂无评论

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
//起初ONBOOT=no,改成yes。将BOOTPROTO=dhcp改成static,加入IP地址和网关。
DEVICE=eth0
HWADDR=00:0C:29:8D:59:30
TYPE=Ethernet
UUID=c0843d27-05d2-490c-91d3-69fa230b8d3d
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.5.35
NETMASK=255.255.255.0
GATEWAY=192.168.5.1

ONBOOT为系统启动时是否激活网卡。