「Ubuntu Server 安裝步驟」:修訂間差異
出自DILA Wiki
imported>Guo.jieli (新頁面: 1. 使用的版本 12.04 LTS (下載:http://releases.ubuntu.com/precise/)<br /> LTS版本會在五年內一直會更新,不需要重新安裝整個系統。2012的LTS 在 2017...) |
imported>Ray |
||
(未顯示由 2 位使用者於中間所作的 8 次修訂) | |||
行 1: | 行 1: | ||
== 安 裝server == | |||
3. 需要安裝的server | 1. 使用的版本 12.04 LTS | ||
OpenSSH server | 下載: | ||
* http://www.ubuntu.com/download/server | |||
* http://releases.ubuntu.com/precise/ | |||
LTS版本會在五年內一直會更新,不需要重新安裝整個系統。2012的LTS 在 2017年前都會有更新檔案。更新的考量是安全性。 | |||
2. 安裝系統 | |||
partition disk | |||
root : 20G | |||
EFI : 開機需要 | |||
資料:放成data(剩下的檔案) | |||
swap : 跟RAM 一樣大 | |||
directory 不需要 encrypt | |||
3. 需要安裝的server : | |||
OpenSSH server | |||
LAMP server。(若忘記,就在系統能以 sudo apt-get install apache2 mysql-server php5)<br /> | LAMP server。(若忘記,就在系統能以 sudo apt-get install apache2 mysql-server php5)<br /> | ||
4. 另外在系統內 apt 裝 phpadmin、apache2。 | 4. 另外在系統內 apt 裝 phpadmin、apache2。 | ||
== 安全性設定 == | |||
0. ubuntu mail command: | |||
http://askubuntu.com/questions/12917/how-to-send-mail-from-the-command-line | |||
http://ubuntu.lyhdev.com/2010/09/gmailubuntu-linuxsmtp.html | |||
# 使用gmail當成 ubuntu server的收發信件。信件內容是關於一些server面對的問題 | |||
1. 自動安裝安全更新:#在安裝server 的時候直接處理了,要檢查設定。 | |||
command: | |||
sudo dpkg-reconfigure -plow unattended-upgrades | |||
check: | |||
will create /etc/apt/apt.conf.d/20auto-upgrades | |||
2. crontab 設定時間同步 # 時間不同步的話,容易出現問題。 | |||
## system clock update from ntp server (midnight every day) | |||
0 0 * * * /usr/sbin/ntpdate -s time.stdtime.gov.tw | |||
3. 安裝ufw | |||
ufw 防火牆設定程式 http://wiki.ubuntu-tw.org/index.php?title=Ufw | |||
4. Harden PHP for security. | |||
sudo vi /etc/php5/apache2/php.ini | |||
disable_functions = exec,system,shell_exec,passthru | |||
register_globals = Off | |||
expose_php = Off | |||
display_errors = Off | |||
track_errors = Off | |||
html_errors = Off | |||
magic_quotes_gpc = Off | |||
5. apache config: | |||
- 確定 run apache的user | |||
- 禁止瀏覽目錄:Options Indexes FollowSymLinks MultiViews (刪去Indexes), 重新啟動apache | |||
- Restrict Apache Information Leakage. | |||
sudo vi /etc/apache2/conf.d/security | |||
ServerTokens Prod | |||
ServerSignature Off | |||
TraceEnable Off | |||
Header unset ETag | |||
FileETag None | |||
6. apache mod_security | |||
sudo apt-get install libapache2-mod-security | |||
7. SELinux - Apparmor. | |||
sudo apt-get install apparmor apparmor-profiles | |||
check: sudo apparmor_status | |||
8. 安裝 Denyhosts #sudo apt-get install。 這是拿來擋ssh 攻擊的。 | |||
== Django 和 wsgi 設定 == | |||
說明事項: | |||
Django,用1.2.3的版本。 | |||
wsgi 是python 和apache 之間的溝通橋樑(官方安裝文件:http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide ) | |||
apache2 是適合很適合的版本。 | |||
安裝方法 | |||
解壓縮官方網站所(下載的檔案)(tar.gz 放在家目錄) | |||
>> tar xvfz mod_wsgi-X.Y.tar.gz | |||
執行壓縮檔案中的configure,檢查檔案 | |||
cd mod_wsgi-3.4 | |||
./configure | |||
成功會有以下畫面: | |||
checking for apxs2... /usr/bin/apxs2 | |||
checking Apache version... 2.2.22 | |||
checking for python... /usr/bin/python | |||
configure: creating ./config.status | |||
config.status: creating Makefile | |||
若不成功,可能有以下的套件需要安裝 | |||
安裝apxs2: | |||
sudo apt-get remove apache2-threaded-dev | |||
sudo apt-get install apache2-prefork-dev | |||
安裝 python-dev: | |||
sudoapt-get install python-dev | |||
要以上的 configure 都有出現才能進行 install | |||
make # 需要 sudo apt-get install make | |||
sudo make install | |||
模組成功安裝後會在 /usr/lib/apache2/modules cd 進去,然後設定 | |||
/usr/lib/apache2/modules | |||
sudo nano /etc/apache2/httpd.conf | |||
在檔案中填入: | |||
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so 存檔離開 | |||
之後需要重啟設定(reset) | |||
sudo /etc/init.d/apache2 force-reload | |||
設定 apache# django中media靜態要用 alias 指定。 | |||
為每個專案設定wsgi: | |||
sudo nano /etc/apache2/sites-available/default | |||
# {XXXXX} project | |||
WSGIScriptAlias /{XXXXX} /data/projects/{XXXXX}/{XXXXX}.wsgi | |||
WSGIDaemonProcess {XXXXX} user={user} group={user} processes=5 threads=1 | |||
WSGIProcessGroup {XXXXX} | |||
Alias /{XXXXX}/media /data/projects/{XXXXX}/{XXXXX}/media | |||
Alias /{XXXXX}/generateTreeMenu /data/projects/{XXXXX}/{XXXXX}/TreeMenu |
於 2013年9月18日 (三) 13:50 的最新修訂
安裝server
1. 使用的版本 12.04 LTS 下載:
LTS版本會在五年內一直會更新,不需要重新安裝整個系統。2012的LTS 在 2017年前都會有更新檔案。更新的考量是安全性。
2. 安裝系統
partition disk root : 20G EFI : 開機需要 資料:放成data(剩下的檔案) swap : 跟RAM 一樣大 directory 不需要 encrypt
3. 需要安裝的server :
OpenSSH server LAMP server。(若忘記,就在系統能以 sudo apt-get install apache2 mysql-server php5)
4. 另外在系統內 apt 裝 phpadmin、apache2。
安全性設定
0. ubuntu mail command:
http://askubuntu.com/questions/12917/how-to-send-mail-from-the-command-line http://ubuntu.lyhdev.com/2010/09/gmailubuntu-linuxsmtp.html # 使用gmail當成 ubuntu server的收發信件。信件內容是關於一些server面對的問題
1. 自動安裝安全更新:#在安裝server 的時候直接處理了,要檢查設定。
command: sudo dpkg-reconfigure -plow unattended-upgrades check: will create /etc/apt/apt.conf.d/20auto-upgrades
2. crontab 設定時間同步 # 時間不同步的話,容易出現問題。
## system clock update from ntp server (midnight every day) 0 0 * * * /usr/sbin/ntpdate -s time.stdtime.gov.tw
3. 安裝ufw
ufw 防火牆設定程式 http://wiki.ubuntu-tw.org/index.php?title=Ufw
4. Harden PHP for security.
sudo vi /etc/php5/apache2/php.ini
disable_functions = exec,system,shell_exec,passthru register_globals = Off expose_php = Off display_errors = Off track_errors = Off html_errors = Off magic_quotes_gpc = Off
5. apache config:
- 確定 run apache的user - 禁止瀏覽目錄:Options Indexes FollowSymLinks MultiViews (刪去Indexes), 重新啟動apache - Restrict Apache Information Leakage.
sudo vi /etc/apache2/conf.d/security
ServerTokens Prod ServerSignature Off TraceEnable Off Header unset ETag FileETag None
6. apache mod_security
sudo apt-get install libapache2-mod-security
7. SELinux - Apparmor.
sudo apt-get install apparmor apparmor-profiles
check: sudo apparmor_status
8. 安裝 Denyhosts #sudo apt-get install。 這是拿來擋ssh 攻擊的。
Django 和 wsgi 設定
說明事項:
Django,用1.2.3的版本。 wsgi 是python 和apache 之間的溝通橋樑(官方安裝文件:http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide ) apache2 是適合很適合的版本。
安裝方法
解壓縮官方網站所(下載的檔案)(tar.gz 放在家目錄) >> tar xvfz mod_wsgi-X.Y.tar.gz
執行壓縮檔案中的configure,檢查檔案
cd mod_wsgi-3.4 ./configure
成功會有以下畫面:
checking for apxs2... /usr/bin/apxs2 checking Apache version... 2.2.22 checking for python... /usr/bin/python configure: creating ./config.status config.status: creating Makefile
若不成功,可能有以下的套件需要安裝
安裝apxs2: sudo apt-get remove apache2-threaded-dev sudo apt-get install apache2-prefork-dev 安裝 python-dev: sudoapt-get install python-dev
要以上的 configure 都有出現才能進行 install
make # 需要 sudo apt-get install make sudo make install
模組成功安裝後會在 /usr/lib/apache2/modules cd 進去,然後設定
/usr/lib/apache2/modules sudo nano /etc/apache2/httpd.conf
在檔案中填入:
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so 存檔離開
之後需要重啟設定(reset)
sudo /etc/init.d/apache2 force-reload
設定 apache# django中media靜態要用 alias 指定。
為每個專案設定wsgi: sudo nano /etc/apache2/sites-available/default
# {XXXXX} project WSGIScriptAlias /{XXXXX} /data/projects/{XXXXX}/{XXXXX}.wsgi WSGIDaemonProcess {XXXXX} user={user} group={user} processes=5 threads=1 WSGIProcessGroup {XXXXX} Alias /{XXXXX}/media /data/projects/{XXXXX}/{XXXXX}/media Alias /{XXXXX}/generateTreeMenu /data/projects/{XXXXX}/{XXXXX}/TreeMenu