建議使用 Nginx 官方提供的 Repo。

若 /etc/apt/sources.list.d/ 下沒有 nginx.list,代表沒有設定 Nginx 專用 repo。

安裝 Nginx repo key
# wget http://nginx.org/keys/nginx_signing.key -O - | sudo apt-key add -

# sudo vi /etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/ubuntu/ precise nginx
deb-src http://nginx.org/packages/ubuntu/ precise nginx

若 Ubuntu 版本非 12.04 (precise),請將 precise 換成以下指令產生的代號
# lsb_release -cs
lucid (Ubuntu 10.04)

# sudo apt-get update && sudo apt-get install nginx


檢查版本
# nginx -v
nginx version: nginx/1.4.2

停用 Nginx,待設定好再啟動。
# sudo service nginx stop


主設定檔位於 /etc/nginx/nginx.conf,它會 include /etc/nginx/conf.d/*.conf
# cd /etc/nginx/conf.d/
# sudo cp default.conf web.conf

# sudo vi web.conf
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
# autoindex on; 列出整個目錄
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

避免 vboxsf 檔案分享功能造成 apache、nginx 的檔案更新失效
# sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ori
# sudo vi /etc/nginx/nginx.conf
sendfile off;


# sudo service nginx start

arrow
arrow
    全站熱搜

    flyfox 發表在 痞客邦 留言(0) 人氣()