安装前置条件
 1.下载win32diskimager-v0.7-binary.zip
 2.下载debian_wheezy_armhf_v1_mele.zip
 3.下载cubie_nand_uboot_partition_image.zip
 4.下载FlashFXP.zip
 5.下载PanasonicSDFormatter.zip
 6.下载puttyfile_0.62cn.zip
以上文件下载地址:http://pan.baidu.com/s/1i3Ke8gH  提取码:pi9m
将系统安装到Nand
1将TF卡装入读卡器,插入电脑USB接口.
 2.解压win32diskimager,debian_wheezy_armhf_v1_mele到当前目录,执行Win32DiskImager.exe.
 3.选择debian_wheezy_armhf_v1_mele.img,盘符选择你读卡器的盘符,点击Write,等待写入完成.
 4.取出TF卡,插入cubieboard的TF卡插口,通电开机。
 5.等cubieboard启动后,进入路由器查看DHCP客户端列表,记录下主机mele的IP地址,即为cubieboard的ip地址.
 6.解压FlashFXP.zip和cubie_nand_uboot_partition_image.zip,打开FlashFXP,使用快速连接,类型选择SFTP(无SSH),输入cubieboard的ip,账号密码均为root,
 7.登录后上传cubie_nand_uboot_partition_image.bin到root目录.
 8.解压puttyfile_0.62cn.zip,执行目录内的putty.exe,在界面的主机名处输入上一步骤记录的IP地址,端口保持不变,点击打开.期间会弹出警告,选择'是'即可.
 9.以账号root,密码root登录系统。
 10.执行 
 dd bs=4096 if=cubie_nand_uboot_partition_image.bin of=/dev/nand #更新板载MBR
 等待至少三十秒,执行
 rm cubie_nand_uboot_partition_image.bin #删除文件
 reboot #重启cubieboard
 11.等重启完成后使用putty登录,依次执行以下命令
 mkfs.ext4 /dev/nandb #格式化板载存储
 mount /dev/nandb /mnt #挂载
 mkdir /tmp/boot #新建临时目录
 mount /dev/mmcblk0p1 /tmp/boot #将sd卡的第一个分区挂载到刚才的临时目录
 mkdir /mnt/boot #在板载存储里面新建boot目录
 cp /tmp/boot/uImage /mnt/boot/uImage #将sd卡第一分区里的启动镜像到板载里面的boot目录
 touch cplst.txt #新建一个txt文件
 nano cplst.txt #编辑里面内容如下:
