0%

Ubuntu Server 16.04 LTS 安裝筆記

Ubuntu 16.04 LTS在上個月發佈了
最近剛好要架設一個網站
順便來個系統重整:P

SSH

剛灌好系統先讓系統可以SSH
# sudo apt install openssh-server
設定檔在
# sudo vim /etc/ssh/sshd_config

1
2
PermitRootLogin prohibit-password #禁止Root
PasswordAuthentication no #關閉密碼登入

限制使用者IP
AllowUsers [user1]@123.456.* [user2]@*
重新啟動
# sudo systemctl restart sshd.service
# sudo systemctl restart sshd
權限
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

更新

更新所有套件source
# sudo apt-get update
自動安裝安全性更新(會跑很久)
# sudo unattended-upgrade
Log位置
# cat /var/log/unattended-upgrades/unattended-upgrades.log

新增使用者

新增一個有家目錄的使用者
# sudo useradd -m [user]
改密碼
# sudo passwd [user]
加入sudo群組
# sudo usermod -a -G sudo [user]
如果要從sudo群組移除使用者的話
# sudo gpasswd -d [user] sudo
看有沒有改對
id [user]

Shell

更改成bash
# sudo usermod -s /bin/bash hsu
一般使用者無法使用$ chsh指令,或許加入adm群組就能用了吧(?)

Apache

安裝
# sudo apt install apache2
重開
# sudo systemctl restart apache2.service

PHP 7 (版本號要自己去search)

安裝
# sudo apt install php7.0
裝完apache就可讀php檔
# sudo apt install libapache2-mod-php7.0
必要的套件(Laravel)
# sudo apt install php7.0-zip

MySQL (版本號要自己去search)

安裝
# sudo apt install mysql-server-5.7
# sudo apt install php7.0-mysql
查看目前狀態
# sudo systemctl status mysql.service

PhpMyAdmin

安裝
# sudo apt install phpmyadmin
# sudo apt install php-mbstring
# sudo apt install php-gettext
記得重啟不然還是不能用
# sudo systemctl restart apache2.service

Git

安裝
# sudo apt install git
設定
git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"
# git config --list(git config -l)

Composer

下載
https://getcomposer.org/download/
# php composer.phar 確認沒問題後
# sudo mv composer.phar /usr/local/bin/composer
可以global # composer