下载Adobe Flash Player

https://get.adobe.com/flashplayer/?no_redirect

解压:


tar -xf xxx.tar
得到一个libpepflashplayer.so文件。


2. 加入Chromium的插件文件夹


sudo cp libpepflashplayer.so /usr/lib/chromium-browser/plugins

3. 在Chromium的启动选项中加入这一插件


sudo gedit /etc/chromium-browser/default
在flags一行加上:


CHROMIUM_FLAGS="--ppapi-flash-path=/usr/lib/chromium-browser/plugins/libpepflashplayer.so --ppapi-flash-version=11.5.31.2"
version可以从下载包里面的manifest.json文件里面看到。

启用插件

启动Chromium浏览器,在地址栏输入
chrome://plugins/

启用插件即可


http://www.cnblogs.com/linkzijun/p/6492761.html
save_cycle_data || { echo 'save cycle data failed' && exit 1; }  #调用函数失败的写法
basedir=$(cd "$(dirname "$0")";pwd)
echo $basedir

cat /backup/3306/cycle_file
BASE_ID=base-2018-06-11-1203
INCREMENTAL_STEP=20534973839
LAST_LSN=2
获取到等号后面的位置:


获取INNODB的Last checkpoint at:


参数之f3,砍断后第三节,如下:

$git branch -a|grep -v "*" | grep -v ">"
  master
  remotes/origin/dev
  remotes/origin/master


Cut上来:

$git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3
  master
dev
master



sed 去空格和Tab:

git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3|sed "s/^[ \t]*//g"



去掉重复行:

$git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3|sed "s/^[ \t]*//g"
master
dev
master



按正顺序sort:(反着排序 -r)

$git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3|sed "s/^[ \t]*//g"|sort
dev
master
master



uniq上来去重:

git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3|sed "s/^[ \t]*//g"|sort|uniq



防止太多,限制10条,head -10上来:

git branch -a|grep -v "*" | grep -v ">"|cut -d "/" -f3|sed "s/^[ \t]*//g"|sort|uniq|head -10




当然,还有更简单的,不用git branch -a:
主要是了解命令:

$git branch |sed "s# ##g"|sed "s#*##"
dev
master

addr:You have new mail in /var/spool/mail/root


背景:发现df 特别慢,用strace df -h ,发现卡在/mnt/backup,想cd /mnt卡住了,于是,怎么办?发现NFS的Server端都宕机了。
cat /proc/mounts
umount -lf   /mnt/backup
umount: only root can do that
Root:
umount -lf   /mnt/backup
More: http://justwinit.cn/post/6800/
-------------------------------------------------------------------------------------
这个问题是第二次遇到了。这次一定要记下来,免得日后麻烦!!
问题描述:

有两台服务器,其中一台向另一台通过nfs共享分区,如下:

server A: nfs server
server B: nfs Client

事件发生: Server A,B 因故障同时重启。 重启后,用putty登陆到server A ,运行‘df’命令:
$ df

$ Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda5             80632188   8899080  67636940  12% /

none                   4086484         0   4086484   0% /dev/shm

/dev/sda2            201582252  32076524 159265900  17% /opt

/dev/sda3            201582252  44511180 146831244  24% /fs

/dev/sda7             20161172    332916  18804116   2% /usr/local

/dev/sda8             20161172     78360  19058672   1% /tmp

$(没有出现这个命令提示符)

无奈,只好再用putty 登陆Server A ,将 df 进程kill......


只好尝试重新mount

$mount -t nfs B:/data /mnt/data

failed: RPC Error: Program not registered


哦~~~ ,原来B的nfs 服务没有start...  登陆B:
$serive nfs restart

重新再A上运行df,仍然死掉...

想到先卸载,在挂载:

$umount /mnt/data

device is busy 。



运行fuser -mk /mnt/data 杀掉访问/mnt/data所有进程。

/mnt/data: Stale NFS file handle



在server A 运行 A , ok ~~~

重新mount -t nfs B:/data /mnt/data  打完收工。

来自:http://blog.csdn.net/daniel_cao_/article/details/4584443
TPLink_TLWN725N无线网卡支持SoftAP功能,在XP下面配置模拟AP时,开启SoftAP功能,
可能会弹出报错信息“配置ICS失败,你可以连接到SoftAP,但可能无法使用因特网服务”。
解决方法:
1.电脑上打开“服务与应用程序”---“服务”,找到“Windows Firewall/Internet Connection Sharing(ICS)”服务,确保此服务已经开启,如未开启,将此服务手动开启并将启动类型设置为自动。

2.如果电脑上网络连接在开启SoftAP之前就已经手动共享过了,将此共享取消。

3.如果电脑上网络连接在开启SoftAP之前并没有手动共享过,但是仍然提示错误,很有可能是电脑的系统在开启SoftAP功能之前曾经使用过网络连接共享的应用,其状态尚未恢复到初始状态。首先关闭SoftAP功能。接着打开电脑网络连接页面,找到本地连接,查看本地连接状态是否已经共享。
(1)若已经共享,右键“本地连接”选择“属性”---“高级”选项卡,将“Internet连接共享”关闭,点击“确定”。然后将另外一个网络连接的共享开启之后再关闭。重新尝试开启SoftAP功能。
(2)若未共享,随便找一个网络连接,将其共享开启之后再关闭,然后重新尝试开启SoftAP功能。


来自:http://www.360doc.com/content/13/1010/18/2250352_320378101.shtml
分析文章:https://huoding.com/2013/10/06/288
内存不够用时通过它来申请新内存(data segment)


「man brk」来查询一下它的含义:

brk() sets the end of the data segment to the value specified by end_data_segment, when that value is reasonable, the system does have enough memory and the process does not exceed its max data size (see setrlimit(2)).

在Strace中和操作花费时间相关的选项有两个,分别是「-r」和「-T」,它们的差别是「-r」表示相对时间,而「-T」表示绝对时间。简单统计可以用「-r」,但是需要注意的是在多任务背景下,CPU随时可能会被切换出去做别的事情,所以相对时间不一定准确,此时最好使用「-T」,在行尾可以看到操作时间,可以发现确实很慢。 更多:https://blog.huoding.com/2013/10/06/288


shell> strace -T -p $(pgrep -n php-cgi) 2>&1 | grep -B 10 brk
stat("/path/to/script.php", {...}) = 0 <0.000064>
brk(0x1d9a000) = 0x1d9a000 <0.000067>
brk(0x1dda000) = 0x1dda000 <0.001134>
brk(0x1e1a000) = 0x1e1a000 <0.000065>
brk(0x1e5a000) = 0x1e5a000 <0.012396>
brk(0x1e9a000) = 0x1e9a000 <0.000092>

cat bak0.c
#include<stdio.h>
#include <unistd.h>

int main()
{
    int*p1 = sbrk(4);
    int*p2 = sbrk(4);
    int*p3 = sbrk(4);
    printf("pid%d\n",getpid());
    printf("p1:%p\n",p1);
    printf("p2:%p\n",p2);
    printf("p3:%p\n",p3);
     while(1);
}

gcc bak0.c  -o main
#./main
pid2816
p1:0x602000
p2:0x602004
p3:0x602008
ps -ef|grep main
root      2994  2461 94 10:26 pts/3    00:00:07 ./main
此时我们可以看下他的maps文件
cat /proc/2994/maps
00602000-00603000 rw-p 00000000 00:00 0                                  [heap]


2)  内核维护一个指针,假设是p,那么sbrk(0)或得到一个没有被占用的虚拟内存地址,但是此时不分配空间,但是此时只是初始化p,所以你如果对此时得到的内存地址赋值,那么就会出现段错误
cat bak.c
#include<stdio.h>
#include<unistd.h>

