修改 CentOS i386/arm 套件庫來源

因為有更新的需求,所以自行在學校 mirror 一份。
# du -hs /var/ftp/Linux/CentOS
97G     /var/ftp/Linux/CentOS

修改套件庫來源
1. 備份原檔
# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.$(date +%F)[@more@]2. 修改 CentOS-Base.repo
# sed -i ‘s|^baseurl=http://mirror.centos.org/altarch|baseurl=ftp://140.111.74.109/Linux/CentOS/altarch|’ /etc/yum.repos.d/CentOS-Base.repo

3. 清除舊有及更新
# yum clean all;yum update

CentOS 7 arm 版本

在使用 Raspberry Pi / Banana Pi / CubieTurck 這些控制板時,覺得比較困擾的是,它支援的 Linux 大部分都是 Arch Linux / Debian / Ubuntu …等等,個人比較習慣的 CentOS 卻一直沒有釋出相對的版本。終於在 2015 年末 、2016 年初時,盼到了 CentOS 支援的版本。
CentOS 7 arm 版本下載路徑:
http://mirror.centos.org/altarch/7.2.1511/isos/armhfp/

看檔案名稱,似乎有支援的是 BananaPi / CubieTruck / Raspberry Pi 2

更詳細的介紹可以參考下列網站:
Raspberry Pi 的基礎 – 安裝 CentOS 7 for ARM ~ IT 技術家
CentOS 7 AMR版正式發布:支持樹莓派2/香蕉派/CubieTruck - 今日頭條

目前手上還有一塊閒置的 Banana Pi,有空的話再來仔細測試看看!

解決 Debian Apache Web Server 啟動時出現的提示訊息

在 Debian 啟動 Apache Web Server 時會出現下面的提示訊息
# /etc/init.d/apache2 restart
[….] Restarting web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using 2001:288:a2xx:x::xx for ServerName
 … waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 2001:288:a2xx:x::xx for ServerName
. ok

看起來似乎是 Apache Web Server 的設定檔中沒有設定 ServerName

設定的方式:
/etc/apache2/apache2.conf 加入主機名稱的設定
# echo “ServerName xxx.tces.ilc.edu.tw” >> /etc/apache2/apache2.conf

重新啟動時就不會再出現提示訊息了!
# /etc/init.d/apache2 restart
[ ok ] Restarting web server: apache2 … waiting .

Banana Pi – Bananian Linux 更新到 15.04 Debian 8/Jessie

原本系統版本
$ cat /etc/debian_version
7.8

Bananian 15.08 (and later versions) will only be available for Debian 8/Jessie.
Debian 7/Wheezy is still supported and will receive kernel and security updates.

更新的方式:[@more@]
1.) 修改套件庫中的版本設定
$ sudo sed -i ‘s/wheezy/jessie/g’ /etc/apt/sources.list
2.) 更新套件庫來源
$ sudo apt-get update
3.) 更新套件
$ sudo apt-get upgrade
4.) 更新系統
$ sudo apt-get dist-upgrade
5.) 重新啟動電腦
$ sudo shutdown -r now

更新後版本
$ cat /etc/debian_version
8.1

tar.bz2 無法解壓縮

將在別台 Server 備份好的檔案,利用 scp 複製到 Banana Pi 架設的 Server,要解壓縮時,卻發現無法解壓縮。
$ sudo tar xvjf blog_N.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

百思不得其解,本來以為是壓縮檔損毀,可是在原 Server 上可以正常解壓縮。後來上網查了一下,在下面這一篇文章找到了答案。
Can’t extract tar.bz2

發現原來是系統沒有安裝 bzip2 套件
$ sudo apt-get install bzip2

安裝了 bzip2 套件後,就可以正常解壓縮了!

Banana Pi – Bananian Linux 更新到 1504

Bananian Linux 已於 2015-04-08 更新到 1504
Bananian Linux 1504 更新說明:http://forum.lemaker.org/thread-11797-1-1-bananian_15_04_released.html
[@more@]可以直接下載新版本來安裝
Bananian Linux 15.04 下載網址:http://www.lemaker.org/resources/9-116/bananian_for_bananapi.html

1. 執行 bananian-update 來進行更新

2. 輸入 yes 進行更新

3. 更新中

