分类目录归档:Linux

Ubuntu编译安装PHP 5.5.3+Nginx 1.5.4

因系统Ubuntu12.04,官方源能升级到最新的PHP版本为5.3.10,感觉版本太旧有漏洞,所以决定编译升级到最新的nginx和php。下面是安装笔记。

注:MySQL用的依然是源里的二进制包,编译MySQL耗时太久,所以就放弃了。

1.编译安装Nginx

安装后默认目录在/usr/local/nginx,执行/usr/local/nginx/sbin/nginx 测试是否安装成功。

2.编译安装PHP

默认安装目录在/usr/local/php

3.配置nginx+php

 4.结束

启动php-fpm
/etc/init.d/php-fpm start

启动nginx
/usr/local/nginx/sbin/nginx

最后收尾工作就是权限配置和nginx的站点配置了。

vim映射CTRL+S保存快捷键

禁用掉终端CTRL+S快捷键功能
“CTRL-S:挂起终端(XON)
“CTRL-Q:恢复终端(XOFF)
“要禁止这些键盘映射,在~/.bashrc中加入
stty -ixon
然后修改vim中的按键映射,在 ~/.vimrc中加入

解决gcc4.5编译L2TP一键安装包 openswan出错问题

错误大概是:

In file included from /home/users/z/rpm/BUILD/openswan-2.6.25/programs/addconn/addconn.c:51:0:
/home/users/z/rpm/BUILD/openswan-2.6.25/include/ipsecconf/confread.h:37:19: error: comparison between ‘enum keyword_string_config_field’ and ‘enum keyword_string_conn_field’
/home/users/z/rpm/BUILD/openswan-2.6.25/include/ipsecconf/confread.h:38:19: error: comparison between ‘enum keyword_numeric_config_field’ and ‘enum keyword_numeric_conn_field’
/home/users/z/rpm/BUILD/openswan-2.6.25/include/ipsecconf/confread.h:39:34: error: comparison between ‘enum keyword_string_config_field’ and ‘enum keyword_string_conn_field’
/home/users/z/rpm/BUILD/openswan-2.6.25/include/ipsecconf/confread.h:40:34: error: comparison between ‘enum keyword_numeric_config_field’ and ‘enum keyword_numeric_conn_field’
make3* [addconn.o] Error 1
make3: Leaving directory /home/users/z/rpm/BUILD/openswan-2.6.25/OBJ.linux.i386/programs/addconn'
make2
[programs] Error 1
make2: Leaving directory /home/users/z/rpm/BUILD/openswan-2.6.25/OBJ.linux.i386/programs’
make1
[programs] Error 1
make1: Leaving directory `/home/users/z/rpm/BUILD/openswan-2.6.25/OBJ.linux.i386′
make: *
 [programs] Error 2

 

这是个bug,打上补丁即可解决
https://www.openswan.org/issues/1108

补丁详细信息:

继续阅读

usassh免费SSH代理自动登录脚本

USAssh.com 最早成立于2009年,是一家注重用户体验、高速稳定、诚信专业、老牌资深的美国SSH代理服务提供商,专注于给用户提供优质稳定的SSH代理和VPN代理服务。

2012-7-23 update:更新ruby获取密码脚本!

最近发现usassh提供的有免费测试,美中不足的是每整点更换密码。经过摸索自己写了个脚本实现自动抓取密码并自动重新连接。(如果您觉得服务不错,请购买付费账户,也算支持别人的工作 🙂 )

脚本使用了工具expect,Ubuntu用户可以用sudo apt-get install expect安装。

1.expect脚本内容如下,主要实现自动登录的处理。

继续阅读

关于Ubuntu下apt-get安装包名自动完成

有时候用root登录或者一些Server版的Ubuntu中遇到过apt-get install安装新包时,输入包名前几个字符按TAB建无法自动匹配提示,只需按下面方法解决便可。

  1. 安装bash-completion包。apt-get install bash-completion
  2. 加载环境。source /etc/bash_completion

利用SSH端口转发实现代理加速

关于SSH动态转发变成Socket代理情况这里就不说了。

本文适用于:

假如你有一台国外的SSH主机C(目的大家都懂~ o(∩∩)o…),自己电脑A用SSH做代理访问C网络状况不佳,时不时丢包,或者速度特别慢的时候。

同时需要主机B,与A和C连接速度都很快,一般是国内主机。

  1. SSH登录B,执行:
    ssh -g -D 9001 C用户@C主机IP
    会自动监听9001端口接受下一步发来的数据。
  2. SSH登录A,执行:
    ssh -g -L 9000:localhost:9001 B用户名@B主机IP
    开启本地端口转发,将会在A主机开启9000端口,发往9000端口的数据会经过SSH隧道转发到B机本地的9001端口,同时B机的ssh会再次把数据转发往第一步的C主机。

然后在A本机设置FireFox或者其他应用程序的Socks代理为127.0.0.1:9000即可上网。

OpenVPN几个关键配置

服务端配置文件openvpn.conf

local 你VPS的IP地址
port 1194
proto tcp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem
server 10.8.0.0 255.255.255.0
push “dhcp-option DNS 8.8.8.8″
push “dhcp-option DNS 8.8.4.4″
client-to-client
keepalive 10 120
comp-lzo
persist-key
persist-tun
status /etc/openvpn/keys/openvpn-status.log
verb 4

客户端配置文件*.opvn

client
dev tun
proto tcp
remote 你vps的ip 1194
persist-key
persist-tun
ca ca.crt
cert client01.crt
key client01.key
#这里的两个文件名必须和前面生成的证书文件名一样
ns-cert-type server
comp-lzo
verb 3
redirect-gateway def1

几个重要的转发规则(假设10.8.0.0/24)

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -m state –state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

云端Xen/LinuxVPS 挂载未使用硬盘教程

原文地址:http://blog.aoyohost.com/mount-lvm-formatted-disk.html

[[email protected] ~]# fdisk -l //*查看硬盘分区情况*//

Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM
/dev/xvda3            1045        1305     2096482+  8e  Linux LVM

Disk /dev/xvdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn’t contain a valid partition table
[[email protected] ~]#df -hal //*查看已划分区空间使用情况*//
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
9.3G  1.2G  7.7G  13% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/xvda1             99M   29M   66M  31% /boot
tmpfs                 151M     0  151M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
[[email protected] ~]#fdisk /dev/xvdb //*对硬盘/dev/xvdb进行增加分区操作*//
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):n //*输入n新建分区*//
Command action
e   extended
p   primary partition (1-4)
p //*输入p,主分区*//
Partition number (1-4): 1 //*由于xvdb还没有分区.我们这里输入1.第1个分区*//
First cylinder (1-913, default 1)://*回车跳过*//
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-913, default 913)://*回车跳过*//
Using default value 913

Command (m for help): t //*通过t来指定分区系统格式*//
Selected partition 1
Hex code (type L to list codes):8e //*输入8e LVM系统格式*//
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help):w //*输入w保存退出*//
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]#reboot //*重启使之生效*//

Broadcast message from root (pts/0) (Mon Aug 15 00:43:03 2011):

The system is going down for reboot NOW!
[[email protected] ~]#
Connection closed by foreign host.

Type `help’ to learn how to use Xshell prompt.
Xshell:>