int main()
{
         int *p = sbrk(0);
         printf("%p\n",p);
         *p = 111;

}
gcc bak.c -o main

#./main
0x602000
段错误(吐核)


来自:https://blog.csdn.net/xiaoxiaopengbo/article/details/78206953
https://www.cnblogs.com/chengxuyuancc/p/3566710.html
检查是否安装了libxm包

[root@rh-Linux software]# rpm -qa |grep libxml2
libxml2-2.7.6-21.el6_8.1.x86_64
libxml2-devel-2.7.6-21.el6_8.1.x86_64
libxml2-python-2.7.6-21.el6_8.1.x86_64
重新安装libxml2和libxml2-devel包, yum安装的时候发现新版本会提示更新,需要更新的可以更新,不要跳过就行了。

[root@rh-linux /]# yum install libxml2
[root@rh-linux /]# yum install libxml2-devel -y
安装完之后查找xml2-config文件是否存在

[root@rh-linux /] #find / -name "xml2-config"
/usr/bin/xml2-config

From:http://blog.csdn.net/risingsun001/article/details/43705273
PHP版本的实践:https://www.imooc.com/article/10431

背景:在工作中经常会遇到一些关于定时任务的实际场景,比如每天凌晨1点自动备份数据库,或者,每隔1小时执行一次爬虫脚本,这种固定时间执行固定动作的需求我们称之为定时任务,利用crontab即可轻松实现。如果我们对自动备份数据库这个定时任务改变一下需求(这种情况就像你邀请一个人,一天内如果没有人来或有人来你通知下你,你邀请的人来了,这种任务。二、再就是公司没啥好的设备,钱少,网太烂了搞一个任务比如Mysql备份数据库的脚本,比如备份Redis的数据Bgsave的Scp拷贝经常出现网络不好,第一次备份会失败,于是得第二次这种垃圾需求。有垃圾需求就有解决办法,于于优雅或不优雅是一回事,但得技术人员觉得有一个流程总比没有流程好,本来没有方案的,于是就有技术方案。),如图:
点击在新窗口中浏览此图片  
如果仍然利用crontab来实现,就有点勉强了。类似这种需求最常见的是服务器之间的消息通知,假如服务器B由于网络不稳定或者服务器压力较大导致不能即时对服务器A的消息作出正确响应,那么服务器A就会延迟一段时间再次发送消息,直到收到服务器B的正确响应或者超出最大通知次数为止。过去的做法是定时扫表,把通知失败的消息再次发送一遍,虽然可以多次发送通知,但是发送间隔太短会增加服务器B的压力,发送间隔太长消息的时效性就不能保证,显然处理这种延时任务用crontab根本不能解决问题。
Node之Error: Cannot find module 'redis:
#npm install -g redis
/usr/lib
└─┬ redis@2.7.1
  ├── double-ended-queue@2.1.0-0
  ├── redis-commands@1.3.1
  └── redis-parser@2.6.0
环境变量:
#rpm -ql nodejs-6.10.3-1.el7.x86_64
/usr/bin/node
/usr/lib/node_modules
export NODE_PATH=/usr/lib/node_modules
#echo $NODE_PATH  
/usr/lib/node_modules
#node notice.js
订阅成功

select 3
OK
setex msg_2 2 chokingwin
OK
client.on("pmessage", function(pattern, channel, expiredKey) {
    console.log(pattern + "|" + channel + "|" + expiredKey);
_             _keyevent@3__:expired|__keyevent@3__:expired|msg_2




从Redis 2.8.0版本起,加入了"Keyspace notifications"(即"键空间通知")的功能。按照官方的说法:键空间通知,允许Redis客户端从“发布/订阅”通道中建立订阅关系,以便客户端能够在Redis中的数据因某种方式受到影响时收到相应事件。比如:所有改变给定key的命令;所有经过lpush操作的key;所有在0号数据库中过期的key等等。我们在处理延时任务的时候,先把通知失败的消息ID作为key的一部分存到redis缓存中,并设定过期时间(相当于延时),当这条缓存数据失效的时候,通过订阅关系(用NodeJS实现)就可以收到消息,通过分析消息就可以知道过期KEY,这样就可以再次发送消息通知,从而实现延时任务。
不过,需要注意一点:Redis的发布/订阅目前是即发即弃(fire and forget)模式的,因此无法实现事件的可靠通知。也就是说,如果发布/订阅的客户端断链之后又重连,则在客户端断链期间的所有事件都丢失了。
核心部分是两个Redis的终端,分别连接上Redis,并打开这个特性,另一个终端是监控的,这块里面用代码进行编写订阅,如下:
订阅,作者用的是Node,我在这儿不得不打下广告了,Swoole是不是应该也能支持这个功能?https://wiki.swoole.com/wiki/page/523.html ,http://blog.csdn.net/koastal/article/details/52869140,subscribe。
psubscribe来自:https://wiki.swoole.com/wiki/page/590.html

<?php
$serv = new Swoole\Server("127.0.0.1", 9501);
$serv->set(array(
    'worker_num' => 8,   //工作进程数量
    'daemonize' => false, //是否作为守护进程
));
$serv->on('connect', function ($serv, $fd){
    echo "Client:Connect.\n";
});
$serv->on('receive', function ($serv, $fd, $from_id, $data) {
    $val = "";
    $redis = new Swoole\Coroutine\Redis();
    $redis->connect('10.51.77.34', 6379);
    while (true) {
        $val = $redis->psubscribe(['psubscribe __keyevent@3__:expired']);
        //订阅的channel,以第一次调用subscribe时的channel为准,后续的subscribe调用是为了收取Redis Server>的回包
        //如果需要改变订阅的channel,请close掉连接,再调用subscribe
        var_dump($val);
    }                                                                                                    
});
$serv->on('close', function ($serv, $fd) {
    echo "Client: Close.\n";
});
$serv->start();


Swoole的这个Redis的Coroutine必须要有一个端口暴露,这是和Node最大的不同吧?上面这个图我试着使用了一下,感觉有点问题。
=============================================================================

#redis-cli -h 10.51.77.34
10.51.77.34:6379>  psubscribe __keyevent@0__:expired
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "__keyevent@0__:expired"
3) (integer) 1



1) "pmessage"
2) "__keyevent@0__:expired"
3) "__keyevent@0__:expired"
4) "name"



塞一个数据进去:

#redis-cli -h 10.51.77.34
10.51.77.34:6379> config set notify-keyspace-events Ex
OK
10.51.77.34:6379> setex name 10 chokingwin
OK


===================================================================================
关于expired事件通知的发送时间
Redis使用以下两种方式删除过期的键:a:当一个键被访问时,程序会对这个键进行检查,如果键已过期,则删除该键;b:系统会在后台定期扫描并删除那些过期的键。
当过期键被以上两种方式中的任意一种发现并且删除时,才会产生expired事件通知。
Redis不保证生存时间(TTL)变为 0 的键会立即被删除:如果没有命令访问这个键,或者设置生存时间的键非常多的话,那么在键的生存时间变为0,到该键真正被删除,这中间可能会有一段比较显著的时间间隔。
因此,Redis产生expired事件通知的时间,是过期键被删除的时候,而不是键的生存时间变为 0 的时候。
接下来我们开始代码实现(假定阅读本文的同学已正确安装Nginx/PHP/Redis/NodeJS的环境)。

