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
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