Recently i got my vps corrupted and restored it from a snap shot. Unfortunately, the snap shot doesn't contain my previous https certificate and ssl certificate key. So i have to reissue all the stuff. Below is the steps about … Read the rest
作者归档:kotomi
vps 负载过高,博客无法访问
最近晚上要整理整理博客, 发现博客经常无法打开。 查看 vps 进程发现 php5-fpm 进程占用了 CPU 的大部分时间,于是去网上搜了一圈,改了改配置文件,现在 CPU 使用率基本在 20% 以下,各服务都算正常,顺手做一个总结。
- 首先查看
/var/log/php5-fpm.log
文件,判断大概是什么问题。我的日志当时一直报这个 warning:
WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 10 total
c implementation of “mkdir -p”
unix 下的 mkdir 函数只能在一个已经存在的目录下创建一个子目录,而常见的情况是创建一个多级目录,就像 shell 中的 mkdir -p
一样。看过工作中的不少实现,感觉不够简洁和清晰,于是找到了这个实现(链接:sharp2wing),应该可以了。
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#define RWXRR (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH)
int make_path(const char *path, mode_t mode)
{
char
… Read the rest c++: access private members in the copy constructor
considering the following code:
class Test
{
int num;
public:
Test(int x):num(x){}
Test(const Test &rhs):num(rhs.num+1){}
};
int main()
{
Test test(10);
Test copy = test;
}
The num in the copy should be 11, and my question is about inside … Read the rest
git: remove big files in historical commits
最近git push一直提示文件太大,无法push,想到应该是自己之前不小心git add *
把可执行文件什么的也加入跟踪列表了,于是就想把它们从历史commits中删除,步骤总结如下:
-
查看历史提交中有哪些非源代码文件,然后把它们记录下来:
git log --stat
-
删除历史提交中的非源代码文件:
git filter-branch --tree-filter 'rm -f non_code_files' HEAD
-
如果步骤2中漏掉了某些大文件,则可以再执行2中的命令,不过要加一个参数-f:
git filter-branch -f --tree-filter 'rm -f non_code_files_left' HEAD
-
最后把本地提交强制push到远端:
git push -f
OS X iTerm2: 'ls' doesn't show different colors for different file types
As a serious terminal user, i have to use 'ls' command thousands of times.
Coloful output of 'ls' is a must. Thus i installed gnu coreutils, which can provide custom schemes for showing directoies and files.(this is a guide … Read the rest
Install WordPress on debian 7 x64(wheezy)
wordpress安装
对于在自己购买的vps上搭建wordpress博客的用户而言,需要先手动搭建wordpress安装环境,然后按照wordpress官网教程安装wordpress。本文将介绍在vultr的vps上搭建wordpress安装环境的步骤。主要参考了vultr documentation 和 wordpress documentation。
安装环境:debian 7 x64 (wheezy) / vps : vultr
- Install Nginx
root@localhost:~# apt-get install python-software-properties
root@localhost:~# add-apt-repository -y ppa:rtcamp/nginx
root@localhost:~# apt-get update
root@localhost:~# apt-get install nginx
root@localhost:~# service nginx start
-
Test if the