chattr命令好像只适用ext2 ext3,freebsd下是不存在的,freebsd port上也没这个命令
查了一下发现这样可以替代
chattr +i = chflags schg
chattr -i = chflags noschg
It's dangerous to go alone! Take this.
chattr命令好像只适用ext2 ext3,freebsd下是不存在的,freebsd port上也没这个命令
查了一下发现这样可以替代
chattr +i = chflags schg
chattr -i = chflags noschg
每次执行ls -al总是提示“初始化月份字符串出错”,平时使用并不影响,但是看起来让人十分不爽。解决方法如下:
1.编辑 /var/lib/locales/supported.d/local 将文件内容修改如下:
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_CN.GBK GBK
zh_CN GB2312
2.重新生成locale支持文件
sudo locale-gen
3.编辑/etc/default/locale 将文件内容修改如下:
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
现在退出终端重新登陆就不会再报错了。
要解决这个问题很简单,只需要做一点小小的修改。
一、编辑 /etc/pam.d/system-auth 这个文件:
vim /etc/pam.d/system-auth
二、找到下面这一句(或者类似的)
password sufficient /lib/security/pam_unix.so nullok use_authtok shadow
三、将 shadow 改为 md5
四、重启 sshd
service sshd restart
现在 kvm 的 vps 都支持使用 virtio 来优化 vps的磁盘IO 和 网络IO 的性能(估计是类似半虚拟化的东东),之前在kvm上一直使用的是debian,能在安装的时候自动识别加载 virtio 驱动安装 。但 FreeBSD 上不行,在安装时识别不了硬盘和网卡,搜了一google,最新的8和9版本的 FreeBSD 上已经有 virtio 的内核模块了。
1. 首先在KVM安装好一个FreeBSD(VPS面板硬件先不要选择virtio)
2.登录到FreeBSD VPS上,下载 FreeBSD 的源码
cp /usr/share/examples/cvsup/standard-supfile /root
编辑 /root/standard-supfile
找到 default host ,修改为
*default host=cvsup3.FreeBSD.org
然后
csup /root/standard-supfile
等待完成,这样就把FreeBSD的源码下载到/usr/src下面了
3. 更新下vps上的 ports
portsnap fetch update
如果是第一次更新,用
portsnap fetch extract
然后
cd /usr/ports/emulators/virtio-kmod
make install clean
4.在安装 virtio-kmod 成功后,他会让你提示让你修改一些配置文件,如下。
首先我们修改下 /boot/loader.conf ,如果没有存在,就创建下,然后填入下面的内容
virtio_load="YES"
virtio_pci_load="YES"
virtio_blk_load="YES"
if_vtnet_load="YES"
virtio_balloon_load="YES"
接着修改 /etc/fstab 的配置,他里面的ada开头的修改为 vtbd
sed -i.bak -Ee 's|/dev/ada?|/dev/vtbd|' /etc/fstab
最后修改下 /etc/rc.conf 里面关于网络的配置,增加一句 ifconfig_vtnet0_name=”em0″
echo 'ifconfig_vtnet0_name="em0"' >> /etc/rc.conf
5.最后是先关闭FreeBSD VPS ,然后到你的KVM VPS 的管理面板修改 网卡和硬盘为 virtio,如:
之后启动FreeBSD VPS,搞定。
转自:http://loli.asia/archives/7.shtml
我们用到的很多开源程序比如mailman, nagios等等,都有WEB端管理界面。在那个Apache一家独大的年代,这个问题可以很好解决,因为apache本身可以运行cgi程序。但随着nginx服务器的大规模应用,而恰好nginx又没有cgi模块,所以我们不得不采用一些变通的手段来解决它。
在网上广为流传的解决方法是一个老外写的perl脚本,但这个脚本本身有很多问题,而且需要在后台启动一个守护进程,本人对用perl写的网络服务守护进程的稳定性很怀疑,在看了它的代码后,发现用PHP即可很好的解决这个问题。
首先我们要明白的是CGI其实本质上就是一个普通的二进制程序,你可以在后台直接运行它。而服务器要做的事就是将WEB传递的变量作为参数传递给这个程序并执行,而将执行返回的结果显示到页面上。
明白了这个道理,我们就可以开始着手解决这个问题了。其过程无非就是将PHP作为一个proxy,使其运行指定的程序,并把程序输出结果echo出来。
那么首先第一步,我们就需要把原来的cgi请求全部转发到指定的php上,这一点在nginx里用rewrite就可以很简单的做到。我们把这个PHP脚本命名为cgi.php,把它随便放到一个你认为合适的位置,然后用rewrite将后缀为cgi的请求都转发到cgi.php上。以下为参考的配置格式
#rewrite cgi请求到cgi.php上,并把cgi文件名作为php的pathinfo
rewrite ^/nagios/cgi-bin/(.*) /cgi.php/$1 break;
location /nagios/
{
gzip off;
alias /usr/local/nagios/share/;
index index.html index.htm index.php;
}
location ~ .*\.php(\/.*)*$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_param SCRIPT_FILENAME /usr/local/nagios/share$fastcgi_script_name;
#pathinfo必须设置
fastcgi_param PATH_INFO $fastcgi_script_name;
#以下两个为cgi.php需要用到的变量名,分别为cgi程序目录,和cgi默认index程序
fastcgi_param CGI_BASE /usr/local/nagios/sbin;
fastcgi_param CGI_INDEX status.cgi;
}
这是nagios的配置文件。
注意上面配置文件的注释部分,在你自己设置的时候必须填上合适的值。下面就是最重要的cgi.php文件了
0) {
$cgi_path = $cgi_path . '/' . array_shift($cgi_file_levels);
if (is_file($cgi_path)) {
$cgi_file_exists = true;
break;
}
}
if (!$cgi_file_exists) {
die('NOT EXISTS PAGE!' . $cgi_file);
}
$cgi_pathinfo = '';
if (!empty($cgi_file_levels)) {
$cgi_pathinfo = '/' . implode('/', $cgi_file_levels);
}
if (is_readable($cgi_path)) {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
);
$cwd = $cgi_base;
$env = $_ENV;
$env['SCRIPT_FILENAME'] = $cgi_path;
$env['SCRIPT_NAME'] = $cgi_file;
$env['DOCUMENT_ROOT'] = CGI_BASE;
$env['PATH_INFO'] = $cgi_pathinfo;
// http auth support (nagios etc.)
if (isset($_SERVER['PHP_AUTH_USER'])) {
$env['REMOTE_USER'] = $_SERVER['PHP_AUTH_USER'];
}
$process = proc_open($cgi_path, $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
$stdin = file_get_contents("php://input");
if (!empty($stdin)) {
fwrite($pipes[0], $stdin);
fclose($pipes[0]);
}
//stream_set_blocking($pipes[1], 0);
stream_set_timeout($pipes[1], 3);
$result = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($process);
list($header, $body) = preg_split("/\r?\n\r?\n/", $result, 2);
$headers = explode("\n", $header);
foreach ($headers as $line) {
header(trim($line));
}
echo $body;
} else {
die('ERROR APPLICATION!');
}
} else {
die('ERROR PAGE!' . $cgi_path);
}
转自:http://joyqi.com/development/nginx-run-cgi.html
禁止:
if ($http_referer ~* angeeks.com) {
break;
}
跳转:
if ($http_referer ~* angeeks.com) {
rewrite ^/ http://www.fxxkyou.com/;
}
1、修改更新源
sudo vi /etc/apt/sources.list (打开Ubuntu 12.04源列表文件)
2、清空sources.list, 将下面的代码粘贴进去
#台湾源 deb http://tw.archive.ubuntu.com/ubuntu/ precise main universe restricted multiverse deb-src http://tw.archive.ubuntu.com/ubuntu/ precise main universe restricted multiverse deb http://tw.archive.ubuntu.com/ubuntu/ precise-security universe main multiverse restricted deb-src http://tw.archive.ubuntu.com/ubuntu/ precise-security universe main multiverse restricted deb http://tw.archive.ubuntu.com/ubuntu/ precise-updates universe main multiverse restricted deb-src http://tw.archive.ubuntu.com/ubuntu/ precise-updates universe main multiverse restricted #网易 Ubuntu 11.10 源(速度很快) deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted #骨头源,骨头源是bones7456架设的一个Ubuntu源 ,提供ubuntu,deepin deb http://ubuntu.srt.cn/ubuntu/ precise main universe restricted multiverse deb-src http://ubuntu.srt.cn/ubuntu/ precise main universe restricted multiverse deb http://ubuntu.srt.cn/ubuntu/ precise-security universe main multiverse restricted deb-src http://ubuntu.srt.cn/ubuntu/ precise-security universe main multiverse restricted deb http://ubuntu.srt.cn/ubuntu/ precise-updates universe main multiverse restricted deb http://ubuntu.srt.cn/ubuntu/ precise-proposed universe main multiverse restricted deb-src http://ubuntu.srt.cn/ubuntu/ precise-proposed universe main multiverse restricted deb http://ubuntu.srt.cn/ubuntu/ precise-backports universe main multiverse restricted deb-src http://ubuntu.srt.cn/ubuntu/ precise-backports universe main multiverse restricted deb-src http://ubuntu.srt.cn/ubuntu/ precise-updates universe main multiverse restricted #mirror.lupaworld.com的源,速度很快 deb http://mirror.lupaworld.com/ubuntu/archive/ precise main restricted universe multiverse deb http://mirror.lupaworld.com/ubuntu/archive/ precise-security main restricted universe multiverse deb http://mirror.lupaworld.com/ubuntu/archive/ precise-updates main restricted universe multiverse deb http://mirror.lupaworld.com/ubuntu/archive/ precise-backports main restricted universe multiverse deb http://mirror.lupaworld.com/ubuntu/ubuntu-cn/ precise main restricted universe multiverse #ubuntu.cn99.com源(推荐): deb http://ubuntu.cn99.com/ubuntu/ precise main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ precise-updates main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ precise-security main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu/ precise-backports main restricted universe multiverse deb http://ubuntu.cn99.com/ubuntu-cn/ precise main restricted universe multiverse #电子科技大学 deb http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse #中国科技大学 deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse #北京理工大学 deb http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe deb http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe deb http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe deb http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe deb http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe #兰州大学 deb ftp://mirror.lzu.edu.cn/ubuntu/ precise main multiverse restricted universe deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-security main multiverse restricted universe deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe deb ftp://mirror.lzu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe #上海交通大学 deb http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe deb http://ftp.sjtu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe
3、通知ubuntu启用新的更新源
sudo apt-get update
Linux查找文件内容的常用命令方法:
1、从文件内容查找匹配指定字符串的行:
$ grep “被查找的字符串” 文件名
2、从文件内容查找与正则表达式匹配的行:
$ grep –e “正则表达式” 文件名
3、查找时不区分大小写:
$ grep –i “被查找的字符串” 文件名
4、查找匹配的行数:
$ grep -c “被查找的字符串” 文件名
5、从文件内容查找不匹配指定字符串的行:
$ grep –v “被查找的字符串” 文件名
6、从根目录开始查找所有扩展名为.log的文本文件,并找出包含”ERROR”的行
find / -type f -name “*.log” | xargs grep “ERROR”
7、例子 :查找/SqLogs/access.log文件中包含”.exe” 或者”TCP_DENIED”的记录
方法1:grep /SqLogs/access.log –e “.exe”
grep /SqLogs/access.log –e “TCP_DENIED”
方法2:find /SqLogs –type f –name access.log | xargs grep “.exe”
find /SqLogs –type f –name access.log | xargs grep “TCP_DENIED”
1.升级系统
pacman -Syu
2.升级系统,附带升级从aur安装的软件包
yaourt -Syu –aur
注:这条命令的确切意思是升级系统,从AUR升级本地软件数据库并安装更新。
3.安装包
pacman -S package_name pacman -Sf package_name #重新安装软件包
4.只下载你要的包
pacman -Sw package_name
5.安装下载的包到指定目录
pacman -U /path/to/package/package_name-version.pkg.tar.gz
6.删除已安装的软件
pacman -R package_name pacman -Rs package_name #卸载包的同时卸载相关依赖
注:-R和-Rs参数同样适用于yaourt。
7.查找包
pacman -Ss package yaourt foo #会列出所有匹配foo的包,用户可选择安装。
8.查看本地包
pacman -Qi package #显示包信息 pacman -Ql package #显示包安装位置
9.清空cache
pacman -Scc
用pacman 安装的时候,下的包会在/var/cache 这个目录,你会发现这个文件夹很大
yaourt的其他用法:
yaourt -Si package_name #列出软件包信息 yaourt -Sc #从缓存中清楚旧的软件包 yaourt -Su #安装AUR中的更新软件包 yaourt -Sy #获取最新的AUR软件包数据库 yaourt -Cd #清除AUR软件包数据库
1.安装文件包时记得设置DNS。
2.安装完成后首先设置Pacman镜像
nano /etc/pacman.d/mirrorlist
找到CN,去掉Server前面的#,Ctrl+X退出。
3.更新源列表,执行:
pacman -Syu
4.设置签名全部信任(如不设置会十分麻烦)
nano /etc/pacman.conf
在 Architecture = auto 下新增
SigLevel = Optional TrustAll
5.更新系统
pacman -Sy pacman pacman -Su
6.安装yaourt(32位系统)
nano pacman.conf 最后添加:
[archlinuxfr] Server = http://repo.archlinux.fr/i686
然后执行 pacman -Sy yaourt curl