一、与本文相关的环境信息
Redis配置文件路径:/etc/redis/6379.conf
测试用的Redis库编号为:3
监听消息的NodeJS文件:/NodeApp/notice.js
发送消息的PHP代码为:/send.php
接收redis数据的PHP代码:/test.php
业务流程:首先运行notice.js开启监听,然后运行send.php发送消息,如果没有收到成功响应,将消息ID存入redis缓存,之后按照10秒、30秒、60秒、120秒、300秒的时间间隔,再次发送消息通知,直到收到对消息的成功响应,或者超出最大通知次数为止。

二、修改Redis配置文件
因为键空间通知功能需要耗费一定的CPU时间,因此默认情况下,该功能是关闭的。可以通过修改配置文件,或者通过CONFIG SET命令,设置notify-keyspace-events选项,来启用或关闭该功能。
该选项的值为空字符串时,该功能禁用,选项值为非空字符串时,启用该功能,非空字符串由特定的多个字符组成,每个字符表示不同的意义:
K keyspace事件,事件以__keyspace@<db>__为前缀进行发布
E keyevent事件,事件以__keyevent@<db>__为前缀进行发布
g 一般性的,非特定类型的命令,比如del,expire,rename等
$ 字符串特定命令
l 列表特定命令
s 集合特定命令
h 哈希特定命令
z 有序集合特定命令
x 过期事件,当某个键过期并删除时会产生该事件
e 驱逐事件,当某个键因maxmemore策略而被删除时,产生该事件
A g$lshzxe的别名,因此”AKE”意味着所有事件
注意:该选项的值中至少需要包含K或者E,否则不会发布任何事件。比如,如果需要开启针对列表的keyspace事件通知,则该选项需要配置为"Kl"。

我们在服务器上运行vim /etc/redis/6379.conf,找到notify-keyspace-events开头的一行,将其配置为:notify-keyspace-events Ex,含义为:发布keyevent事件,使用过期事件(当每一个key失效时,都会生成该事件)。保存退出,并重启redis服务。如图:
点击在新窗口中浏览此图片

三、安装Node扩展
在网站根目录下,依次运行:
npm init #初始化创建package.json
npm install redis #安装redis扩展
npm install mysql #安装mysql扩展

四、实现send.php

为了便于实现延时的计算,我们将存入redis的key格式设计为:固定前缀+消息ID+时间戳+次数,如:noticeId_12345678_1482991887_2点击在新窗口中浏览此图片
关键代码:
$delayArr=[0,10,30,60,120,300];//延时间隔,相对于首次通知时间,单位为 s
$res=doSomething();//发送消息
$content=date('Y-m-d H:i:s').' 第 '.$nums.' 次发送通知,消息ID为:'.$noticeId."\n";
if($res==true){
$content.='消息发送成功'."\n";
}else{//未收到对方回应
$content.='消息发送失败,等待下次重发'."\n";
$expTime=$delayArr[$nums];
$nums++;
saveNoticeToRedis($noticeId,$stamp,$nums,$expTime);//存入缓存
}
//记录日志
file_put_contents($root.'/tmp.log',$content,FILE_APPEND);

五、实现 notice.js
服务器端运行notice.js后,会一直监听redis的Expired事件,取到ExpiredKey后,把消息ID、时间、通知次数,POST给test.php,从而实现再次发送消息。

关键代码:
var client = redis.createClient('6379', '127.0.0.1');
client.psubscribe("__keyevent@"+redisDB+"__:expired",function(){
//console.log('订阅成功');
});
client.on("pmessage", function(pattern, channel, expiredKey) {
var tmpArr=expiredKey.split('_');
if(tmpArr[0]==keyPrefix){
console.log('-----expired Key-----',expiredKey);
var noticeId=tmpArr[1];
var stamp=parseInt(tmpArr[2]);
var nums=parseInt(tmpArr[3]);
sendPost(noticeId,stamp,nums,logFile);//向test.php发送数据
}else{
console.log('-----error Key-----',expiredKey);
writeLog(logFile,'The key "'+expiredKey+'" is a error key.');
}
});

六、实现 test.php
点击在新窗口中浏览此图片

关键代码:

$delayArr=[0,10,30,60,120,300];//延时间隔,相对于首次通知时间,单位为 s
$res=doSomething();//发送消息
$content=date('Y-m-d H:i:s').' 第 '.$nums.' 次发送通知,消息ID为:'.$noticeId."\n";
if($res==true){
$content.='消息发送成功'."\n";
}else{//未收到对方回应
if($nums && $nums>=6){
$content.='消息ID:'.$noticeId."已达到最大通知次数,任务停止\n";
}else{
$content.='消息发送失败,等待下次重发'."\n";
$expTime=$stamp+$delayArr[$nums]-time();
$nums++;
saveNoticeToRedis($noticeId,$stamp,$nums,$expTime);//存入缓存
}
}
//记录日志
file_put_contents($root.'/tmp.log',$content,FILE_APPEND);

七、测试结果
点击在新窗口中浏览此图片

八、其他说明
本文内容为个人原创,首发今日头条,同时提供代码下载地址,供大家学习交流。本人以后还会发布更多原创干货,如果觉得有用,希望及时关注本头条号。

代码下载地址:http://www.i1981.com/zb_users/upload/2016/12/20161223.zip
DownLoad:
下载文件
点击这里下载文件


From: http://www.toutiao.com/a6369425996433408257/?tt_from=weixin&utm_campaign=client_share&app=news_article&utm_source=weixin&iid=11032449540&utm_medium=toutiao_ios&wxshare_count=1
背景:Node和PHP在IO密集型上的一个探讨,IO密集可能Node要好一点,能更多压榨系统性能。这个链接应该有一定向Node的倾向性,但都看看叫兼听则明嘛。
Q:兄弟用Node搞毛,赶紧竹筒倒豆子,呵呵
A:做接入层啊,替代PHP接入层的角色.异步嘛 PHP同步是短板

Q:哪些函数异步了?函数支持异步才行吧,要是同步函数不也是同步嘛。
A:nodejs本身天然就支持异步的,里面的所以IO操作都是天然就是异步的。

Q:PHP vs NODE:喔,像兄弟们主要用的Mysql和那个Redis啥的接口吧,还有啥?
A:看场景,如果IO多的话,并发性能能高很多:http://taobaofed.org/blog/2015/11/24/nodejs-php-process-manager/

Q:说白了就是把Node当PHP用呗,IO密集有奇效?
A:是的
php安装模块见http://fffo.blog.163.com/blog/static/211913068201401464238334/

1、官网下载
wget http://prdownloads.sourceforge.net/lam/ldap-account-manager-4.3.tar.bz2?download
2、解压
tar -xjf  ldap-account-manager-4.3.tar.bz2
3、直接移动到apache 根目录
mv  ldap-account-manager-4.3 /usr/local/apache/htdocs/lam
4、给它可以访问的权限
chmod 777 -R /usr/local/apache/htdocs/lam
5、进入配置目录
cd /usr/local/apache/htdocs/lam/config
6、创建主参数文件
cp config.cfg_sample config.cfg
7、创建连接ldap服务器参数文件
cp lam.conf_sample lam.conf
vim lam.conf
修改 所有的dc=1v,dc=cn
8、web访问
http://203.195.187.200/lam/templates/login.php

上面的模式是只限管理员登录模式。现在切换到用户登录模式
点击LAM配置——>编辑服务器配置文件——>默认密码是lam(可修改)——>通用设置——>安全设定

From:http://blog.csdn.net/u012461550/article/details/42608781

我的是在:
/usr/local/lam/etc/unix.conf
一、旧版本的PHP(php5.3.27)要装Mysql之后才能装Mysql(mysqli)扩展?编译选项有这个:
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config

传统的安装php的方式中,我们在编译PHP时,一般需要指定以下几项:
--with-mysql=/usr/local/mysql
--with-pdo-mysql=/usr/local/mysql
这实际上就是使用了mysql官方自带的libmysql驱动, 这是比较老的驱动, PHP 5.3开始已经不建议使用它了, 而建议使用mysqlnd.


