Joyber 发布的文章

PHP7.1

./configure --prefix=/usr/local/php7 --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --with-gd --with-freetype-dir=/usr/local/freetype24 --with-mcrypt

PHP5.6

yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel freetype freetype-devel jpegsrc libpng libpng-devel

创建 www 用户

groupadd www

useradd -g www -s /sbin/nologin -M www

./configure --prefix=/usr/local/php56 --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --with-gd --with-freetype-dir=/usr/local/freetype24

转一个文章(参数含义):
https://blog.csdn.net/niluchen/article/details/41513217

# 指定 php 安装目录

--prefix=/usr/local/php 

# 指定php.ini位置

--with-config-file-path=/usr/local/php/etc 

# mysql安装目录,对mysql的支持

--with-mysql=/usr/local/mysql

mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。

--with-mysqli=/usr/local/mysql/bin/mysql_config   

整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块

--with-apxs2=/usr/local/apache/bin/apxs 

# 选项指令 --with-iconv-dir 用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。

--with-iconv-dir=/usr/local 

 

--with-freetype-dir   打开对freetype字体库的支持 

--with-jpeg-dir   打开对jpeg图片的支持 

--with-png-dir   打开对png图片的支持 

--with-zlib-dir   打开zlib库的支持,用于http压缩传输

--with-libxml-dir   打开libxml2库的支持

--disable-rpath    关闭额外的运行库文件 

--enable-bcmath    打开图片大小调整,用到zabbix监控的时候用到了这个模块

--enable-shmop --enable-sysvsem  这样就使得你的PHP系统可以处理相关的IPC函数了。

--enable-inline-optimization  优化线程

--with-curl    打开curl浏览工具的支持 

--with-curlwrappers    运用curl工具打开url流 

--enable-mbregex

--enable-fpm 打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序

--enable-mbstring    多字节,字符串的支持 

--with-mcrypt                    mcrypt算法扩展

--with-mhash                     mhash算法扩展

--with-gd    打开gd库的支持 

--enable-gd-native-ttf   支持TrueType字符串函数库

--with-openssl      openssl的支持,加密传输https时用到的

--enable-pcntl   freeTDS需要用到的,可能是链接mssql 才用到

--enable-sockets     打开 sockets 支持

--with-xmlrpc    打开xml-rpc的c语言 

--enable-zip   打开对zip的支持 

--enable-ftp   打开ftp的支持 

 

--with-bz2    打开对bz2文件的支持        

--without-iconv   关闭iconv函数,字符集间的转换 

--with-ttf     打开freetype1.*的支持,可以不加了 

--with-xsl     打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 

--with-gettext     打开gnu 的gettext 支持,编码库用到 

--with-pear    打开pear命令的支持,PHP扩展用的 

--enable-calendar    打开日历扩展功能

--enable-exif    图片的元数据支持 

--enable-magic-quotes    魔术引用的支持 

 

--disable-debug    关闭调试模式 

--with-mime-magic=/usr/share/file/magic.mime      魔术头文件位置

CGI方式安装才用的参数

 

--enable-fastCGI            支持fastcgi方式启动PHP

--enable-force-CGI-redirect        重定向方式启动PHP

--with-ncurses         支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库

--with-gmp  应该是支持一种规范

--enable-dbase                     建立DBA 作为共享模块

--with-pcre-dir=/usr/local/bin/pcre-config      perl的正则库案安装位置

--disable-dmalloc

--with-gdbm                     dba的gdbm支持

--enable-sigchild

--enable-sysvshm

--enable-zend-multibyte         支持zend的多字节

--enable-wddx

--enable-soap

方法一:
将下面的内容保存到nginx.conf同级目录,比如:deny1.conf

# 针对单个ip的形式
deny 171.94.171.205;
deny 115.29.166.101;
deny 182.247.251.48;
deny 61.147.89.17;

# 针对网段的形式
deny 66.249.227.0/24;

然后在nginx.conf 的 http 段 引入这个文件,重启生效(注意这个是整体全部的网站配置的禁止这些IP访问了,谨慎使用):

include deny1.conf; 

方法二:
有针对性的阻止,比如有些人工的发起请求,或许其他的你不想要的访问,通常是异常的客户端UA,可以这么做:

将下面的内容也保存到一个文件,也是nginx.conf同级目录,比如:deny2.conf

#禁止常用工具的抓取
 if ($http_user_agent ~* "Scrapy|Curl|HttpClient|Java") {
  return 403;
 }
 #禁止指定UA及UA为空的访问
 if ($http_user_agent ~* "Baidu-YunGuanCe|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$" ) {
  return 403;
 }

这里注意需要把里面的正则表达式修改成你需要的正则表达式,以免达不到你要的效果

然后在nginx.conf 的 server 段(也就是某个网站的配置而不是http段) 引入这个文件,重启生效:

