買錯的電影票,含著淚也得看-LAMP搭建&Linux基礎,電影票-lamp
hi
沒說過,上周五室友過生請客,在龍湖裡吃嗨了喝爽了,回去的路上侃侃而談。說好的這周一起去看年內最後的大片,火星救援的,誰知道老子眼神不好,買錯了電影的時間。。。把周六的約定提前到了今兒個下午,madan,送都送不出去,只有敲班去看了
1、LAMP
-----搭建LAMP環境(二)-----
----給PHP添加常用拓展
gd以及curl,命令去網上找好了,這個太長了
liang@liang-andy:~$ sudo apt-get install php5-gd curl libcurl3-dev php5-curl
時間也有點長
驗證的話,要先重啟apache2服務,然後去上次說的那個探針檔案中看,也就是看看phpinfo中有米有
----filezilla
ssh工具,管理伺服器檔案
-----LAMP環境配置最佳化(一)-----
----LAMP環境檔案概述
常識
/etc--Ubuntu系統設定檔目錄,一般通過apt-get命令安裝的軟體的設定檔都在這裡
LAMP也在這裡
/etc/apache2
/etc/mysql
/etc/php5
----環境檔案詳解
---
先開啟apache2檔案清單
liang@liang-andy:~$ cd /etc/apache2
liang@liang-andy:/etc/apache2$ ll
總用量 96
drwxr-xr-x 8 root root 4096 11月 23 19:08 ./
drwxr-xr-x 134 root root 12288 11月 25 12:37 ../
-rw-r--r-- 1 root root 7115 1月 7 2014 apache2.conf
drwxr-xr-x 2 root root 4096 11月 23 19:08 conf-available/
drwxr-xr-x 2 root root 4096 11月 23 19:08 conf-enabled/
-rw-r--r-- 1 root root 1782 1月 3 2014 envvars
-rw-r--r-- 1 root root 31063 1月 3 2014 magic
drwxr-xr-x 2 root root 12288 11月 23 19:21 mods-available/
drwxr-xr-x 2 root root 4096 11月 23 19:21 mods-enabled/
-rw-r--r-- 1 root root 320 1月 7 2014 ports.conf
drwxr-xr-x 2 root root 4096 11月 23 19:08 sites-available/
drwxr-xr-x 2 root root 4096 11月 23 19:08 sites-enabled/
apache2中有apache.conf,算是設定檔的總入口,可以include很多其他的設定檔——配置起來更靈活,而且總檔案不是很大
核心配置:mods-*** apache模組;sites-*** 虛擬機器主機
***可以用avaliable(可用的)和enabled(已啟用的)(具體看上面的命令最後那一列)
enabled與avaliable之間用ln -s命令進行軟串連。等於說,模組本身就像是燈,然後命令是開關
---
mysql和php
核心分別是my.cnf以及php.ini
以後詳述
2、Linux基礎
環境為虛擬機器VM中的centOS6以及ssh工具xshell5
快速鍵,ctrl+l
-----Linux常用命令(一)-----
我們需要掌握的大概6、70個,以後一共用到的可能會有200個
[root@andy ~]#
使用者@主機名稱 ~當前所在位置(檔案夾)#超級使用者提示符 $普通使用者提示符
注意,linux中的使用者不是admin;預設的主機名稱是localhost;~表示/root,簡稱家
[root@andy ~]# cd /root 地址是不變的
普通使用者的家目錄是二級地址
----命令格式
命令 [選項] [參數]
注意,個別命令不遵守這樣的格式;多個選項可以寫在一起,比如-au;有簡化選項和完整選項,比如-a和-all
---ls:查詢目錄中檔案
ls [] [檔案和目錄]
-a all 顯示所有檔案,包括隱藏檔案
-l long 顯示詳細資料,也稱為長格式
-d direct 目錄屬性
-h human 顯示人能看懂的大小
-i innode
[root@andy ~]# ls -al
總用量 80
dr-xr-x---. 2 root root 4096 11月 25 05:06 .
dr-xr-xr-x. 24 root root 4096 11月 26 03:41 ..
-rw-------. 1 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-------. 1 root root 183 11月 25 05:06 .bash_history
-rw-r--r--. 1 root root 18 5月 20 2009 .bash_logout
-rw-r--r--. 1 root root 176 5月 20 2009 .bash_profile
-rw-r--r--. 1 root root 176 9月 23 2004 .bashrc
-rw-r--r--. 1 root root 100 9月 23 2004 .cshrc
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
-rw-r--r--. 1 root root 129 12月 4 2004 .tcshrc
-rw-------. 1 root root 768 11月 25 04:20 .viminfo
--ll命令,就是ls -l
--關於長格式
--第一列,許可權
-rw-r--r-- 是指許可權;預設是10位。
-表示檔案類型(-檔案 d目錄 |軟連結檔案)——總共有7種,其他用的少,先不管,是系統特殊檔案,一般使用者不用管,想看的話
[root@andy ~]# ls -l /dev/
後面9位,每3個是一組,分別代表檔案的u所有者,g所屬組,o其他人三個身份(該檔案與三者的許可權規定)
(Linux使用者組是有相同許可權的使用者集)
r讀,w寫,x執行(基本許可權就這麼三個)
比如rw- u對它具有讀寫權限
--點兒“.”
代表ACL許可權
--數字1
引用計數
--root root
所有者和所屬組
--數字
檔案大小,單位是位元組,用-h選項
[root@andy ~]# ls -lh
總用量 44K
-rw-------. 1 root root 1.3K 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26K 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7.4K 11月 25 03:52 install.log.syslog
--日期
最後一次修改時間
--最後、
檔案名稱
檔案名稱以“.”開頭的是隱藏檔案
-- -d
看目錄本身的許可權
-- -i
顯示i節點,id號
----檔案處理命令
建立目錄,建立檔案啊
---目錄處理命令&檔案處理命令
目錄也是檔案,先明確下再。
--建立目錄:mkdir
make directory
mkdir -p [目錄名]
-p 遞迴建立,意思就是如果要建立多級目錄,要遞迴建立
[root@andy ~]# mkdir -p japan/cangls
---切換所在目錄:cd
cd [目錄]
很簡單,即可以切很多級,也可以切一級,不輸入目錄,就直接回家目錄
-簡化操作
cd 或 cd ~ 回家(~本來就代表家目錄)
cd .. 返回上一級目錄
cd - 進入上一次目錄
cd . 進入目前的目錄
[root@andy ~]#
[root@andy ~]# cd /etc
[root@andy etc]# cd sysconfig
[root@andy sysconfig]# cd..
-bash: cd..: command not found
[root@andy sysconfig]# cd ..
[root@andy etc]# cd -
/etc/sysconfig
[root@andy sysconfig]# cd ~
[root@andy ~]#
--
相對路徑和絕對路徑
[root@andy ~]# cd ../usr/local/src
[root@andy src]# cd ../usr/local/src
-bash: cd: ../usr/local/src: 沒有那個檔案或目錄
[root@andy src]# cd /usr/local/src
[root@andy src]# cd /usr/local/src
[root@andy src]#
相對路徑,就是相對當前位置來cd
絕對路徑,就是從根目錄開始找,麻煩但可靠,適合初學者
--關於tab鍵
補全命令和目錄,按鍵兩次,判斷正確
--查詢所在目錄位置:pwd
直接用
--刪除空目錄:rmdir
remove empty directory
rmdir [目錄]
[root@andy ~]# rmdir bols
[root@andy ~]# rmdir japan
rmdir: 刪除 "japan" 失敗: 目錄非空
所以不好用,知道就好
--刪除檔案或目錄:rm
remove
[root@andy ~]# rm japan
rm: 無法刪除"japan": 是一個目錄
[root@andy ~]# rm -r japan
rm:是否進入目錄"japan"? y
rm:是否刪除目錄 "japan/cangls"?y^Hn^H^H^H
rm:是否刪除目錄 "japan"?n
[root@andy ~]# rm -rf japan
[root@andy ~]# ls -l
總用量 44
-rw-------. 1 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
[root@andy ~]#
rm -rf [目錄]
如果直接用-rf刪除,就沒有提問,直接刪除了,所以小心使用,甚至有可能把整個系統刪除
-r 刪除目錄
-f 強制
--複製:cp
copy
-r 複製目錄
-p -d
-a 相當於-rpd
所以用cp就,cp -a,確保複製的都一樣,時間啊什麼的
--剪下或改名:mv
move
注意,剪下不加選項
--常見目錄作用
[root@andy ~]# cd /
[root@andy /]# ls
bin boot cgroup dev etc home lib lost+found media misc mnt net opt proc root sbin selinux srv sys tmp usr var
先切換到根目錄/
這些都是一級目錄
bin和sbin,以及usr下的bin和sbin下的都是儲存系統命令
/boot 啟動目錄,儲存使用者的啟動資料
/dev 特殊檔案儲存目錄,不要亂動
/etc 系統的預設的設定檔,以後會經常動的
/home 普通使用者的家目錄, /root 超級使用者的家目錄
/lib 函數庫倉庫
misc media mnt 空目錄,用於掛載,外接其他裝置的,自己設定用
proc sys 不能直接操作,是記憶體的盤符
/tmp 臨時目錄
/usr 系統資來源目錄
/var 儲存系統可變文檔目錄
總之,在家目錄和/tmp下隨便放東西
---連結命令:ln
link
ln -s [源檔案] [目標檔案]
-s soft 軟連結
注意一點:建立連結的根本目的,就是相當於平時的捷徑
--永久連結
基本上可以理解為,同一個檔案的不同的存取點/名字(想象為同一個教室的前後門)
具有同樣的i節點和儲存block塊;刪除其中一個,還是可以用
缺點在於,不能跨分區,不能針對目錄
[root@andy ~]# ln /root/anaconda-ks.cfg /tmp/ana.hard
[root@andy ~]# ll
總用量 48
-rw-------. 2 root root 1272 11月 25 03:55 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 11月 26 04:55 japan
[root@andy ~]# ll /tmp
總用量 92
-rw-------. 1 root root 1272 11月 26 04:55 ana
-rw-------. 2 root root 1272 11月 25 03:55 ana.hard
drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
-rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 11月 25 03:32 yum.log
基本上是看不出來的,除了引用計數+1了;不過可以看i節點號
[root@andy ~]# ls -li
總用量 48
135177 -rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
135180 drwxr-xr-x. 3 root root 4096 11月 26 04:55 japan
[root@andy ~]# ls -li /tmp
總用量 92
550003 -rw-------. 1 root root 1272 11月 26 04:55 ana
135177 -rw-------. 2 root root 1273 11月 26 05:32 ana.hard
550005 drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
550004 -rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
522243 -rw-------. 1 root root 0 11月 25 03:32 yum.log
如果刪除了某一個檔案,引用計數會變回1
但,不推薦建立永久連結:限制多;比較隱蔽,僅i節點——推薦用軟~
--軟連結
相當於windows的捷徑
擁有自己的i節點和block塊,但是資料區塊中只儲存源檔案的檔案名稱和i節點號,沒有實際的檔案資料(類似儲存的是個藏寶圖)
軟連結的許可權都是lrwxrwxrwx
刪除源檔案,軟連結失效(都說是捷徑了)
修改某一個,另一個也會變
[root@andy ~]# cp -a anaconda-ks.cfg /root/japan
[root@andy ~]# ln -s /root/japan/anaconda-ks.cfg /tmp/an.soft
[root@andy ~]# ll
總用量 48
-rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
-rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
-rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
drwxr-xr-x. 3 root root 4096 11月 26 05:43 japan
[root@andy ~]# ll /tmp
總用量 92
-rw-------. 1 root root 1272 11月 26 04:55 ana
-rw-------. 2 root root 1273 11月 26 05:32 ana.hard
lrwxrwxrwx. 1 root root 27 11月 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
-rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
-rw-------. 1 root root 0 11月 25 03:32 yum.log
[root@andy ~]# ll -i /tmp
總用量 92
550003 -rw-------. 1 root root 1272 11月 26 04:55 ana
135177 -rw-------. 2 root root 1273 11月 26 05:32 ana.hard
533111 lrwxrwxrwx. 1 root root 27 11月 26 05:44 an.soft -> /root/japan/anaconda-ks.cfg
550005 drwxr-xr-x. 3 root root 4096 11月 26 04:56 japan
550004 -rw-------. 1 root root 81920 11月 26 04:40 whatis.2kxNR9
522243 -rw-------. 1 root root 0 11月 25 03:32 yum.log
[root@andy ~]# ll -i
總用量 48
135177 -rw-------. 2 root root 1273 11月 26 05:32 anaconda-ks.cfg
130564 -rw-r--r--. 1 root root 26420 11月 25 03:55 install.log
130565 -rw-r--r--. 1 root root 7572 11月 25 03:52 install.log.syslog
135180 drwxr-xr-x. 3 root root 4096 11月 26 05:43 japan
注意幾點,i節點,許可權,檔案名稱
另外,軟連結中,源檔案一定要寫絕對路徑,否則可能會報錯
我自己寫的例子少,大家多練習
明天見
http://www.bkjia.com/PHPjc/1074840.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1074840.htmlTechArticle買錯的電影票,含著淚也得看-LAMP搭建Linux基礎,電影票-lamp hi 沒說過,上周五室友過生請客,在龍湖裡吃嗨了喝爽了,回去的路上侃侃而談...