以上是摘录,更多查看:http://blog.163.com/yxba_02/blog/static/187557620160401018458/


二、PHP7啥的都不用指定Mysql的位置,直接就能编译通过的呀~

PHP7这样的:
--with-mysql=mysqlnd \    
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \

现在系统存在历史问题,没法一时半会升级PHP7了,还在用 php5.3.27上混,编译选项有指定Mysql路径的。
ldd php
发现:
libmysqlclient.so.18 => /usr/lib64/libmysqlclient.so.18 (0x00002b5b5dec7000)
也就是说PHP5.3.7最后还是编译成自己的LIb了,没有Mysql一样能跑,这TM是个问题,装个PHP还得装上Mysql,这个低版本的PHP还得装Mysql服务才行哟。

总之,Mysql和PHP在低版本有了较强的捆绑,而新的PHP7采用Mysqlnd(MySQL Native Driver),摆脱了这一依赖,更简单,更高效。php高版本不再使用mysql_connect()来连接数据库。

背景:一般来讲Linux对明文登录用户的密码在CentOS里有多种,但是MD5长度在36位以下。容量被破解,正向算法、碰撞等,特别是那个万能Wifi钥匙,我去。CentOS5和CentOS6的想法是更安全,但为了兼容统一管理密码Shadow,批量刷一样的,往往会用MD5这种方式,但是被破解后也是很容易给被攻下的一种弱的加密验证方式。
当用户发出useradd命令时,useradd命令读取/ etc / default / useradd和/etc/login.defs并确定useradd的默认值。 要显示/ etc / defaults / useradd的值,请参阅显示useradd的默认值

#使用MD5或DES加密密码? 红帽默认使用MD5。
MD5_CRYPT_ENAB是的

ENCRYPT_METHOD MD5

背景:原来是因为Jenkins的组不对,再把组修正了下,再加上chmod a+s /bin/su ,后来发现是因为/etc/passwd 里面的shell是 :/bin/false导致没法sudo 成功。
su jenkins
id
uid=0(root) gid=0(root) 组=0(root)

试了下Su到其它用户可以,于是查了一下 vi /etc/passwd :
jenkins:x:1012:1010:Jenkins Continuous Integration Server:/data/jenkins:/bin/false
原来是这儿/bin/false,不是su的问题:
jenkins:x:497:601:Jenkins Continuous Integration Server:/data/jenkins:/bin/bash

于是就好了:
[root@iZ2zehnf4lbq2wf83bmzk1Z ~]# su jenkins
[jenkins@iZ2zehnf4lbq2wf83bmzk1Z root]$ id
uid=1012(jenkins) gid=1010(jenkins) 组=1010(jenkins)
==================================================

[root@iZ2zehnf4lbq2wf83bmzk1Z ~]# su jenkins
[root@iZ2zehnf4lbq2wf83bmzk1Z ~]# id
uid=0(root) gid=0(root) 组=0(root)
[root@iZ2zehnf4lbq2wf83bmzk1Z ~]# whoami
root
[root@iZ2zehnf4lbq2wf83bmzk1Z ~]# id jenkins
uid=984(jenkins) gid=990(jenkins) 组=990(jenkins)

========================================
原因1
/bin/su文件没有s位权限


chmod a+s /bin/su


来自:http://blog.itpub.net/26432034/viewspace-1688391/

解决办法
感谢csdn用户jeecg-scott分享的博文《su 切换,提示:“密码不正确”》以下是连接
http://blog.csdn.net/zhangdaiscott/article/details/18666471

step1
检查/etc目录下passwd的权限
[root@dev /]# ll /etc/passwd
-rw-r--r--. 1 root root 1975 5月  27 06:04 /etc/passwd
如果普通用户不能读请改成644权限
[root@dev /]# chmod 644 /etc/passwd

step2
检查/bin/su文件是否有s位权限
[root@dev ~]# ll /bin/su
-rwxrwxrwx. 1 root root 34904 10月 17 2013 /bin/su
如果不存在则添加上
[root@dev /]# chmod a+s /bin/su
[root@dev /]# ll /bin/su
-rwsrwsrwx. 1 root root 34904 10月 17 2013 /bin/su

step3
测试成功否
[oracle@dev ~]$ su - root
密码:
[root@dev ~]#

背景:频繁调用itv投票和调查接口,导致 redis 频繁bgsave ,进而引起大量磁盘io报警,在一些大型的活动,如奥运会、世界杯一些业务会量比较大,在后端肯定是Redis来扛了,而出现了大量的bgsave,导致Redis在刷磁盘时会出现性能陡然下降,触发了Zabbix的报警,鉴于此,得临时性关掉Redis,redis如何关闭持久化?

bgsave的进程在Fork时会生成一样的内存数据,
操作系统认为太多,导致内存不给分派于是出现,fork: Cannot allocate memory :
https://jee-appy.blogspot.com/2016/04/can-not-save-in-background-fork-redis.html?m=1


修改redis配置文件,redis.conf 第115行左右。

1.注释掉原来的持久化规则
#save 900 1
#save 300 10
#save 60 10000

2.设置为空

save ""

然后重启redis服务即可,Bgsave放在备份Redis里,这样就不会因为主Redis挂了导致宕机。

ls  -lart /data/redis6413 |less
-rw-r--r--  1 redis redis 211841024 Jan  9 14:00 temp-33345.rdb
-rw-r--r--  1 redis redis 212078592 Jan  9 15:00 temp-53462.rdb
-rw-r--r--  1 redis redis 220446720 Jan  9 16:00 temp-8399.rdb
-rw-r--r--  1 redis redis 212865024 Jan  9 17:00 temp-28516.rdb

http://blog.csdn.net/opens_tym/article/details/10097805

摘自 :https://blog.csdn.net/tomisaboy/article/details/53763537
背景:听说Lumen起家是以一个叫av的框架,larvael。以Auth2.0起步,Lumen是精简版本,于是想了解一下。发现居然边TM路由就卡住了,Fuck,不光是我老外也有这个问题,都没有解决,主要是一个Nginx的转写问题,这块在Lumen的文档里写的很垃圾,我都不知这些人是怎么写文档的,有用Apache,有Nginx的就不能写细一点么,说一下原理啥的,关键是Nginx配置文件里面的:location /里面的重写。
From:http://blog.csdn.net/wowkk/article/details/52104689

Lumen 5.5.*版本的Lumen,目录:lumen-clear-edition
composer create-project laravel/lumen lumen-clear-edition --prefer-dist  "5.5.*"  # proc_open,

vi ms/survey/bootstrap/app.php
require __DIR__.'/../config/providers.php'

vi ms/survey/config/providers.php
<?php
$app->register(Common\Providers\RedisServiceProvider::class);
$app->register(Common\Providers\MysqlServiceProvider::class);
$app->register(Common\Providers\KafkaServiceProvider::class);
$app->register(Common\Providers\EventServiceProvider::class);
$app->register(Common\Providers\QueueServiceProvider::class);

注册的文件在:
ls ./lumen-clear-edition/common/Providers
EventServiceProvider.php  MysqlServiceProvider.php  RedisServiceProvider.php

启动方法:
启动方法#服务提供者中注册一个视图 composer 则应该在 boot 方法中完成。此方法会在所有其它的服务提供者被注册后才被调用,意味着你能访问已经被框架注册的所有其它服务:https://lumen.laravel-china.org/docs/5.3/providers,ServiceProvider类,和绑定easy_kafka类:
lumen-clear-edition/common/Providers/KafkaServiceProvider.php

