arm交叉编译环境

#交叉编译环境的搭建
1.到buildroot.org去下载构建包
2.解压 make menuconfig 进入配置菜单 如下:

主要介绍:
target Architecture 选择CPU平台 Toolchain 工具链(默认没有勾选C++支持) Package Selection 选择扩展包(供编译使用,多选些编译 软件时就不需要编译第三方包了) 主要在library里面。

1
apt-get install autoconf automake bash bison bzip2 diffutils file flex g++ gawk gcc-multilib gettext gperf groff-base libncurses-dev libexpat1-dev libslang2 libssl-dev libtool libxml-parser-perl make patch perl pkg-config shtool tar texinfo unzip zlib1g zlib1g-dev bc

3.make 开始安装(很久)
4.安装完成: export PATH=$PATH:/opt/cross/host/bin 加入环境变量

5.aria2静态编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
MY_USR_DIR=/opt/cross/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr
CC=arm-linux-gcc \
STRIP=arm-linux-strip \
CXX=arm-linux-g++ \
AR=arm-linux-ar \
RANLIB=arm-linux-ranlib \
KG_CONFIG_PATH=$MY_USR_DIR/lib/pkgconfig \
LD_LIBRARY_PATH=$MY_USR_DIR/lib \
./configure \
ARIA2_STATIC=yes \
--host=arm-uclibc-linux \
LIBSSH2_CFLAGS=-I$MY_USR_DIR/include \
LIBSSH2_LIBS=$MY_USR_DIR/lib/libssh2.la \
SQLITE3_CFLAGS=-I$MY_USR_DIR/include \
SQLITE3_LIBS=$MY_USR_DIR/lib/libsqlite3.la
make

瘦身

1
arm-linux-strip -s src/aria2c

第三方包编译(很多时候需要依赖包都要自己编译):

iconv库安装

1
2
CC=arm-linux-gcc STRIP=arm-linux-strip CXX=arm-linux-g++ AR=arm-linux-ar RANLIB=arm-linux-ranlib ./configure --host=arm-uclibc-linux --prefix=/home/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/
make

汇编常用指令

####通用寄存器

1
2
3
4
5
6
7
8
9
10
11
12
EAX: 累加器
EBX: 基址寄存器
ECX: 计数器
EDX: 数据寄存器
ESI: 源变址寄存器
EDI: 目的变址寄存器
EBP: 扩展基址指针寄存器
ESP: 栈指针寄存器
EIP: 指令指针寄存器
EBP: EBP在栈中运用最广,刚开始没有什么需要特别注意的
ESP: ESP指向栈区域的栈顶位置。栈是一个存放即将会被用到的数据的地方,你可以去搜索一下push/pop 指令了解更多栈知识。
EIP: EIP指向下一个将会被执行的指令。

####标志寄存器

1
2
3
ZF 零标志 若上一个运算结果为0,则其值为1,否则其值为0
OF 溢出标志 当上一步操作改变了某寄存器的最高有效位时,OF寄存器会被设置成1
CF 进位标志

linux-mysql

修改mysql root密码

1
2
3
4
service mysql stop
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 &
mysql mysql -uroot; (或者mysql -uroot; use mysql; )
UPDATE user SET Password=PASSWORD('123456') where USER='root';

风扇减速方法

普通风扇风力过大,噪声太大可以通过此方法DIY

  • 方法一

    1
    2
    3
    在电源线上加个 2uF的电容,可使风扇风力变小
    注意电容容量是 2uf电压和原来的电容电压一样,我的是450V
    这里容量越大,风速越大,容量越小风速越小,只是小于2uf 太小 可能就会出现风扇不转。
  • 方法二

    1
    2
    这个是把原来的电容换小,风速也会变小。
    容量越小风速也是越小。如果比原来的容量更大,风力更大,据说电机发热严重,容易烧(不过这个应该有个阀值,各个电机的阀值应该是不一样)
  • 方法三

    1
    2
    3
    在原来的电容上串联一个电容,也可以减速,这个原理是和方法二是一样的。
    电容串连计算公式:C= (C1*C2)/(C1+C2) 如 1.5*1.5/(1.5+1.5) = 0.75uf 变小了
    并联的公式是: C= C1+C2 这个就变大了。要把转速改快就用并联吧。
提示:方法是在网上找的,我在我的风扇上改过,用了两年没有问题。
本博客主要是我个人记录使用而已。如对浏览者造成什么损失不负责。

nginx 配置

301重定向域名

1
2
3
if($host!='www.xxxx.com'){ #host变量表示主机名
rewrite ^/(.*)$ http://www.xxxx.net/$1 permanent; #permanent表示永久重定向
}

普通地址重定向

把 http://example.com/test.php?para=xxx 重定向到 http://example.com/new

1
rewrite ^/test.php(.*) /new? permanent; #重定向后不带参数

把 http://example.com/test.php?para=xxx 重定向到 http://example.com/new?para=xxx

1
rewrite ^/test.php(.*) /new permanent; #重定向后带参数

把 http://example.com/test.php?para=xxx 重定向到 http://example.com/new

1
rewrite ^/test.php/new?id=$arg_id? permanent; #重定向后带指定的参数

去除index.php

1
2
3
4
5
6
7
8
9
10
#方法1
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.PHP/$1 last;
}
}
#方法2
location / {
try_files $uri $uri/ /index.php$is_args$args;
}

检测配置文件正确性

1
命令:nginx -t

一个虚拟主机的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
server
{
listen 80;
server_name www.xx.com xx.com;
index index.php;
root /www/xx;
#error_page 404 /404.html;
#禁止访问指定的目录下的PHP文件
location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
#重定向
if ($host != 'www.xx.com') {
rewrite ^/(.*)$ http://www.xx.com$1 permanent;
}
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log off;
}

apache

apache2.4以上版本vhost 403问题

1
2
3
4
5
在Vhost 项目中添加
<Directory />
AllowOverride All
Require all granted
</Directory>

主要是这句 Require all granted 2.2版本是不需要的

检测配置文件错误 导致不能启动

1
2
3
4
windows : httpd -t
linux : ./apachectl configtest
正确显示 : Syntax OK
错误显示 : 类似AH00526: Syntax error on line 339 of conf/httpd.conf:

Linux其他

#多网卡配置方法
在VirtualBox生成一个nat(外网网卡) Host-Only(内网网卡)
eth0 外网 配置默认 dhcp模式
eth1 内网 静态ip配置 HWADDR(mac地址)要配置正确
查看 MAC配置 cat /etc/udev/rules.d/70-persistent-net.rules

#eth0配置(外网):

1
2
3
4
5
6
7
DEVICE=eth0
TYPE=Ethernet
HWADDR=08:00:27:68:8e:cd
UUID=112836d5-3ea3-4c7b-9b81-373b4e0b1127
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

#eth1配置(内网):

1
2
3
4
5
6
7
8
9
DEVICE=eth1
TYPE=Ethernet
HWADDR=08:00:27:ad:a0:80
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.56.88
NETMASK=255.255.255.0
#GATWAY 这一定不能填,否则不能上网

#route配置(临时配置,重启网络失效):

1
2
3
4
5
6
7
8
9
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
192.168.56.0 * 255.255.255.0 U 0 0 0 eth1
link-local * 255.255.0.0 U 1002 0 0 eth0
link-local * 255.255.0.0 U 1003 0 0 eth1
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
主要查看 default 的 gateway 值,如果是内网值,就
route del default
route add default gw 10.0.2.2

#/etc/sysconfig/network配置:

1
2
添加外网网关
GATEWAY=10.0.2.2