Connecting to            :22…
Connection established.
Escape character is ‘^@]’.

Last login: Mon Aug 15 00:41:06 2011 from
[[email protected] ~]#fdisk -l //*查看硬盘分区情况*//

Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM
/dev/xvda3            1045        1305     2096482+  8e  Linux LVM

Disk /dev/xvdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1         913     7333641   8e  Linux LVM
[[email protected] ~]#pvcreate /dev/xvdb1 //*创建物理卷*//
Physical volume “/dev/xvdb1” successfully created
[[email protected] ~]#vgextend VolGroup00 /dev/xvdb1 //*将物理卷加入到组VolGroup2011*//
Volume group “VolGroup00” successfully extended
[[email protected] ~]# vgdisplay //*查看物理卷组情况.可以看到我们有6.97G的容量可以扩展*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  6
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       315 / 9.84 GB
Free  PE / Size       223 / 6.97 GB
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[[email protected] ~]# lvresize -L +6G /dev/VolGroup00/LogVol00 //*扩容6G(我们第一次加6G)*//
Extending logical volume LogVol00 to 15.59 GB
Logical volume LogVol00 successfully resized
[[email protected] ~]#resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*//
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4087808 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4087808 blocks long.

[[email protected] ~]# vgdisplay //*查看物理卷组情况.可以看到我们还有992M的容量可以扩展*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  7
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       507 / 15.84 GB
Free  PE / Size       31 / 992.00 MB
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[[email protected] ~]# lvresize -L +992M /dev/VolGroup00/LogVol00 //*扩容992M(我们第2次加992M)*//
Extending logical volume LogVol00 to 16.56 GB
Logical volume LogVol00 successfully resized
[[email protected] ~]# resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*//
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4341760 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4341760 blocks long.

[[email protected] ~]#vgdisplay //*最后再查看扩容完没有 可以看到已经扩容完毕*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  8
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       538 / 16.81 GB
Free  PE / Size       0 / 0
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[[email protected] ~]# df -hal //*查看已划分区空间使用情况 可以看到我们挂载成功*//
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G  1.2G   15G   8% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/xvda1             99M   29M   66M  31% /boot
tmpfs                 151M     0  151M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
//*S4 Did For AoyoHost*//