Debian 8 安裝Nginx最新版本

在Debian下若是直接apt-get install nginx直接裝發現nginx版本是很舊的,本文主要講一下如何在Debian 8上裝新版的nginx。html

原文資料:https://nginx.org/en/linux_packages.html,若是英文不錯的話,能夠直接閱讀官方文檔。linux

1、清理殘餘的舊版本nginx

sudo apt-get remove nginx nginx-common nginx-full

2、安裝nginx PGP簽名文件vim

wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

3、使用sudo修改source源rest

codename參數根據os來選擇:https://nginx.org/en/linux_packages.html#distributionscode

好比個人OS是Debian 8 jessie,codename參數即爲jessieserver

使用sudo編輯/etc/apt/source.list文件htm

sudo vim /etc/apt/source.list

在文件末追加如下:blog

deb http://nginx.org/packages/mainline/debian/ [codename] nginx
deb-src http://nginx.org/packages/mainline/debian/ [codename] nginx

eg:rem

deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx

4、更新軟件源並安裝nginx

sudo apt-get update
sudo apt-get install nginx

5、查看nginx版本號

sudo nginx -v

6、nginx啓動

 

sudo service nginx start
sudo service nginx restart
sudo service nginx reload
sudo service nginx stop

七.配置

vim /etc/nginx/sites-available/default

 

server{
        listen 80;
	access_log  logs/www.***.cn.log  main;
        server_name www.***.cn; #綁定域名
        location / {
            proxy_pass  http://localhost:7777;
	    proxy_set_header Host $host;
	    proxy_set_header X-Real-IP $remote_addr;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
相關文章
相關標籤/搜索