2016年6月28日 星期二

Web server架設

首先先安裝所需套件:

 #yum -y install httpd

接下來是啟動web server服務:

#systemctl enable httpd.service
#systemctl start httpd.service
#systemctl status httpd.service

開通防火牆:

#firewall-cmd --permanent --add-service=http
#firewall-cmd --reload

再安裝PHP模組:

#yum -y install php-* --skip-broken php-mysql

重新啟動Web server服務:

#systemctl restart httpd.service

在 /etc/httpd/conf.d目錄中自由新增檔案:

#cd /etc/httpd/conf.d

新增vhosts.conf檔案:

#vim vhosts.conf

<VirtualHost _default_:80>
   ServerName www.example.com
   DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:80>
   ServerName test1.example.com
   DocumentRoot /var/www/vhosts/test1
</VirtualHost>

建立虛擬網路目錄:

#mkdir -p /var/www/vhosts/test1

建立虛擬網頁:

#vim /var/www/vhosts/test1/index.html

Hello!! Test1 Web Site !!

新增DNS紀錄:

#vim /var/named/example.zone


$TTL 10
@        IN SOA dns1.example.com. root (
         2016032901;
         1H;
         2D;
         3W;
         10 )
@        IN NS dns1.example.com.
@        IN A 192.168.5.220
@        IN MX 10 mail

dns1.example.com. IN A 192.168.5.220
mail                         IN A 192.168.5.220
ftp                            IN A 192.168.5.220
www                        IN A 192.168.5.220
test1                         IN  A  192.168.5.220     //新增在最後一行

重新啟動DNS服務:

#systemctl restart named

重新啟動Web server服務:

#systemctl restart httpd





2016年6月26日 星期日

Proftpd server

首先先安裝EPEL套件:
#rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

安裝 proftpd 相關套件:
#yum install -y proftpd-*

開啟防火牆:
#firewall-cmd --permanent --add-service=ftp

#firewall-cmd --reload

啟動與執行proftpd:
#systemctl enable proftpd.service

#systemctl start proftpd

取消與關閉proftpd:
#systemctl disable proftpd.service

#systemctl stop proftpd

重新執行proftpd:
#systemctl restart proftpd




之後打開瀏覽器打上ftp://192.168.XXX.XXX ,登入之後就會看到你的站台目錄了

2016年6月16日 星期四

arduino自走車

今天心血來潮來做自走車,今天是做用序列窗控制馬達正反轉及轉速的實驗

程式碼如下:
const int M1_enable = 5;  //定義腳位
const int M2_enable = 6;
const int M1_int1 = 12;
const int M1_int2 = 11;
const int M2_int3 = 10;
const int M2_int4 =  9;
int speed = 0;
void setup() {
Serial.begin(9600);     //將狀態顯示在序列窗上
pinMode(M1_int1, OUTPUT);   //設定pin腳為輸出
pinMode(M1_int2, OUTPUT);
pinMode(M2_int3, OUTPUT);
pinMode(M2_int4, OUTPUT);
Serial. println(" '+':speed up   '-':speed down   'F':forward,  'B':backward,  others:Stop");  //指令設定
}

void loop() {
  int _speed;

if (Serial. available()) {
  char ch = Serial.read();
if (ch=='+') {
  speed ++;
 if (speed>10) speed=10;
 _speed =map(speed, 1, 10, 60,  255);

 Serial.print("speed , _speed=> "); Serial.print(speed); Serial.print(" , ");
 Serial.println(_speed);
 analogWrite(M1_enable, _speed);
 analogWrite(M2_enable, _speed);
} else if (ch== '-'){
  speed--;
 if (speed<=0){
  speed=0;
  _speed=0;
 } else {
 _speed = map(speed, 1, 10,  60, 255);
 }

 Serial.print("speed , _speed=>");
 Serial.print(speed);
 Serial.print( " , ");
 Serial.print(_speed);
 analogWrite(M1_enable, _speed);
 analogWrite(M2_enable, _speed);
 } else if (ch== 'F') {
 
Serial.println("forward");
   digitalWrite(M1_int1, HIGH);  //right正轉
   digitalWrite(M1_int2, LOW);
   digitalWrite(M2_int3, HIGH);  //lift正轉
   digitalWrite(M2_int4,  LOW );
 } else if (ch=='B') {

 Serial.println("backward");
   digitalWrite(M1_int1, LOW);  //right反轉
   digitalWrite(M1_int2, HIGH);
   digitalWrite(M2_int3, LOW);  //lift反轉
   digitalWrite(M2_int4, HIGH);
  }else {
 
 Serial.println("Stop" );
    speed=0;
    analogWrite(M1_enable, speed);
    analogWrite(M2_enable, speed);
  }
}
}




序列窗畫面























載入後執行序列窗就會這樣,當下達  F 的指令就是前進但此時的轉速是0,因此還要在下 轉速從0變為60,在按 會依序增加20直到255極限, B 是倒退, 一樣按 + 增加轉速;相反按  - 是降速
O 是停止的意思

2016年6月6日 星期一

Llinux RAID5(2016/6/7)

Linux RAID製作:
設定目標: mdadm 來建立磁碟陣列

設置環境:CPU:  I7  2600
                 memory:  4G
                OS:  CentOS7

設定流程:

首先先安裝mdadm公用程式
      # yum install mdadm


磁碟分割幾個區塊:
# gdisk  /dev/sda
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

命令 (m 以獲得說明):n   //新增磁區

Select (default e):  p      //主要分割區

Selected partition 4

起初 sector (29698048-42150143, 預設 29698048):      //這邊我直接enter下去
最後 sector, +sectors 或 +大小{K,M,G} (29698048-42150143, 預設 42150143):  //enter

command (m for help): t    //指定磁區格式
Hex code (type L to list codes):fd
# fd =Linux raid autodetect     //按下[I]即可選擇需要的格式

command (m for help):w      //w=寫入分割表
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.     //六顆硬碟都照以上這些步驟做


# mdadm -C /dev/mda0  --level=raid5 --devices=6 /dev/sda1/dev/sdb1/dev/sdc1/dev/sde1

/dev/sdf1/dev/sdg1



製作心得: 一開始我們很努力在找主題來做,但似乎不太順利,一直處於繞圈圈的狀態下,但後來還是來做RAID5 ,情況就有比較好一點,雖然我們中間有很多問題存在,比如說:mdadm的公用程式不能安裝、分割後卻沒有辦法進行下一步驟......   我們就一直找可行的教學,找得很辛苦一直都找不到差點就想放棄,後來終於被我們給找到了,完成之後雖然我們很多不懂的東西,但堅持下去也是做的了事的,所以心態的調整也是成功的條件之一。 (2016/06/15) 








參考文獻資料:
              http://www.tecmint.com/create-raid-5-in-linux/
http://paul.pixnet.net/blog/post/5757945-%5B%E7%AD%86%E8%A8%98%5Dlinux-               %E8%BB%9F%E9%AB%94-raid-5-%E5%AF%A6%E4%BD%9C