vi lumen-clear-edition/common/Service/Kafka/Kafka.php   #自己写这个类的方法。


绑定的easy_kafka在这儿:
lumen-clear-edition/common/Facades/Kafka.php


ms/survey/app/Http/Controllers/Api/V1/ActivityController.php  #路由@./ms/survey/routes/web.php
$router->group(['namespace'=>'Api\V1'], function () use ($router) {
    $router->post('activity/form', ['uses' => 'ActivityController@form']);


ms/survey/app/Helpers/Client/SurveyClient.php  


类的加载,common文件夹位置:
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Common\\": "common/"
        }
    },
#composer dump-autoload --optimize
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Generating optimized autoload files

生成文件在这儿(挪动一下文件放到新目录,建议重新运行一下这个:composer dump-autoload --optimize,再就是如果有PHP的OPcache得重新启动一下PHP-FPM或关闭掉Opcache,/usr/local/php/etc/php.d/opcache.ini ,opcache.enable=0):
./lumen-clear-edition/vendor/composer/autoload_psr4.php:    'Common\\' => array($baseDir . '/common'),
More:


#find ./ -mtime 0 -type f
./composer.json   <== "Common\\": "common/"
./app/Http/Controllers/Api/V1/ActivityController.php
./app/Helpers/Client/SurveyClient.php
./common/Providers/UserServiceProvider.php
./common/Facades/User.php
./common/Services/User/User.php
./config/providers.php


composer dump-autoload --optimize改动的:
./vendor/autoload.php  ==》return ComposerAutoloaderInit7d1969d6b0c0a5e119f2b7e0932178e2::getLoader();
./vendor/composer/autoload_psr4.php
./vendor/composer/autoload_static.php
./vendor/composer/autoload_classmap.php
./vendor/composer/autoload_files.php
./vendor/composer/ClassLoader.php
./vendor/composer/autoload_namespaces.php
./vendor/composer/autoload_real.php

访问URL: http://47.93.207.136/activity/survey
最后,这个Provider的类如何使用参考,但写得不是很明白,最新版本的和实际使用并不定一模一样的:http://www.cnblogs.com/cxscode/p/7569856.html