/dev/*
 /proc/*
 /sys/*
 /media/*
 /mnt/*
 /run/*
 /tmp/*
输入完成后按ctrl+x,然后输入y,回车保存.
 12.然后执行
 rsync -avc --exclude-from=cplst.txt / /mnt #同步TF卡系统到NAND
 等待上述命令执行完成后,输入shutdown -h now关闭电源,取出TF卡,重新启动,此时cubieboard已经脱离TF卡运行了。
 执行
 rm cplst.txt #删除文件
系统的初步设置
 1.固定MAC地址
 nano /etc/network/interfaces
 在配置文件末尾新加入一行,内容如下
 hwaddress ether AA:BB:CC:CB:EB:00
2.修改主机名
 nano /etc/hostname
3.修改当前用户密码
 passwd
4.用Panasonic SDFormatter格式化存储卡,否则插入存储卡cubieboard不能启动.注意选项'格式化大小调整'选'开启'.
5.设置自动挂载TF卡
 插入TF卡,执行
 cat /proc/partitions #查看当前所有分区
最后一个便是TF卡
 执行 nano /etc/fstab
 在行尾添加,如下内容
 /dev/mmcblk0p1 /mnt vfat defaults,umask=000 1 2
 保存,重启系统后,用"df -h"命令查看是否挂载成功
6.安装nginx,php,mysql
 依次执行
 
apt-get update
 apt-get install nginx
 apt-get install php5-fpm
 apt-get install php5-cli
 apt-get install php5-curl
 apt-get install php5-gd
 apt-get install php5-mcrypt
 apt-get install php5-mysql
 apt-get install php5-cgi
 apt-get install mysql-server
安装Mysql的过程中会提示输入密码,请记住你所输入的密码,Mysql中的root密码即是你所输入的。待所有安装完成,下面我们开始逐一配置相关程序。
 首先创建网页目录
 执行 
 mkdir /mnt/wwwroot #创建目录
 touch /mnt/wwwroot/index.php #创建php探针文件
 nano /mnt/wwwroot/index.php #为php探针写入内容
写入以下内容
<?php
 phpinfo();
 ?>
先配置Nginx 请按照以下内容对照修改
 nano /etc/nginx/nginx.conf #修改nginx.conf
 worker_processes 1;
 worker_connections 128;
取消以下代码前的#,使之生效。
 
gzip on;
 gzip_disable "msie6";
 gzip_vary on;
 gzip_proxied any;
 gzip_comp_level 6;
 gzip_buffers 16 8k;
 gzip_http_version 1.1;
 gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
nano /etc/nginx/sites-available/default #修改default
server {
 listen 80;
 #listen [::]:80 default_server;
 root /mnt/wwwroot; #此处请修改为你所需的网站路径 本条注释请勿添加
 index index.html index.php;
 # Make site accessible from http://localhost/
 #server_name localhost;
 if (!-e $request_filename)
 {
 rewrite ^(.*)$ /index.php$1 last;
 }
 location / {
 try_files $uri $uri/ /index.html;
 }
 location /doc/ {
 alias /usr/share/doc/;
 autoindex on;
 allow 127.0.0.1;
 allow ::1;
 deny all;
 }
 location ~ .*\.php(\/.*)*$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 include fastcgi_params;
 }
 }
接下来是对Mysql数据库软件针对CB硬件环境所进行的优化操作
 nano /etc/mysql/my.cnf
 [mysqld]
 key_buffer = 64k
 max_allowed_packet = 1M
 thread_stack = 64K
 thread_cache_size = 4
#以下两条并未出现在默认的配置文件中,需要额外添加进去。
 default-storage-engine = MyISAM
 loose-skip-innodb
 skip-innodb
 innodb=OFF
然后对PHP进行优化处理,依旧寻找相应代码后进行修改。
 nano /etc/php5/fpm/php.ini
 memory_limit=16M
nano /etc/php5/fpm/php-fpm.conf
 process.max=4
至此,所有的安装优化工作进行完毕,我们可以逐一进行对Nginx、Php、Mysql三项所属服务进行重启验证配置文件是否更改正确.
 service nginx reload #重启Nginx
 service php5-fpm reload #重启Php5
 service mysql reload #重启Mysql
然后reboot进行一次重启,通过浏览器访问cubieboard的IP地址,查看是否配置正确。
7.安装samba服务(方便上传以及更改网页)
 执行
 apt-get install samba #安装samba服务组件
 nano /etc/samba/smb.conf #编辑配置文件,可清空原有配置,复制修改以下配置。
[global]
 workgroup = WORKGROUP
 netbios name = Cubieboard
 server string = Cubieboard
 security = share
 guest ok = yes
 guest account = root
 [root]
 path = /mnt
 writeable = yes
/etc/init.d/samba restart #重启samba服务
 8.如果网站提示无写入权限,执行
 chmod 777 /mnt/wwwroot
 其他设置
 1.更改ssh默认端口
 nano /etc/ssh/sshd_config
 将端口22更改为你想设置的端口,然后reboot
 2.设置时区
 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 3.更新时间
 ntpdate cn.pool.ntp.org 
 4.设置自动更新时间
 执行
 apt-get install cron
 nano /etc/crontab
 在末尾添加上
 */60 * * * * root ntpdate cn.pool.ntp.org
    









