2015年8月27日 星期四

RHEL 7_124-08/27

P.166   ( from RHEL 7_124 )


- r w x  r _ x _ _ _
     ↑         ↑       ↑
  user    group  other

◎檔案執行 → 一定要有執行的權限才可執行,不能看副檔名來執行。 (Linux)

※ Windows 要看副檔名才可執行。


   
~# chmod -R g+rwX demodir
※ 權限大小寫,目錄上可執行權限,可以看到目錄內檔案名稱及內容。
Process → 執行緒、排程

Program  --------->   process
            run
底下為還蠻常使用指令:
~$ ps aux

2015年8月23日 星期日

JAVA SL-110_08/23

// InterfaceMember.java

interface Surfacing{
        double pi=3.14159;
        double area();
}

class Shap{
        protected double x, y;
        Shap(double x, double y){
                this.x = x;
                this.y = y;
        }

        public String toString(){
                return "圖形原點:("+ x +", " + y + ")";
        }
}

class Ccircle extends Shap implements Surfacing{
        private double r;
        public Ccircle(double x, double y, double r){
                super(x,y);
                this.r = r;
        }

        public double area(){
                return pi * r * r;
        }

        public String toString(){
                return "圓心:(" + x + "," + y + "),半徑:" + r + ",面積:" + area();
        }
}

public class InterfaceMember{
        public static void main(String args[]){
        Ccircle c = new Ccircle(3, 5, 6);
        System.out.println(c.toString());
        System.out.println("圓周率:" + c.pi);
        System.out.println("圓周率:" + Surfacing.pi);  // interface不需建立實體也能執行
        }
}
/*******************************************************************************************************/

姓名中翻英:http://c2e.ezbox.idv.tw/name.php
Kuan-Ju Huang 

地址中翻英:http://www.post.gov.tw/post/internet/SearchZone/index.jsp?ID=130112
 6F., No.89, Liuzhang St., Sanchong Dist., New Taipei City 241, Taiwan (R.O.C.)

 VUE 辦帳號:http://www.vue.com/oracle/ 
Oracle 辦帳號:https://login.oracle.com/mysso/signon.jsp

 /*******************************************************************************************************/

◎ 抽象類別:

是為了讓方法的使用更多樣化,若父類別是一個抽象類別,
其所產生的抽象方法都必須由子類別來加以實作,
如果沒有全部實作則子類別也要宣告成抽象類別。

◎ abstract class 類別名稱

抽象方法的宣告(不可以是 static)

abstract 傳回值 方法名稱(參數列);

存取權限不可以是 private,沒有抽象建構子和屬性。

◎如何實作抽象類別

利用 extends 關鍵字
子類別透過 override 父類別的方法

/*******************************************************************************************************/
◎ 介面
只能有無實作的方法
void show();

◎ 抽象類別
可以有一般的方法和抽象方法
abstract void  show();
void show(){System.out.println();};

◎ 一般類別
只能有一般方法
void show(){System.out.println();};
/*******************************************************************************************************/

// LineShow.java

abstract class LineDemo {       //宣告抽象類別
        private int length;

        LineDemo(int length){
                this.length = length;
        }

        abstract double area(); //抽象方法

        int getlength(){        //一般方法
                return length;
        }
}

public class LineShow extends LineDemo{
        LineShow(int length){
                super(length);
        }

        public static void main(String args[]){
                LineShow s = new LineShow(10);
                System.out.println("area= "+s.area());

                //因為 length 是 private 權限,要印出必須是透過 getlength()
                System.out.println("length= "+s.getlength());
        }

        public double area(){   //實作 LineDemo 的 area()
                return  Math.pow(getlength(),2);        //Math.pow(n,a) --> n^a
        }
}

/*******************************************************************************************************/
◎ enum 列舉
列舉就十南一種類別,可以單獨撰寫,也可以在類別內當成內部類別。

存取權限 (static) enum 列舉名稱{
A, B, …..}

列舉的內容值都是經過 public, static, final 的修飾。
列舉的內容一經初始給定後就無法更改。

public enum week{…}

/*******************************************************************************************************/

※ 列舉練習,分兩個檔案來寫:Week.java、WeekEnum.java


// Week.java

public enum Week{
        Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}

// WeekEnum.java

public class WeekEnum{
        public static void play(Week week){
                switch(week){
                        case Sunday:
                                System.out.println("Sunday");
                                break;
                        case Monday:
                                System.out.println("Monday");
                                break;
                        case Tuesday:
                                System.out.println("Tuesday");
                                break;
                        case Wednesday:
                                System.out.println("Wednesday");
                                break;
                        case Thursday:
                                System.out.println("Thursday");
                                break;
                        case Friday:
                                System.out.println("Friday");
                                break;
                        case Saturday:
                                System.out.println("Saturday");
                                break;
                        default:
                                System.out.println("DEFAULT");
                }
        }