路由:https://lumen.laravel.com/docs/5.4
中文文档:http://laravelacademy.org/laravel-docs-5_4
5.4这个路由,老外写得很简单,这帮人可能是想你去看他的代码吧,有很多人在问:
http://www.thinksaas.cn/ask/question/22000/
class KafkaServiceProvider extends ServiceProvider{
return new \Common\Service\Kafka\Kafka(); #lumen-clear-edition/common/Service/Kafka/Kafka.php
lumen-clear-edition/common/Service/Kafka/Kafka.php 里:




做微服务:/usr/local/nginx/conf/vhosts/ms.conf

server_name  10.70.**.142;
root /data/www/ms/;
rewrite ^/(survey)/.*$ /$1/public/index.php last;
http://10.70.33.140/survey/public/index.php
/data/www/ms/survey/public/index.php
路由:
/data/www/ms/survey/routes/web.php

一)$app->group(['prefix' => 'private','namespace'=>'Api\V1'], function () use ($app) {
    $app->get('survey/list', ['uses' => 'SurveyController@list']);
http://47.93.207.136/private/survey/list
app/Http/Controllers/Api/V1/SurveyController.php

二)$app->group(['namespace'=>'Api\V1'], function () use ($app) {
    $app->get('activity/survey', ['uses' => 'ActivityController@survey']);
http://47.93.207.136/activity/survey
app/Http/Controllers/Api/V1/ActivityController.php 里有一行:
$client = new SurveyClient();
./app/Helpers/Client/SurveyClient.php:class SurveyClient{

Lumen (5.5.2) (Laravel Components 5.5.*),路由的写法有点不一样:
$router->group(['prefix' => 'private','namespace'=>'Api\V1'], function () use ($router) {
        $router->get('survey/list', ['uses' => 'SurveyController@list']);

$router->group(['namespace'=>'Api\V1'], function () use ($router) {
        $router->get('activity/survey', ['uses' => 'ActivityController@survey']);


调用层级及配置文件的一个情况,二是如何引入框架目录的入口:
./app/Http/Controllers/Api/V1/SurveyController.php:class SurveyController extends Controller{
/**
* 删除互动
*/
public function delete(Request $request){
  $iid = intval($request->input('iid'));
  $res = Survey::deleteSurvey($iid);#调用Models
  return $this->out($res?1:0,$res?"success":"failed");
}

调用Models位置:
./app/Models/Survey.php:        public static function deleteSurvey($iid){

配置文件:
/data/www/ms/survey/config_production/database.php
/data/www/ms/survey/config_production/kafka.php
/data/www/ms/survey/config_production/redis.php

vi /data/htdocs/lumen.levoo.com/bootstrap/app.php   #引入框架目录



======================================================================================
Lumen 中可以使用的 Facades,查看源代码,可用清单如下(https://segmentfault.com/a/1190000002902055):
/survey/bootstrap/app.php:$app->withFacades();  $app->withFacades();
./lumen-clear-edition/vendor/laravel/lumen-framework/src/Application.php:    public function withFacades($aliases = true, $userAliases = [])
./vendor/laravel/lumen-framework/src/Application.php
public function withAliases($userAliases = [])
if (! static::$aliasesRegistered) {
  static::$aliasesRegistered = true;

  $merged = array_merge($defaults, $userAliases);

  foreach ($merged as $original => $alias) {
    class_alias($original, $alias);
  }
}


==========================================================================================
/usr/local/composer/composer.phar  global require "laravel/lumen-installer"
https://lumen.laravel.com/docs/5.4#server-requirements 下面的:
chmod a+x /root/.config/composer/vendor/laravel/lumen-installer/lumen
/root/.config/composer/vendor/bin/lumen new lumen.levoo.com

/data/htdocs/lumen.levoo.com/blog/routes/web.php

你可以将所有路由都定义在routes/web.php中。最基本的 Lumen 路由接收:
http://laravelacademy.org/post/6337.html



$app->group(['prefix'=>'test'],function($app){
    $app->get("/index",["uses" => "TestController@index"]);
                                                                                                                                                                                                              
});


【lumen】基础点记录使用:blog.csdn.net/imdingding/article/details/48679359
app/Http/routes.php中进行路由配置可以使用如下路由组的形式,在路由上lumen和laravel有一些区别
$app->group(['prefix' => 'scrollnews','namespace' => 'App\Http\Controllers'],function($app) {
$app->get('/','NewsController@showall');
$app->get('/{time}_{newpage}.htm','NewsController@showtime');
$app->get('/{newpage}.htm', 'NewsController@show');

});


http://123.57.252.183/test/index
hello Lumen (5.4.5) (Laravel Components 5.4.*)
/data/htdocs/lumen.levoo.com/app/Http/Controllers/TestController.php

<?php

namespace App\Http\Controllers;

use App\user;   //新增部分
use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Http\Request;

class TestController extends BaseController
{
    //直接传人sql方式操作数据库
    function index(Request $request){
        echo "hello Lumen (5.4.5) (Laravel Components 5.4.*)。";die;                                                                                                                                          
        return User::all();
    }
}


以上实践来源及变通参看了:http://blog.5ibc.net/p/87952.html

PHP message: PHP Fatal error:  Uncaught UnexpectedValueException: The stream or file "/data/htdocs/lumen.levoo.com/storage/logs/lumen.log" could not be opened: failed to open stream: Permission denied in /data/htdocs/lumen.levoo.com/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
mkdir
chmod -R 755 /data/htdocs/lumen.levoo.com/storage
chown -R www /data/htdocs/lumen.levoo.com/storage


Controller类的写法:https://segmentfault.com/q/1010000002727820
/data/htdocs/lumen.levoo.com/blog/app/Http/Controllers/AccountController.php



关于数据库配置文件:
默认情况下, Lumen 使用单一的 .env 文件来配置你的应用, 然而, 你也可以使用 Laravel 风格 的配置方法.
/data/htdocs/lumen.levoo.com/vendor/laravel/lumen-framework/config/database.php
文件夹下对应的配置文件复制到根目录下的 config 文件里面就行.
https://lumen.laravel-china.org/docs/5.3/configuration#configuration-files

Redis:
CACHE_DRIVER=file
SESSION_DRIVER=redis
QUEUE_DRIVER=sync

REDIS_HOST=192.168.1.248
REDIS_PASSWORD=null
REDIS_PORT=6379



今天在部署服务器的时候,使用composer来安装依赖。遇到了如下情况,这块出错好像和Redis配置有关,得在.env里配置好并运行起来。
  The Process class relies on proc_open, which is not available on your PHP installation.
  [ErrorException]                                          
  proc_get_status() has been disabled for security reasons
  开始的时候,我有些不知所措,于是冷静下来思考一番,然后goolge了一下
解决方法:
  在php.ini中,找到disable_functions选项,看看后面是否有proc_open函数被禁用了,如果有的话,去掉即可
  其实如果php的文档熟悉的话,你应该马上就能知道proc_open实际上是一个函数,是php用来和shell交互的函数,一般这种可以直接作用于操作系统的函数是非常不安全的,对于这种不安全的函数,总是要做一些措施来进行保护

php artisan make:migration create_table_cars --create=cars
php artisan make:migration create_table_cars --create=cars
Created Migration: 2017_03_04_160644_create_table_cars
/data/htdocs/lumen.levoo.com/database/migrations/2017_03_04_160644_create_table_cars.php

    public function up()
    {
        Schema::create('cars', function (Blueprint $table) {
            $table->increments('id');
            $table->string('make');                                                                                                                                  
            $table->string('model');
            $table->string('year');
            $table->timestamps();
        });
    }



php artisan migrate
Migrated: 2017_03_04_161708_create_table_cars

migrations记录历史 /car 两个表:
id int(10) UNSIGNED
make  varchar(255)
model varchar(255)
year varchar(255)
create d_attimestamp


问题实践来源:http://www.cnblogs.com/crisenchou/p/6237781.html
打开方法来自:http://www.codesec.net/view/497671.html?winzoom=1



Model这块和Controll层的配置:
1)Controll层, /data/htdocs/lumen.levoo.com/app/Http/Controllers/TestController.php

<?php

namespace App\Http\Controllers;
use App\Models\Information;
use App\Models\Collection;

//use App\User;     //新增部分APP目录下
use App\Models\User; //App\Models\User目录下
use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Http\Request;

class TestController extends BaseController
{
    //直接传人sql方式操作数据库
    function index(Request $request){
        /*
            $UserModel = new User();
            $result = $User::all(); //这样也成
            $result2 = $UserModel::all2(); //这样也成
        */
        $result = User::all();
        $result2 = User::all2();//这个在Model自定义的all2也能被调用输出结果

        print_r($result);
        echo "<hr>";                                                                                                                                                                                          
        print_r($result2);
    }
}


2)Model层:/data/htdocs/lumen.levoo.com/app/Models/User.php

<?php
//namespace App; //这个得注释掉,容易和App/User.php发生错误引用。
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
//默认操作数据库的users表,需要定制的话请看文档,下面有自己的配置。
class User extends Model
{
    /**
    * The connection name for the model.
    *
    * @var string
    */
    protected $connection = 'mysql';

    /**
    * 表名
    *
    * @var string
    */
    protected $table = 'levoo_sns_user'; //指定操作表名
    protected $primaryKey = "id";        //指定主键
    public $timestamps = false;
    protected $dateFormat = 'U';

    static public function all2(){
        $User = User::all();
        return $User;                                                                                                                                                                                          
    }
}


=================MVC模板学习=============================
/data/htdocs/lumen.levoo.com/app/Http/Controllers/TestController.php

<?php

namespace App\Http\Controllers;
use App\Models\Information;
use App\Models\Collection;

//use App\User;     //新增部分APP目录下
use App\Models\User; //App\Models\User目录下
use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Http\Request;

class TestController extends BaseController
{
    //直接传人sql方式操作数据库
    function index(Request $request){
        /*
            $UserModel = new User();
            $result = $User::all(); //这样也成
            $result2 = $UserModel::all2(); //这样也成
        */
        $result = User::all();
        //$result2 = User::all2();//这个在Model自定义的all2也能被调用输出结果
        /*
        print_r($result);                                                                                                                                            
        echo "<hr>";
        print_r($result2);
        */
        //view()->exists('user');
        return view('test', ['name' => 'jackX','results' => $result]);
    }
}


vi /data/htdocs/lumen.levoo.com/resources/views/test.blade.php


<!-- 该视图存放 resources/views/greeting.php -->

<html>
    <body>
        <h1>Hello, {{ $name }}</h1>
        <h1>Hello, {{ $name2 or 'Default' }}</h1>
        <h1>Hello, {!! $name !!}</h1>
        <h1>Array, {{ $results}}</h1>
        <h1>Array, {!! $results !!}</h1>
        Blade for each:<br>
        <h1>
            @foreach ($results as $user)
                <ul>
                <li>This is user {{ $user->id }}</li>
                <li>This is user {{ $user->mobile }}</li>
                <li>This is user {{ $user->fansmobile }}</li>
                <li>This is user {{ $user->followedTime }}</li>
                </ul>
            @endforeach
        </h1>
        <h1>
            @foreach ($results as $user)
                <ul>
                @if ($user->id == 1)
                   用户Id=1,标识一下:
                @endif
                <li>This is user {{ $user->id }}</li>
                <li>This is user {{ $user->mobile }}</li>
                <li>This is user {{ $user->fansmobile }}</li>
                <li>This is user {{ $user->followedTime }}</li>
                </ul>
            @endforeach
        </h1>
        <h1>只显示id=1的区块:</h1>
        <h1>
            @foreach ($results as $user)
                <ul>
                 @continue($user->id == 2)
                <li>This is user {{ $user->id }}</li>
                <li>This is user {{ $user->mobile }}</li>
                <li>This is user {{ $user->fansmobile }}</li>
                <li>This is user {{ $user->followedTime }}</li>
                </ul>
                 @break($user->id == 1)
            @endforeach
        </h1>
    </body>
</html>




模板输出:http://123.57.252.183/test/index
Hello, jackX

Hello, Default

Hello, jackX

Array, [{"id":1,"mobile":"1881**65108","fansmobile":"18810322234","followedTime":1211212121},{"id":2,"mobile":"1881**65108","fansmobile":"18810322232","followedTime":121212}]

Array, [{"id":1,"mobile":"1881**65108","fansmobile":"18810322234","followedTime":1211212121},{"id":2,"mobile":"1881**65108","fansmobile":"18810322232","followedTime":121212}]

Blade for each:
This is user 1
This is user 1881**65108
This is user 18810322234
This is user 1211212121
This is user 2
This is user 1881**65108
This is user 18810322232
This is user 121212
用户Id=1,标识一下:
This is user 1
This is user 1881**65108
This is user 18810322234
This is user 1211212121
This is user 2
This is user 1881**65108
This is user 18810322232
This is user 121212
只显示id=1的区块:

This is user 1
This is user 1881**65108
This is user 18810322234
This is user 1211212121

这个叫Blade的模板引擎解析成PHP的,也就是相当于没有啥大的损耗,如果它的算法还算先进的前提下,位置在:
/data/htdocs/lumen.levoo.com/storage/framework/views/9e3b647aebb6a248d1ae42408e87c3fc7f5bc520.php
为什么这么说呢,如下,我在想为何要搞成这样,PHP裸写不也一样么,像Ci框架啥的,思考思考,这样也算是能模板和程序分离罢:


        <h1>只显示id=1的区块:</h1>
        <h1>
            <?php $__currentLoopData = $results; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <ul>
                 <?php if($user->id == 2) continue; ?>
                <li>This is user <?php echo e($user->id); ?></li>
                <li>This is user <?php echo e($user->mobile); ?></li>
                <li>This is user <?php echo e($user->fansmobile); ?></li>
                <li>This is user <?php echo e($user->followedTime); ?></li>
                </ul>
                 <?php if($user->id == 1) break; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </h1>



主要是对这个模板有一个大体理解,和Smarty啥的有一个初步了解,参考自:
http://laravelacademy.org/post/6780.html




======================================================================
Nginx配置文件:

server
{
    listen       80 default_server;
    server_name  101.200.189.210 lumen.levoo.com;
    index index.html index.htm index.php;
    root  /data/htdocs/lumen.levoo.com/blog/public;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;


    location ~ .*\.(php|php5)?$
    {
        fastcgi_pass unix:/dev/shm/php-fcgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        #if (!-f $request_filename){                                                                                                  
        #    rewrite ^/(.+)$ /index.php?s=$1 last;
        #    break;
        #}
    }
    access_log /data/logs/nginx/access_lumen_levoo.log;
}



上面location / {里被注释掉的也成,只是优雅度不够,这块好像手册有说明,我当时把 try_files $uri $uri/ /index.php?$query_string;放到location ~ .*\.(php|php5)?$ 里了,发现不对。

http://123.57.252.183/foo
Hello World


老外:
http://stackoverflow.com/questions/32281294/lumen-simple-route-request-doesnt-work
老外也有这个问题:
http://laravel.io/forum/05-08-2014-nginx-laravel-routing-shows-404?page=1

主从数据库配置(多台读库配置):
http://blog.sina.com.cn/s/blog_9bbafb790102win1.html
基于Lumen搭建一个OAUTH2认证的API框架:
http://www.bibihub.com/php/lumen-mobile-api-oauth-2-authentication/

========DB学习=========
基本使用
注意:如果你想要使用DB门面,应该取消bootstrap/app.php文件中$app->withFacades()调用前的注释
vi bootstrap/app.php

下面这个需要门面:

$app->get('/foo', function () use ($app) {
    $results = app('db')->select("SELECT * FROM levoo_sns_user");
    print_r($results);
    $results = DB::select("SELECT * FROM levoo_sns_user");//这个需要门面
    print_r($results);
    return 'Hello World';                                          
});

一些报错的日志:SQLSTATE[HY000] [2002] Connection refused
grep: ./survey/config_production/config_production: Too many levels of symbolic links
./survey/config_production/app.php:    'lumen_log_path'=>'/data/logs/lumen/survey.log',  //框架日志
grep: ./survey/config/config_production: Too many levels of symbolic links
./survey/config/app.php:    'lumen_log_path'=>'/data/logs/lumen/survey.log',  //框架日志
tail -f survey.log
Next Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `survey` where `type` = 0 and `user` = 271 and `state` = 0) in /data/www/ms/lumen-clear-edition/vendor/illuminate/database/Connection.php:664
/usr/bin/env: PHP: No such file or directory报错
su www

[root@VM-0-15-centos ~]# curl -sS https://getcomposer.org/installer | php

#把composer.phar转移之bin目录以便全局使用
[root@VM-0-15-centos ~]# mv composer.phar /usr/local/bin/composer
#展示版本信息说明成功
[root@VM-0-15-centos ~]# composer -v
如果出现这个提示,是因为composer不建议root账号运行,可以输入y,或者切换账号

Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]?

sudo -u www -H/usr/local/composer/bin/composer config repo.packagist composer https://mirrors.aliyun.com/composer/
[ErrorException]
  touch(): Unable to create file /home/www/.config/composer/config.json because No such file or directory  

#composer clear-cache
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Cache directory does not exist (cache-vcs-dir):
Cache directory does not exist (cache-repo-dir):
Cache directory does not exist (cache-files-dir):
Clearing cache (cache-dir): /root/.cache/composer
如果是其它用户就是在它的家目录下面建立配置文件。

[root@nexus-repo-10-10-0-109:/data/www/l.levoo.com]
#sudo -u www -H /usr/local/composer/composer update
Loading composer repositories with package information

[root@nexus-repo-10-10-0-109:/data/www/l.levoo.com]
#sudo -u www -H /usr/local/composer/composer update
......
Package operations: 41 installs, 14 updates, 38 removals
    Failed to download dragonmantank/cron-expression from dist: The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
    Now trying to download from source

PHP的一些安全函数禁用了,打开就成功了:
  - Upgrading easyswoole/task (1.0.5 => 1.1.2): Extracting archive
  - Upgrading easyswoole/log (1.0.3 => 1.1.1): Extracting archive
Generating autoload files
28 packages you are using are looking for funding.
Use the `composer fund` command to find out more!



然后执行compser up
或者备份composer.lock
==========================================================================

composer config -g repo.packagist composer https://packagist.phpcomposer.com #换国内镜像URL地址。
composer是一个可执行命令,你在一个空目录下写一个composer.json
然后执行composer update,就能生成。
====================两步:软链接composer/PATH/下载autoloader===========================
软链接加PATH:


easy swoole 3.0.9 官方并不是最新的,换换阿里云镜像:
全局替换:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer clear-cache # 此步奏选泽性操作,清除所有 package 缓存。
composer clear-cache
Cache directory does not exist (cache-vcs-dir):
Clearing cache (cache-repo-dir): /data/www/.cache/composer/repo
Clearing cache (cache-files-dir): /data/www/.cache/composer/files
Clearing cache (cache-dir): /data/www/.cache/composer

当前项目替换: (注意:不让root用户运行,用www用户)
cd 项目目录
composer config repo.packagist composer https://mirrors.aliyun.com/composer/


不重新开终端不会生效,则可直接导入变量:
source /etc/profile.d/composer.sh


cd /usr/local/kafka-php
cat composer.json
{
        "require": {
                "nmred/kafka-php": "0.2.*"
        }
}

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing amphp/amp (v1.2.2): Downloading (100%)        
  - Installing psr/log (1.0.2): Downloading (100%)        
  - Installing nmred/kafka-php (v0.2.0.8): Downloading (100%)        
Writing lock file
Generating autoload files

cd /usr/local/kafka-php
composer.json  composer.lock  vendor
目的是看下同事所说的Kafka死光了,kafka-php会退出的问题:
https://github.com/weiboad/kafka-php

===========================================================================

cd /usr/local/composer  ,sudo -u www -H composer.phar install ,会去读取:/usr/local/composer/composer.json文件。
chown -R www.www /data/htdocs/sd.levoo.com #否则会报:/data/htdocs/sd.levoo.com/vendor does not exist and could not be created.
sudo -u www -H composer.phar install

实践如下:


vi /etc/sudoers
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/composer:/usr/local/php/bin


#sudo -u www -H composer.phar config -g repo.packagist composer https://packagist.phpcomposer.com                                                                                                    
  [ErrorException]                                                                                  
  touch(): Unable to create file /home/www/.composer/config.json because No such file or directory  

#mkdir  /home/www
#chown www.www /home/www
#chmod 755 /home/www
#sudo -u www -H composer.phar config -g repo.packagist composer https://packagist.phpcomposer.com


#sudo -u www -H composer.phar install
Composer could not find a composer.json file in /usr/local/composer
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

建立composer.json如下,可以根据需要添加你所依赖的库,但下面一定得包含在内,autoload必须要指定app和test的目录不得省略。

{
  "require": {
    "tmtbe/swooledistributed":">2.0.0"
  },
"autoload": {
    "psr-4": {
      "app\\": "src/app",
      "test\\": "src/test"
    }
  }
}
/usr/local/composer/composer.json
运行:
#sudo -u www -H composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
  [RuntimeException]                                                  
  /usr/local/composer/vendor does not exist and could not be created.

  [RuntimeException]                                                                
  /usr/local/composer/vendor/symfony/intl does not exist and could not be created

  - Installing symfony/intl (v3.3.8):
                                                                                          
  [Symfony\Component\Process\Exception\RuntimeException]                                  
  The Process class relies on proc_open, which is not available on your PHP installation.  
      
PHP需有proc_open,得从PHP的php.ini里给去掉:
; disable_functions = chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_
restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket

#sudo -u www -H composer.phar install
Composer could not find a composer.json file in /usr/local/php/etc
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
得cd到:/usr/local/composer 里,再执行:sudo -u www -H composer.phar install
#sudo -u www -H composer.phar install
  [ErrorException]                                          
  proc_get_status() has been disabled for security reasons   和上面一样:得从PHP的php.ini里给去掉。
  [RuntimeException]                                          
  Could not delete /usr/local/composer/vendor/symfony/intl:
  chown -R www.www  /usr/local/composer/vendor
  [ErrorException]                                                              
  file_put_contents(./composer.lock): failed to open stream: Permission denied   #写入/usr/local/composer/composer.lock权限不够。
[root@gitlab-jenkins_php-redis_123.57.252.183:/usr/local]
#chown www.www composer
#sudo -u www -H composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。


From:https://getcomposer.org/download/
http://blog.csdn.net/yoywow/article/details/52074512

二、使用composer安装laravel/lumen:
遇到问题:
修改 composer 的全局配置文件(推荐方式)

打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:
[root@a composer]# chtdocs
[root@a htdocs]# cd lumen.levoo.com/
[root@a lumen.levoo.com]# /usr/local/composer/composer.phar global require "laravel/lumen-installer"
Changed current directory to /root/.config/composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
compser 执行命令提示do not run composer as root/super !
这个是因为composer为了防止非法脚本在root下执行,解决办法随便切换到非root用户即可
su www
mkdir -p /home/www/.cache
chown -R www:www /home/www/.cache

composer require easyswoole/hot-reload
Cannot create cache directory /home/www/.cache/composer/repo/https---mirrors.aliyun.com-composer/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/www/.cache/composer/files/, or directory is not writable. Proceeding without cache
Using version ^0.1.2 for easyswoole/hot-reload
./composer.json has been updated


PATH变量设置Ok的方法如下:
打开~/.bashrc
sudo vim ~/.bashrc
添加行:
export PATH=$PATH:/home/lumen/.config/composer/vendor/bin


用Linux系统。比如要把/etc/apache/bin目录添加到PATH中,方法有三:
1.#PATH=c/etc/apache/bin
使用这种方法,只对当前会话有效,也就是说每当登出或注销系统以后,PATH 设置就会失效

2.#vi /etc/profile
在适当位置添加 PATH=$PATH:/etc/apache/bin (注意:= 即等号两边不能有任何空格)
这种方法最好,除非你手动强制修改PATH的值,否则将不会被改变

3.#vi ~/.bash_profile
修改PATH行,把/etc/apache/bin添加进去
这种方法是针对用户起作用的
From:http://opsmysql.blog.51cto.com/2238445/665990


lumen没有成功:



useradd lumen
su lumen
cd /data/htdocs/laravel.levoo.com
/usr/local/composer/composer.phar  config -g repo.packagist composer https://packagist.phpcomposer.com


进行上述设置后,laravel有门,能下载了:
[lumen@a laravel.levoo.com]$ pwd
/data/htdocs/laravel.levoo.com
[lumen@a laravel.levoo.com]$ /usr/local/composer/composer.phar global require "laravel/lumen-installer"  
Changed current directory to /home/lumen/.config/composer
Using version ^1.0 for laravel/lumen-installer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 10 installs, 0 updates, 0 removals
  - Installing symfony/process (v3.2.1) Downloading: 100%        
  - Installing psr/log (1.0.2) Downloading: 100%        
  - Installing symfony/debug (v3.2.1) Downloading: 100%        
  - Installing symfony/polyfill-mbstring (v1.3.0) Downloading: 100%        
  - Installing symfony/console (v3.2.1) Downloading: 100%        
  - Installing guzzlehttp/promises (v1.3.1) Downloading: 100%        
  - Installing psr/http-message (1.0.1) Downloading: 100%        
  - Installing guzzlehttp/psr7 (1.3.1) Downloading: 100%        
  - Installing guzzlehttp/guzzle (6.2.2) Downloading: 100%        
  - Installing laravel/lumen-installer (v1.0.2) Downloading: 100%        
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/filesystem ()
Writing lock file
Generating autoload files


生成文件如下:
[lumen@a composer]$ pwd
/home/lumen/.config/composer

[lumen@a composer]$ ls  /home/lumen/.config/composer
auth.json  composer.json  composer.lock  config.json  vendor


开始学习数据库:
http://blog.csdn.net/wowkk/article/details/52104689

/data/htdocs/lumen.levoo.com/blog/.env
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC

DB_CONNECTION=mysql
DB_HOST=10.44.202.177
DB_PORT=3306
DB_DATABASE=levoo_egg
DB_USERNAME=levoo
DB_PASSWORD=new@levoo.com

CACHE_DRIVER=memcached
QUEUE_DRIVER=sync

/data/htdocs/lumen.levoo.com/blog/app/Http/Controllers/AccountController.PHP


/data/htdocs/lumen.levoo.com/blog/routes/web.php
<?php

$app->group(["namespace"=>"App\Http\Controllers"], function()use($app){
    //账户控制器
    $app->get("/AccountController",["uses" => "AccountController@accountController"]);
});


model:/data/htdocs/lumen.levoo.com/blog/app/Models/User.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
class User extends Model
{
}



在app/Http/Controllers目录下AccountController.php,修改为

<?php

namespace App\Http\Controllers;

use App\user;   //新增部分
use Laravel\Lumen\Routing\Controller as BaseController;
use Illuminate\Http\Request;

class AccountController extends BaseController
{
    //直接传人sql方式操作数据库
    function accountController(Request $request){
        return User::all();
    }
}

http://101.200.189.210/AccountController/accountController
一、用户在网站上观看网络视频或者网络教程的时候,有时候用户需要把视频下载到本地计算机中,但是一般的下载网站又不会提供下载按钮给用户,这样用户如果不利用插件就很难完成这样特殊的需求。今天给大家介绍一款可以把任何网站中的视频下载到本机电脑中的Chrome插件:Video download helper。

二、Chrome Cache View软件来下载:
       Chrome Cache View,从名字上也可以看出来,这个软件的功能,比开发人员工具更加方便。免安装,运行后直接可以显示C:\Documents and Settings\用户名\Local Settings\Application Data\Google\Chrome\User Data\Default\Cache中的内容,不过是以原始地址显示的。直接复制出来地址就可下载了。


三、Chrome  的 Video Downloader professional插件,插件图标是向上箭头那个。
分页: 31/272 第一页 上页 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 下页 最后页 [ 显示模式: 摘要 | 列表 ]