4. 更新完成,執行 shutdown -r now 重新啟動
# shutdown -r now

Banana Pi 測試 – Gentoo Linux IPv6 設定

參考網頁:
gentoo configure ipv6 and ipv4 dual stack |
Gentoo IPv6 Setup

1. 修改網路設定
# vim /etc/conf.d/net
#For Static IP
config_eth0=(
    “192.168.53.98 netmask 255.255.255.0”
    “2001:288:a229:4:d1:2ff:fe42:5c8f/64”
)
routes_eth0=( “default gw 192.168.53.254” )
dns_servers_eth0=( “168.95.1.1 140.111.66.1” )
[@more@]
2. 重新啟動系統
# syunc;sync;sync;sync;shutdown -r now

3. 查看網路設定
# ifconfig eth0 | egrep ‘inet|inet6’
        inet 192.168.53.98  netmask 255.255.255.0  broadcast 192.168.53.255
        inet6 2001:288:a229:4:d1:2ff:fe42:5c8f  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::d1:2ff:fe42:5c8f  prefixlen 64  scopeid 0x20<link>

4. 進行測試
# ping6 -c 4 2001:288:a201::66:96
PING 2001:288:a201::66:96(2001:288:a201::66:96) 56 data bytes
64 bytes from 2001:288:a201::66:96: icmp_seq=1 ttl=125 time=4.52 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=2 ttl=125 time=1.97 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=3 ttl=125 time=9.01 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=4 ttl=125 time=1.81 ms

# ping6 -c 4 www.kame.net
PING www.kame.net(2001:200:dff:fff1:216:3eff:feb1:44d7) 56 data bytes
64 bytes from 2001:200:dff:fff1:216:3eff:feb1:44d7: icmp_seq=1 ttl=49 time=39.9 ms
64 bytes from 2001:200:dff:fff1:216:3eff:feb1:44d7: icmp_seq=2 ttl=49 time=41.7 ms
64 bytes from 2001:200:dff:fff1:216:3eff:feb1:44d7: icmp_seq=3 ttl=49 time=41.3 ms
64 bytes from 2001:200:dff:fff1:216:3eff:feb1:44d7: icmp_seq=4 ttl=49 time=38.8 ms

Banana Pi 測試 – Gentoo Linux 安裝 LAMP Server

參考網頁:
Installing LAMP (Linux, Apache, MySQL, PHP and PhpMyAdmin) in Gentoo Linux
Installing Apache, MySQL, PHP in Gentoo Server | S V N Labs Softwares
LAMP Server on Gentoo – Linode Guides & Tutorials

同步套件庫
# emerge –sync

更新整個系統
# emerge –update world

安裝 Apache Web Server
# emerge apache[@more@]預設網頁根目錄 /var/www/localhost/htdocs/
底下更改成 /var/www/html
# cp /etc/apache2/vhosts.d/default_vhost.include /etc/apache2/vhosts.d/default_vhost.include.$(date +%F)
# sed -i ‘s|/var/www/localhost/htdocs|/var/www/html|’ /etc/apache2/vhosts.d/default_vhost.include
# mv /var/www/localhost/htdocs /var/www/html

cgi 目錄由 /var/www/localhost/cgi-bin 改成 /var/www/cgi-bin
# sed -i ‘s|/var/www/localhost/cgi-bin|/var/www/cgi-bin|’ /etc/apache2/vhosts.d/default_vhost.include
# sed -i ‘s|/var/www/localhost/cgi-bin|/var/www/cgi-bin|’ /etc/apache2/vhosts.d/00_default_ssl_vhost.conf

取消 Indexes 目錄顯示
# sed -i ‘s/Options Indexes/Options -Indexes/’ /etc/apache2/vhosts.d/default_vhost.include

將使用者網頁目錄由 public_html 改成 www
# sed -i ‘s/public_html/www/’ /etc/apache2/modules.d/00_mod_userdir.conf

增加網頁目錄中的 index 設定
# sed -i ‘s/DirectoryIndex index.html index.html.var/DirectoryIndex index.php index.html index.htm index.html.var/’ /etc/apache2/modules.d/00_default_settings.conf

取消 Deny from all 設定
# vim /etc/apache2/modules.d/00_default_settings.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
# Deny from all
</Directory>