        public static void main(String args[]){
                play(Week.Sunday);
                play(Week.Monday);
        }
}

/*******************************************************************************************************/

◎取得列舉內容的方式
1.透過-運算子
2.透過-參照
     Week week = new Week();
     System.out.println(week.Sunday);

3.透過 value()
Week[] week2 = Week.values();
for(int i=0; i<week2.length;i++){
System.out.println(week2[i] + “, ”);
// 或
for(Week w:Week Values())
System.out.println(w + “, “);

4.利用 valueOf(String s)來取得
System.out.println(Week.valueOf(“Sunday”));

/*******************************************************************************************************/
// 實作練習 Enum 各取得內容方法
// 需要保留前一練習的檔案 Week.java
// WeekEnum2.java

public class WeekEnum2{
        public static void main(String args[]){
                System.out.println("=========方法2:透過參照=========");
                Week week = Week.Sunday;
                System.out.println(week.Sunday);

                System.out.println("=========方法3-1:透過 value() / for 迴圈=========");
                Week[] week2 = Week.values();
                for(int i=0; i < week2.length; i++)
                        System.out.println(week2[i] + ", ");

                System.out.println("=========方法3-2:透過 value() / for-each=========");
                for(Week w:Week.values())
                        System.out.println(w + ", ");

                System.out.println("=======方法4-1:利用 valueOf(String s)來取得=======");
                System.out.println(Week.valueOf("Sunday"));

                System.out.println("=======方法4-2:利用 valueOf(String s)來取得=======");
                System.out.println(Week.valueOf(Week.class, "Sunday"));
        }
}



/*******************************************************************************************************/

◎內部類別 InnerClass
1. 一般內部類別
2. 方法內部類別
3. 匿名內部類別
4. 靜態內部類別

 MyOuter$MyInner$MyInnerAgain.class
( $ 代表階層概念 )

 class MyOuter{
 class MyInner{ //內部類別
 class MyinnerAgain{ foo(){} // 次內部類別
 }
 }
 class MyInner2{ //內部類別
 … }
 class MyInner3{ //內部類別
 … }
}

/*******************************************************************************************************/


// 練習 InnerClass:MyOuterDemo.java

class MyOuter{
        class MyInner{
                public void foo(){
                        System.out.println("MyInner foo()");
                }
        }
}
public class MyOuterDemo{
        public static void main(String args[]){
                System.out.println("===== 方法一 =====");
                MyOuter t = new MyOuter();
                MyOuter.MyInner t1 = t.new MyInner();
                t1.foo();

                System.out.println("===== 方法二 =====");
                MyOuter.MyInner t3 = new MyOuter().new MyInner();
                t3.foo();

                System.out.println("===== 方法三 =====");
                new MyOuter().new MyInner().foo();
        }
}


// InnerClassDemo.java

class MyOuter{
        private static int sx=9;
        private int x=7;

        class MyInner{
                private int x=77;
                public void foo(){
                        int x=777;
                        System.out.println("Local x =" + x);
//無法印出        //System.out.println("MyInner x=" + MyInner().x);
                        System.out.println("MyInner x =" + this.x);
                        System.out.println("MyOuter x =" + MyOuter.this.x);
//無法印出        //System.out.println("MyOuter x=" + MyOuter.x);
                        System.out.println("MyOuter sx =" + sx);
                        System.out.println("MyOuter sx =" + MyOuter.sx);

                }
        }
}

public class InnerClassDemo{
        public static void main(String args[]){
                new MyOuter().new MyInner().foo();
        }
}


// CboxDemo.java

class Cbox{
        private int height, width, length;
        private Color cr;

        Cbox(int height, int width, int length, String str){
                this.height = height;
                this.width = width;
                this.length = length;
                cr = new Color(str);
        }

        void show(){
                System.out.println("area = " + height*width*length);
                cr.show_color();
        }

        class Color{                    // innerclass
                private String color;

                Color(String color){
                        this.color=color;
                }

                void show_color(){
                        System.out.println("color = " + color);
                }
        }
}

public class CboxDemo{
        public static void main(String args[]){
                Cbox b = new Cbox(3,5,8,"blue");
                Cbox c = new Cbox(8,9,13,"yellow");
                System.out.println("Box b:");
                b.show();
                System.out.println("Box c:");
                c.show();
        }
}


// ShowInner.java

class businessCard{
        private company c;
        private employee e;

        businessCard(String company, String name, String address, String mobile, String email){
                c = new company(company);
                e = new employee(name, address, mobile, email);
        }

        void show(){
                c.show_company();
                e.show_employee();
        }

        void separator(){
                System.out.println("-------------------------------");
        }

        class employee{
                private String name, address, mobile, email;
                employee(String n, String a, String m, String e){
                        name=n;
                        address=a;
                        mobile=m;
                        email=e;
                }
                void show_employee(){
                        System.out.println("| 姓名:"+name+"           |");
                        separator();
                        System.out.println("| 地址:"+address+"         |");
                        separator();
                        System.out.println("| 行動電話:"+mobile+"       |");
                        separator();
                        System.out.println("| E-Mail:"+email+"|");
                        separator();
                }
        }

        class company{
                private String myCompany;
                company(String myCompany){
                        this.myCompany = myCompany;
                }
                void show_company(){
                        System.out.println("      "+myCompany + "公司員工資料");
                        separator();
                }
        }
}

public class ShowInner{
        public static void main(String arga[]){
                new businessCard("STUST", "Aaron Huang", "Taipei,Taiwan","0987-005986", "kaneju0921@gmail.com").show();
        }
}


◎ 方法內部類別:在方法中宣告的類別。
// MethodInnerClass.java

public class MethodInnerClass{
        public static void main(String args[]){
                new MethodInnerClass().see();
        }
        void see(){
                class MyInner{
                        void foo(){
                                System.out.println("MethodInnerClass foo");
                        }
                }
                MyInner mi = new MyInner();   // 注意必須建立 MyInner 實體
                mi.foo();      // 才能印出 foo()
        }
}

2015年8月19日 星期三

0818_RHEL7


本周進度為幫教室灌好20RHCE上課環境,並上Chap 2一點點!


1. 先把空間騰出來( 刪除不要的分割區 ),之後儲存重開機(不要建立NO)
2.  進入BIOS(Delete) 虛擬機&PXE 啟動
3. 進入開機選單( F8 ),選PXE

P.43
這次老師建立的系統預設的密碼 RootAsimov  /  Kioskredhat
灌完後桌面會出現「Manage VMS」可以檢視目前兩台虛擬機狀態

/bin:可執行檔,/sbin放系統可執行檔
/run:會執行or掛載的檔案
/var:紀錄&文件檔
Redhat7有些檔案搬家囉! ( /bin & /sbin & /lib & /lib64 使用連結的方式被移到/usr下面 )


touch:新增or更新檔案時間

ls  -l :列出詳細
    -a :連隱藏檔都出來
    -R:底下每個資料夾的子目錄都出來

cd - :回到之前的目錄( 如果現在在A,下指令到B,下這個參數就會直接跳回A )

rm -r dir1
mkdir -p dir1/dir2/dir3 :新增一貫目錄出來( 都是新的 )
cp -r dir1 dir2 dir3 ( dir1下和dir2下的所有東西都copydir3裡面,dir1dir2這兩個不會copy)
mv dir1 dir2 dir3:搬移資料夾

2015年8月16日 星期日

JAVA SL-110_08/16

// Date:2015/08/16
// test_0816_1.java
// 以父類別變數存取子類別物件成員

class Circle{
        protected double radius;

        Circle(double radius){
                this.radius = radius;
        }

        void show(){
                System.out.println("area = " + radius*radius);
        }
}

class App extends Circle{
        private int value;
        App(double r, int v){
                super(r);
                value =  v;
        }

        void show(){
 // 要使用 super,才能印出 Circle.show()
                super.show();   
                System.out.println("radius = " + radius + ", value = " + value);
        }
}

public class test_0816_1{
        public static void main(String args[]){
                Circle a = new App(0.2,3);
                a.show();       //發生 override,只會印 App.show()
        }
}


// Date:2015/08/16
// Demo.java
// 繼承、多型、轉型練習

class Father{
        String name = "Father";
        String getName(){
                return name;
        }
        String greeting(){
                return "Class Father";
        }
}

class Son extends Father{
        String name = "Son";
        String greeting(){
                return "Class Son";
        }
        void foo(){
                System.out.println(name);                       //Son
                System.out.println(this.name);                  //Son
                System.out.println(super.name);                 //Father
                System.out.println(((Son)this).name);           //Son
                System.out.println(((Father)this).name);        //Father
                System.out.println(((Son)this).greeting());     //Class Son
                System.out.println(((Father)this).greeting());  //Class Son
                System.out.println(super.greeting());           //Class Father
        }
}

public class Demo{
        public static void main(String args[]){
                new Son().foo();
        }
}



首先要先建立 RPG 資料夾,裏面要有(Role.java、Swordman.java、Magician.java、RPG.java)
~$  mkdir RPG
~$  cd RPG/
// Role.java
public class Role{
        protected String name;
        protected int level;
        protected int blood;

        //name
        public void setName(String name){
                this.name = name;
        }
        public String getName(){
                return name;
        }

        //level
        public void setLevel(int level){
                this.level = level;
        }
        public int getLevel(){
                return level;
        }

        //blood
        public void setBlood(int blood){
                this.blood = blood;
        }
        public int getBlood(){
                return blood;
        }

        public String toString(){
                return String.format("(%s, %d, %d)%n", this.name, this.level, this.blood);
        }

        public void fight(){}


}
// Swordman.java
class Swordman extends Role{
        public void fight(){
                System.out.println("揮劍攻擊");
        }
}
//Magician.java
class Magician extends Role{
        public void fight(){
                System.out.println("魔法攻擊");
        }
        public void cure(){
                System.out.println("魔法治療");
        }
}
// Date:2015/08/16
// RJG.java(Role.java, Magician.java, Swordman.java)

public class RPG{
        public static void showBlood(Swordman swordman){
                System.out.printf("%s 血量 %d %n", swordman.getName(), swordman.getBlood());
        }

        public static void showBlood(Magician magician){
                System.out.printf("%s 血量 %d %n", magician.getName(), magician.getBlood());
        }


 public static void main(String args[]){
        Swordman swordMan = new Swordman();
        swordMan.setName("Justin");
        swordMan.setLevel(1);
        swordMan.setBlood(200);
        //System.out.println(swordMan.toString());
        System.out.printf("劍士:(%s %d %d)%n", swordMan.getName(), swordMan.getLevel(), swordMan.getBlood());

        Magician magician = new Magician();
        magician.setName("Monica");
        magician.setLevel(1);
        magician.setBlood(100);
        //System.out.println(magician.toString());
        System.out.printf("魔法師:(%s %d %d)%n", magician.getName(),magician.getLevel(), magician.getBlood());

        showBlood(swordMan);
        showBlood(magician);
 }

}

/*------------------------------------------------------------------------------------------------------*/ 
.is-a     是一個,是一種上下的關係,利用 extends 來實作延伸類別。 
.has-a  有一個,是一種聚合的關係,表示類別的成員變數。

 class machine{

 }
// is-a 電腦類別繼承電子機械產品類別
 class computer extends machine{
                                                  CPU theCpu;
                                                  RAM theRam;
                                                  HD TheHd;
}
/*-----------------------------------------------------------------------------------------------------*/
.interface 
介面 介面也是類別的一種,它是用戶端的程式碼,與類別之間的溝通管道, 利用相同的介面可讓程式有一定的規範可循,介面類別完成後就不允許更改。
 (主要做用為解決 extends 單一繼承問題)

.宣告
 存取權限         interface         介面名稱[]
 存取權限         interface         介面名稱              extends                 //可以讓範圍更大 


      1. 介面的屬性宣告時一定要給定初始值。
      2. compile 值,屬性會自動加上 public static final, 方法會自動加上 public abstract。
      3. 利用 implements 關鍵字來實作 interface。
      4. interface 的方法皆為實作區塊,所以當 implements 時,都一定要將其方法加以實作。 

class 類別名稱 implements 介面名稱
 /*----------------------------------------------------------------------------------------------------*/
.final 修飾字
  1. 類別加上 final 不可以被繼承。
  2. 方法加上 final 不可以被 override。
  3. 屬性加上 final 不可以放更改。

 /*----------------------------------------------------------------------------------------------------*/
// 練習 interface 及 implements

interface Pet{
        String name="cute";
        void move();
        void skill();
}

public class Dog implements Pet{
        // 存取權限一定要大於 interface
        public void move(){
                System.out.println("移動");
        }

        public void skill(){
                System.out.println("跑跳");
        }

        public static void main(String args[]){
                Dog d = new Dog();
                d.skill();
                d.move();
        }
}
 /*----------------------------------------------------------------------------------------------------*/

※練習 implement 及 extends ,建立檔案:
1. Swimmer.java             //interface
2. Flyer.java                    //interface
3. Driver.java                  //interface
4. Fish.java                     //父類別    實作   Swimmer
5. Airplane.java              //父類別    實作   Flyer
6. Boat.java                   //父類別     實作   Swimmer
7. Human.java               //父類別
8. Helicopter.java           //繼承  Airplane
9. SeaPlan.java              //繼承  Airplane 實作 Swimmer
10. Shark.java               //繼承  Fish
11. Anemonefish.java    //繼承  Fish
12. Piranha.java            //繼承  Fish
13. FlyingFish.java        //繼承  Fish 實作 Flyer
14. SwimPlayer.java     //繼承  Human 實作 Swimmer
15. DemoOcean.java   //主程式

首先先建立 Ocean 資料夾,在建立以上檔案。
~$  mkdir Ocean
~$  cd Ocean/
//1. Swimmer.java
interface Swimmer{
      void swim();
}
//2. Flyer.java
interface Flyer{
        void fly();
}
//3. Driver.java
interface Driver extends Swimmer{
     void drive();
}
//4. Fish.java
public class Fish implements Swimmer{
        protected String name;
        public Fish(String name){
                this.name = name;
        }

        public String getName(){
                return name;
        }

        public void swim(){}
}
//5. Airplane.java
public class Airplane implements Flyer{
        protected String name;
        Airplane(String name){
                this.name = name;
        }
        public void fly(){
                System.out.printf("飛機 %s 在飛%n", name);
        }
}
//6. Boat.java
public class Boat implements Swimmer{
        protected String name;
        Boat(String name){
                this.name = name;
        }
        public void swim(){
                System.out.printf("%s 小船在水面航行%n", name);
        }
}
//7. Human.java
public class Human{
        protected String name;
        public Human(String name){
                this.name = name;
        }
        public String getName(){
                return name;
        }
        public void swim(){}
}
//8. Helicopter.java
public class Helicopter extends Airplane{
        Helicopter(String name){
                super(name);
        }

        public void fly(){
                System.out.printf("直升機 %s 在飛%n", name);
        }
}
//9. SeaPlan.java
public class SeaPlan extends Airplane implements Swimmer{
        SeaPlan(String name){
                super(name);
        }

        public void fly(){
                System.out.printf("海上飛機 %s 空中飛行%n", name);
        }

        public void swim(){
                System.out.printf("海上飛機 %s 水面划行%n", name);
        }
}
//10. Shark.java
public class Shark extends Fish{
        Shark(String name){
                super(name);
        }

        public void swim(){
                System.out.printf("鯊魚 %s 游泳 %n", name);
        }
}
//11. Anemonefish.java
public class Anemonefish extends Fish{
        Anemonefish(String name){
                super(name);
        }

        public void swim(){
                System.out.printf("小丑魚 %s 游泳 %n", name);
        }
}
//12. Piranha.java
public class Piranha extends Fish{
        Piranha(String name){
                super(name);
        }

        public void swim(){
                System.out.printf("食人魚 %s 游泳 %n", name);
        }
}
//13. FlyingFish.java
public class FlyingFish extends Fish implements Flyer{
        FlyingFish(String name){
                super(name);
        }

        public void swim(){
                System.out.printf("飛魚 %s 游泳%n", name);
        }
        public void fly(){
                System.out.printf("飛魚 %s 會飛%n",name);
        }
}
//14. SwimPlayer.java
public class SwimPlayer extends Human implements Swimmer{
        SwimPlayer(String name){
                super(name);
        }

        public void swim(){
                System.out.printf("潛水夫 %s 在游泳%n", name);
        }
}
//15. DemoOcean.java  //主程式
public class DemoOcean{
        public static void doSwim(Swimmer swimmer){
                swimmer.swim();
        }

        public static void doFly(Flyer flyer){
                flyer.fly();
        }

        public static void doDriver(Driver driver){
                driver.drive();
        }

        public static void main(String args[]){
        SeaPlan s = new SeaPlan("S");
        FlyingFish f = new FlyingFish("f");
       
        //Swimmer
        doSwim(new Anemonefish("anemonefish"));
        doSwim(new Shark("shark"));
        doSwim(new Piranha("piranha"));
        doSwim(new SwimPlayer("swimmer"));
        doSwim(s);
        doSwim(f);

        //Flyer
        doFly(new Helicopter("helicopter"));
        doFly(s);
        doFly(f);

        }
}
練習 interface method()
// 練習 interface method()
// Service.java

interface Other{
        void execute();
        void doOther();
}

interface Some{
        void execute();
        void doSome();
}

public class Service implements Some,Other{

        public void execute(){
                System.out.println("execute");
        }

        public void doSome(){
                System.out.println("doSome");
        }

        public void doOther(){
                System.out.println("doOther");
        }

        public static void main(String args[]){
                Service d = new Service();
                d.execute();
                d.doSome();
                d.doOther();
        }
}

2015年8月15日 星期六

0813_RHEL7


Linux > Command-line  > shell, bash, zsh...
   > Graphic
    X-Window  > KDE, GNOME...
   WM

Termal
預設圖形介面  Ctrl + Alt + F1
其它切換  Ctrl + Alt + [ F2 ~ F6 ]

.權限標示:
一般使用者 $
管理者  #
標示參數 $PS1

.指令形式:
<command> <options> <arguments>
       指令 參數(調整)        目標

額外補充 Linux Hack Web Kali Linux

.今日提到指令:
ls
date
man
exit
su
clear
echo
yelp
file
head
tail
wc -l  列出多少行數
 -w  列出多少英文單字
 -c  列出多少字元
useradd --[Tab][Tab] 查看可使用的參數
history

.鍵盤操作
super
super + M
Ctrl + Alt + Up/Down


Terminal 鍵盤操作
Ctrl + K 清除遊標後文字列
Ctrl + L 同指令 clear
Ctrl + C 中斷指令
Ctrl + U 清除指令列,可用 Ctrl + C 取代
Ctrl + D 同指令 exit
Ctrl + A 同鍵盤 Home,移至行首
ESC + . 插入上一次指令的 argument

2015年8月9日 星期日

0806_RHEL7

輸入法
應用程式 --> 系統工具 --> 設定值 --> 地區和語言 --> 按+來新增語言(內建的新酷音很好用Chewing)
我們常用的都是Ibus系列
用指令打可以試試看yum install ibus-table*


虛擬機架虛擬機
ISO檔案下載:
 http://ftp.stu.edu.tw/Linux/CentOS/7/isos/x86_64/CentOS-7-x86_64-NetInstall-1503.iso

系統 --> 虛擬機器管理員




phpMyAdmin

文字界面
系統 --> 軟體 -->  搜尋MariaDB --> 裝五個 -->
mariadb(A community)
mariadb-bench(MariaDB benchmark)
mariadb-devel(Files for development)
mariadb-server(The MariaDB)
mariadb-test(The test)

systemctl enable mariadb.service
systemctl start mariadb.service
mysql -u root -p 就進入進入界面了(第一次不用key 密碼)
exit跳出

***如果剛開始就無法進入登入畫面,請參考以下網址,
http://www.phpini.com/linux/redhat-centos-7-setup-apache-mariadb-php

確定底下東西都有安裝到!
yum install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-snmp php-soap curl curl-devel
***

圖形界面
系統 --> 軟體 -->  搜尋php --> 裝六個 -->
php-cli-5.4(Command-line..)
php-common-5.4(Command-file..)
php-gd-5.4(A module..)
php-mcrypt-5.4(Standard PHP..)
php-mysql-5.4(A module..)
php-pdo-5.4(A database..)
裝完之後


系統 --> 軟體 -->  搜尋httpd --> 裝兩個
httpd-2.4.6(Apache HTTP Server)
httpd-tools(Tools for use...)

systemctl restart httpd.service

Google搜尋  phpMyAdmin,下載tar.gz那個
https://www.phpmyadmin.net/downloads/phpMyAdmin-4.4.12-all-languages.tar.gz

把剛剛載的phpMyAdmin-4.4.12-all-languages.tar.gz 剪下到 /var/www/html 下
並解壓縮到html下
再改名資料夾成 phpMyAdmin
最後至firefox中打上 localhost/phpMyAdmin ( firefox打的名字 和 資料夾名子要一樣 )
就可以看到東西,但會有錯誤訊息,請再做底下步驟

yum install php-mbstring

找不到套件再網路搜尋
Google搜尋 php mbstring centos 7 rpm
http://rpm.pbone.net/index.php3/stat/4/idpl/26646085/dir/centos_7/com/php-mbstring-5.4.16-21.el7.x86_64.rpm.html

三個都可以載
之後再以軟體安裝

systemctl restart httpd


操作底下步驟即可打上網址不需要密碼
之後改名 /var/www/html/phpMyAdmin/config.sample.inc.php 成 config.inc.php
並且編輯如下
blowfish.....=' 隨便打幾個數字 '
AllowNoPa = false改成 true

進去之後就把三個任意使用者全部殺掉
並把剩下的四個更改密碼


drupal
Google搜尋 drupal taiwan 正體 ( http://drupaltaiwan.org/ )
右邊的 Drupal 7.36 & Drupal 中文化 分別點進去兩個東西
7.38(.tar.gz) & 7.38 (.po)

1. .tar.gz檔
貼到  /var/www/html 下,並解開,把裡面的drupa-7.38裡面東西全部剪到上層的html下,再把drupa-7.38空資料夾刪掉

2. .po
放到  /var/www/html/profile/standard/translation裡

之後firefox中打上 localhost就出現了

restorecon -R /var/www/html
再重新整理firefox,save and continue....

1. yum install php-theseer-fDOMDOCM....
(yum research dom)

2.  /var/www/html/sites/default 下新增個 files資料夾
chown apache.apache files

3.  改名/var/www/html/sites/default/default.settings.php 成 settings.php
chown apache.apache settings.php
restorecon -R /var/www/html
systemctl restart apache


之後重新整理firefox
drupal --> 編碼選utf8_general_ci來建立
左邊新增使用者,選本機,資料庫drupal,最上面出現一堆字後才算成功,再全選,執行
email可以打test@gmail.com

以上需要下載的檔案,老師的ftp都有ftp://192.168.10.102/pub/

2015年8月8日 星期六

0804_RHEL7


延續上週:
.做 createrepo
掛載 RHEL DVD
copy DVD 內容至 /var/ftp/pub/
cd /run/media/$USER/RHEL-7.0/Packages
安裝 vsftp createrepo
createrepo -g /var/ftp/pub/repodata/76[Tab] /var/ftp/pub/

 .設定 repo 檔,以自建的 vsftp.service
cd /etc/yum.repos.d/
vi test.repo
 [RHEL7]
 name=rhel
 baseurl=ftp://localhost/pub
 enabled=1
 gpgcheck=0

 .重啟 vsftp 並設定 SELinux Firewall
systemctl enable vsftpd.service
restorecon -R /var/ftp/pub
firewall-cmd --permanent --add-service=ftp
systemctl restart vsftpd.service

 .檢查 ftp repo
打開「應用程式」>「軟體」,可以看到多項套件。
打開 firefox url: ftp://localhost ,可以看到 /var/ftp/pub 內容。

 .安裝套件:應用程式 > 軟體 >
system-config-firewall base components and command line tool
A graphic interface for administering users and groups
A graphic interface for modifying the system language

 .裝 EPEL repo
Google: EPEL (https://fedoraproject.org/wiki/EPEL)
下載  The newest version of 'epel-release' for EL7
安裝 rpm -ivh epel-release..rpm



.測試 EPEL,以 freerdp 遠端連線程式為例:
測試 yum search freerdp
測試 yum install freerdp
xfreerdp -g 800x600 -u $USER $IP

 .查看網路設定:
ip address show
ip route show
ifconfig

 .修改 ip 為手動:
可以使用圖型介面直接改
使用半圖型介面 nmtui-edit

 .重新啟動網路:
 systemctl restart NetworkManager

 .檔案系統格式,對單一檔案容量限制:
FAT16 <= 2G
FAT32 <= 4G
NTFS <= 16T
EXT4  <= 16T
XFS  超大…






...
安裝遠端程式 xrdp

Google:xrdp install on rhel7 (http://www.itzgeek.com/how-tos/linux/centos-how-tos/install-xrdp-on-centos-7-rhel-7.html )
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
yum -y install xrdp tigervnc-server
systemctl start xrdp.service
netstat -antup | grep xrdp
systemctl enable xrdp.service
firewall-cmd --permanent --zone=public --add-port=3389/tcp
firewall-cmd --reload

2015年8月2日 星期日

JAVA SL-110_08/02

#  Override 覆寫:

在繼承關係中,子類別自行實作,一個方法來取代父類別的程式執行時,
會執行子類別的而不會執行父類別。

 1. override 是發生在 extends 關係中。
 2. override 方法的名稱必須相同。
 3. 若方法有回傳值,其型態必須是原方法的型態或其型態的子類別。
 4. 參數列不管是(型態、數量、順序)皆需相同。
 5. 在取權限不可小於原方法。

// Override 覆寫練習1,印出:

/*

兒子的事業:電腦網路

市值: $100

父親的事業:房地產

市值: $80000000

*/
  
class Father{

        public int money = 80000000;

        public void undertaking(){

                System.out.println("父親的事業:房地產");

        }

}



class Son extends Father{

        public int money;

        Son (int money){

                this.money = money;

        }

        public void undertaking(){

                System.out.println("兒子的事業:電腦網路");

        }

        public void go(){

                undertaking();

                System.out.println("市值: $" + money);

                super.undertaking();

                System.out.println("市值: $" + super.money);

        }

}

public class Extends_0802_1{

        public static void main(String args[]){

        new Son(100).go();

        }

}
  


//-------------------------------------------------------------------------------------------------------
// Override 覆寫練習2,印出:
/*
call Father
call Son
*/
class Father{
        void aMethod(){
        System.out.println("call Father");
        }
}

class Son extends Father{
        public Son(){
                super.aMethod();
        }
        public void aMethod(){
                System.out.println("call Son");
        }

}
public class Extends_0802_2{
        public static void main(String args[]){
        Son s = new Son();
        s.aMethod();
        }
}
//-------------------------------------------------------------------------------------------------------
// IOException 練習

import java.io.*;

class Father{
        void aMethod()throws IOException{
        }
}

public class Son_0802_3 extends Father{
        public static void main(String args[]){
        Son_0802_3 s = new Son_0802_3();
                try{
                        s.aMethod();
                }catch(IOException e){
                        System.out.println("s.aMethod() not found.");
                }
        }
        void aMethod()throws IOException{
                System.out.println("call Son");
        }
}
//-------------------------------------------------------------------------------------------------------
// 寫成一個 .bat 執行檔

// IoDemo.java
public class IoDemo{
        public static void main(String args[]){
        System.out.println("----------");
        System.out.println("|     程式設計     |");
        System.out.println("|  Java程式設計組  |");
        System.out.println("|                  |");
        System.out.println("|                  |");
        System.out.println("| 主持人:聯成電腦 |");
        System.out.println("|    聯 成 電 腦   |");
        System.out.println("----------");
        }
}

// IoDemo.bat
SET PATH=%PATH%
javac -encoding utf-8 IoDemo.java
java IoDemo
pause
//-------------------------------------------------------------------------------------------------------
// Overloading 超載
// 同一種方法可以產生不同的實作,
// 例如:同一個方法名稱依傳入的參數不同,而實作出相異的程式碼

method
void aMethod(){}
void aMethod(int a){}
void aMethod(String s, int a){}
void aMethod(int a, String s){}
//-------------------------------------------------------------------------------------------------------
// 練習 Override and Overloading
class Animal{
        void aMethod(){}
}


class Dog extends Animal{
                String aMethod(String a){return a;} //overloading
                void aMethod(int a){} //overloading
                void aMethod(){} //override
/*方法 overloading 除了在參數列不一樣下,其回傳型態也可以不一樣
}
public class Dog_1{
        public static void main(String args[]){
        Dog d = new Dog();
        d.aMethod("String");
        d.aMethod(10);
        d.aMethod();
        }
}


//-------------------------------------------------------------------------------------------------------
// vararg 建構變長參數
// 語法
// 存取權限 傳回值 方法名稱(型態…變數名稱)

public void aMethod(int...c){}
//-------------------------------------------------------------------------------------------------------
// 例題,輸出: 13

public class AddInt{
 public static void main(String args[]){
        AddInt ai = new AddInt();
        int a = ai.newCalc(1,2);
        int b = ai.newCalc(1,2,3,4);
        int c = ai.newCalc(a,b);
        System.out.println(c);
 }
 public int newCalc(int...c){ // c 會類似陣列,故可以用 for-each 印出
        int sum = 0;
        for(int i:c){
                sum += i;
        }
        return sum;
 }
}
//-------------------------------------------------------------------------------------------------------
// 例題,輸出:int 版本被呼叫
// java 機制,遇到整數優先找 int ,故 integer 不會印出來。
// 若要印出 integer,只能將 int 註解掉。

class Some{
        void someMethod(int i){
                System.out.println("int 版本被呼叫");
        }
        void someMethod(Integer integer){ // Integer 為物件化
                System.out.println("Integer 版本被呼叫");
        }
}
public class overloadBoxing{
        public static void main(String args[]){
                Some s = new Some();
                s.someMethod(1);
        }
}
//-------------------------------------------------------------------------------------------------------
//※ 封裝
/*
物件狀態的隱藏過程,也就是透過統一的方法或介面實作,
來取得類別中那些不被外部直接存取的內部資料,
以維護物件資源的完整性與安全性。
*/
// get
// set
// 建構子
//-------------------------------------------------------------------------------------------------------
// 例題: get, set

public class EncDemo{
        public static void main(String args[]){
        MyAccount account = new MyAccount();
        account.setMoney(1000000);
        System.out.println("$" + account.getMoney());
        }
}

class MyAccount{
        private int money;
        public void setMoney(int money){
                this.money = money;
                // this.money 是指 MyAccount 的 money
                // money 是指 setMoney(int money) 的 money
        }
        public int getMoney(){
                return money;
        }
}
//-------------------------------------------------------------------------------------------------------
// 封裝流程練習
// 練習分兩個 .java 寫:CashCard.java、CardApp.java
// 點數卡儲值且每大於一仟就給紅利 1 點。

// CashCard.java
class CashCard{
        private String number;
        private int balance;
        private int bonus;
        CashCard(String number, int balance, int bonus){
                this.number = number;
                this.balance = balance;
                this.bonus = bonus;
        }
        void store(int money){
                if(money > 0){
                        this.balance += money;
                        if(money >= 1000){
                                this.bonus+=(money/1000);
                        }
                }
                else
                        System.out.println("儲值是負的,來亂的嗎");
        }
        String getNumber(){
                return number;
        }
        int getBalance(){
                return balance;
        }
        int getBonus(){
                return bonus;
        }
}
//----------------------------------
// CardApp.java
import java.util.*;
public class CardApp{
        public static void main(String args[]){
                CashCard[] cards = {
                        new CashCard("A001", 500, 0),
                        new CashCard("A002", 300, 0),
                        new CashCard("A003", 1000, 1)};

                Scanner scanner = new Scanner(System.in);

                for(CashCard card:cards){
                        System.out.printf("為(%s, %d, %d)儲值:",card.getNumber(), card.getBalance(), card.getBonus());
                        card.store(scanner.nextInt());
                        System.out.printf("明細(%s, %d, %d)%n", card.getNumber(), card.getBalance(), card.getBonus());
                        System.out.println("------------------------------");
                }
        }
}
//-------------------------------------------------------------------------------------------------------
// ※多型
/*
開發出可擴充的程式,在程式撰寫上更有彈性,也就是說泛指在繼承關係下,單一實體卻可以有多種型別。
*/

父類別 = 子類別實體

Animal a = new Cat();
//-------------------------------------------------------------------------------------------------------



// 練習上方架構設計:
class Animal{
        void move(){
                System.out.println("移動");
        }
}

class Cat extends Animal{
        void skill(){
                System.out.println("抓老鼠");
        }
        void move(){
                System.out.println("跑跳");
        }
}

class Tiger extends Cat{
        void skill(){
                System.out.println("獅王");
        }
}

public class Demo_0802_1{
        public static void main(String args[]){
                Animal a = new  Cat();
                //a.skill();
                ((Cat)a).skill();
                a.move();

                Cat c = new Tiger();
                c.skill();
                c.move();

                Animal a1 = new Tiger();
                //a1.skill();
                ((Tiger)a1).skill();
                a1.move();
}
}