http{
   ...
   server {
       ...
       include deny2.conf;
       ...
   }
   ...
}

先测试有没有配置错误

nginx -t

再重启服务

nginx -s reload 

Xshell 56 评估过期,需要采购,不能使用的解决办法,其实有免费的版本可以用,不需要去下载什么破解版,真的不安全,容易被人置后门,中毒什么的。

那么我们怎么办,下载免费的授权,很多开发者不知道,我也是今天到期了才找到的。

直接进入官网免费的授权页面: https://www.netsarang.com/download/free_license.html

下载 xshell 或者 xftp ,这个页面的下载是免费版的,点完下载会出现一个填写资料的页面,填写自己的姓名和邮箱就可以了,会把下载软件的地址发到你的邮箱,从邮箱进去点击下载软件,安装好就可以用。

最新版还可以,更新了不少的功能,非常赞。。

谢谢看我在这BB了。

有了 FormID,就相当于有了给用户发送模板消息的权限,一个Formid只能发送一条消息,且这个FormId 的有效期只有7天。

微信相关的文档:
https://developers.weixin.qq.com/miniprogram/dev/api/notice.html#发送模板消息

之前也在网上看过到类型的代码和思路参考,只是他们的实现方法都不太符合我的要求,所以自己写了。

目前普遍的做发就是先把用户在小程序里的操作产生的formid收集到后台系统保存起来,需要发的时候直接从后台数据中取出,发送一条消耗一个fromid,过期就自动删除掉。要产生formid前台还必需使用form标签,再写上对应的属性,然后用户要手动去点击了表单的提交按钮才能得到一个fromID。

思路
就是把你页面中(尽量可能多的把所有页面都加上),用户经常会去点的按钮,图片等都用form标签给包起来,再form里面放上一个提交的按钮,改下按钮的样式,透明、大小和原本的按钮、图片的大小一样,这样用户去点击的时候,际实上是点击的表单的提交按钮,所以就拿到了formid ,然后提交到后台保存,后台推荐用像redis这样的缓存服务来保存

实现
这里我把自己写的收集代码片段分享给大家(使用wepy框架,仅供大家参考提供思路):

这是mixins组件,怎么使用这里就不说明了
PS:$post是我自己封装的一个请求方法, 注意:the formId is a mock one 这是开发者工具的固定值,这里不作提交,开发可以去掉看效果

form.js

import wepy from 'wepy'

import {$post, config} from './base'

/**
 * @author Joyber
 * 收集用户的FormID的MIXINS
 * 用法:
 *
 <form class="_f [原有的classname]" report-submit @submit="FormSubmit"
    data-event="[原有的方法]">
 <button class="_f" form-type="submit"></button>
    [原有的标签内容]
 </form>

 */

export default class formMixin extends wepy.mixin {

    methods = {
        FormSubmit(e) {
            let _this = this;
            const {formId, value} = e.detail;
            const {dataset} = e.currentTarget;
            const {event} = dataset;

            config.debug && console.log('formId', formId);
            //the formId is a mock one  这是开发者工具的固定值,这里不作提交
            formId && formId!='the formId is a mock one' && $post("member/form/id", {formId});

            if (!event) return;
            if (typeof _this.methods[event] == 'function') {
                _this.methods[event].call(_this, e);
            } else if (typeof _this[event] == 'function') {
                _this[event].call(_this, e);
            } else {

                let flag = false;
                const {$mixins} = _this;
                config.debug && console.log(typeof $mixins, $mixins);

                $mixins.forEach((mixin, index)=>{
                    config.debug && console.log('find mixin function', index);
                    if (mixin.methods && typeof mixin.methods[event] == 'function') {
                        flag = true;
                        mixin.methods[event].call(_this, e);
                    }else if (typeof mixin[event] == 'function') {
                        flag = true;
                        mixin[event].call(_this, e);
                    }
                });
                !flag && console.error('page function undefined: ' + event);
            }
        }
    }
}

使用

全局CSS(less语法):

form{
    &._f{
        position: relative;
        display: block;
        &._b{display: block;}
        button {
            &._f {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                background: transparent;
                z-index:1;
                &::after {display: none;}
            }
        }
    }
}

代码改造:
原来的页面代码比如:

<view class="XXXX1" @tap="xxxx2" data-id="xxxx3"><image src="xxx4"></image></view>

改造后的页面代码:

 <form class="_f XXXX1" report-submit @submit="FormSubmit"
    data-event="xxxx2" data-id="xxxx3">
 <button class="_f" form-type="submit"></button>
    <image src="xxx4"></image>
 </form>

而JS中只需要把 form.js import进来

wx.page 的 mixins 中 增加 formMixin 即可。
mixins = [formMixin]

本人文采不好,见谅!