2014年4月9日 星期三

安裝debian server

RAM: 2G
硬碟:8G

欲安裝的軟體:
screen, sudo, vim, git, mysql( mysql-server, mysql-client,  ),

安裝sudo
http://sharadchhetri.com/2013/08/07/sudo-command-not-found-debian-7/
$ apt-get update
$ apt-get install vim
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
$ sudo apt-get install vim
bash: sudo: command not found
$ su -
# apt-get install sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  sudo
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 0 B/851 kB of archives.
After this operation, 1,885 kB of additional disk space will be used.
Media change: please insert the disc labeled
 'Debian GNU/Linux 7.4.0 _Wheezy_ - Official i386 CD Binary-1 20140208-12:25'
in the drive '/media/cdrom/' and press enter => 要你插光碟
解法:
http://askubuntu.com/questions/236288/apt-get-asks-me-to-insert-cd-why
sudo gedit /etc/apt/sources.list
把這行註解掉:
# deb cdrom:[Ubuntu 12.10 _Quantal Quetzal_ - Release amd64 (20121017.5)]/ quantal main restricted
然後別忘了: sudo apt-get update
就能 # apt-get install sudo 了

user_name@linux:~$ sudo apt-get install vim
出現錯誤:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for user_name:
user_name is not in the sudoers file.  This incident will be reported.
解法:
用root 編輯這個檔案:
# vi /etc/sudoers
加入這一行:
user_name ALL=(ALL:ALL) ALL
user_name就能使用sudo安裝套件了

vim 沒highlight
在~/.vimrc裡面加入這行: syntax on
或將 /etc/vim/vimrc 的" syntax on 註解拿掉

安裝mysql
http://ariejan.net/2007/12/12/how-to-install-mysql-on-ubuntudebian/
$ sudo apt-get update
$ sudo apt-get dist-upgrade  # 什麼是apt-get dist-upgrade
※ upgrade: 系統將現有的 Package 升級, 如果有相依性的問題, 而此相依性 需要安裝其它新的 Package 或 影響到其它 Package 的相依性時, 此 Package 就不會被升級, 會保留下來.
※ dist-upgrade: 可以聰明的解決相依性的問題, 如果有相依性問題, 需要 安裝/移除 新的 Package, 就會試著去 安裝/移除 它. (所以通常這個會被認為是有點風險的升級)
$ sudo apt-get install mysql-server mysql-client  # 我安裝時他就提示要我設置mysql的root密碼,故不用另外用指令設置了
如果裝好mysql和apache後需要裝php5-mysql才能讓php用mysql( mysql, mysqli 擴展 )
$ sudo apt-get install php5-mysql

安裝php
$ sudo apt-get install php5  # 網路上找到的都要安裝 libapache2-mod-php5 ,但php5安裝完就有裝libapache2-mod-php5了
$ dpkg --get-selections | grep php
libapache2-mod-php5                             install
php5                                            install
php5-cli                                        install
php5-common                                     install

新增資料庫
# mysqladmin create xxx
錯誤訊息:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
解法:
照這篇改密碼後就可以了
http://magicsun.pixnet.net/blog/post/25768313-mysqladmin%3A-connect-to-server-at-'localhost'-failed-%E8%99%95%E7%90%86
雖然改的密碼前後都一樣( 我原本mysql -u root -p 可以登入 ),估計是mysql> FLUSH PRIVILEGES; 的關係


沒有留言:

張貼留言