ServerSignature On 改成 ServerSignature Off
# sed -i ‘s/ServerSignature On/ServerSignature Off/’ /etc/apache2/modules.d/00_default_settings.conf

啟動 Apache Web Server,如果出現下面的訊息
# /etc/init.d/apache2 start
* Starting apache2 …
apache2: apr_sockaddr_info_get() failed for lemaker
* start-stop-daemon: failed to start `/usr/sbin/apache2′ [ !! ]
* ERROR: apache2 failed to start

請在 /etc/hosts 加入一行
# vim /etc/hosts
127.0.0.1 lemaker

設定開機時啟動 Apache Web Servr
# rc-update add apache2 default

安裝 MySQL Server
# emerge dev-db/mysql

啟動 MySQL Server
# /etc/init.d/mysql start
  * Checking mysqld configuration for mysql …                                                               [ ok ]
 * Starting mysql …
 * You don’t appear to have the mysql database installed yet.
 * Please run `emerge –config =dev-db/mysql-5.5.40` to have this done…
 * ERROR: mysql failed to start

如果出上面的錯誤訊息
# emerge –config =dev-db/mysql-5.5.40

Configuring pkg…

 * Please provide a password for the mysql ‘root’ user now, in the
 * MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file.
 * Avoid [“‘_%] characters in the password
    >(輸入您要設定的 MySQL Server 密碼)
 * Retype the password
    >(再次輸入您要設定的 MySQL Server 密碼)
 * Creating the mysql database and setting proper
 * permissions on it …
 * Command: ‘/usr/share/mysql/scripts/mysql_install_db’ ‘–basedir=/usr’  –loose-skip-grant-tables –loose-skip-host-cache –loose-skip-name-resolve –loose-skip-networking –loose-skip-slave-start –loose-skip-ssl –loose-skip-log-bin –loose-skip-relay-log –loose-skip-slow-query-log –loose-skip-external-locking –loose-skip-log-slave-updates –user=mysql –loose-skip-innodb ‘–datadir=///var/lib/mysql’ ‘–tmpdir=///tmp/’
 * Starting mysqld …
 * Command //usr/sbin/mysqld             –loose-skip-grant-tables –loose-skip-host-cache –loose-skip-name-resolve –loose-skip-networking –loose-skip-slave-start –loose-skip-ssl –loose-skip-log-bin –loose-skip-relay-log –loose-skip-slow-query-log –loose-skip-external-locking –loose-skip-log-slave-updates –user=mysql –loose-skip-innodb             –user=mysql            –log-warnings=0                –basedir=//usr                 –datadir=///var/lib/mysql                 –max_allowed_packet=8M                 –net_buffer_length=16K                 –default-storage-engine=MyISAM            –socket=//var/run/mysqld/mysqld16101.sock              –pid-file=//var/run/mysqld/mysqld20041.pid
 *              –tmpdir=///tmp/                                                                             [ ok ]
 * Setting root password …                                                                                [ ok ]
 * Loading “zoneinfo”, this step may require a few seconds … …                                          [ ok ]
 * Stopping the server …
 * Done

MySQL Server 的一些安全性設定
# /usr/bin/mysql_secure_installation

設定開機時啟動 MySQL Server
# rc-update add mysql default

MySQL Server 設定檔
/etc/mysql/my.cnf

安裝 PHP
# USE=”apache2 mysql mysqli php cli cgi pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode” emerge ‘dev-lang/php’

# vim /etc/conf.d/apache2
APACHE2_OPTS=”-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5″

PHP 設定檔
/etc/php/apache2-php5.5/php.ini

PHP 一些設定
# sed -i ‘s/allow_url_fopen = On/allow_url_fopen = Off/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/expose_php = On/expose_php = Off/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 500M/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/post_max_size = 8M/post_max_size = 500M/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/session.cookie_httponly =/session.cookie_httponly = 1/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/;date.timezone =/date.timezone = Asia/Taipei/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/max_execution_time = 30/max_execution_time = 300/’ /etc/php/apache2-php5.5/php.ini
# sed -i ‘s/max_input_time = 60/max_input_time = 600/’ /etc/php/apache2-php5.5/php.ini

重新啟動 apache Web Server
# /etc/init.d/apache2 restart