LoginSignup
0
1

More than 5 years have passed since last update.

Ubuntuに最新のnginxをインストールする(Ubuntu 12.04)

Last updated at Posted at 2017-12-22

環境

Ubuntu 12.04

stableバージョンのnginxをインストール

参考: https://qiita.com/hiroq/items/420424bc500d89fd1cc8

# nginxサイトが配布するPGPキーを追加
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -

# リポジトリを一覧に追加
VCNAME=`cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2` && sudo sh -c "echo \"deb http://nginx.org/packages/ubuntu/ $VCNAME nginx\" >> /etc/apt/sources.list"
VCNAME=`cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2` && sudo sh -c "echo \"deb-src http://nginx.org/packages/ubuntu/ $VCNAME nginx\" >> /etc/apt/sources.list"

# アップデート後、nginxをインストール
sudo apt-get update
sudo apt-get install nginx

# バージョンを確認
nginx -v
> nginx version: nginx/1.12.0

mainlineバージョンのnginxをインストール

参考: https://gist.github.com/craigvantonder/729fc169ae087918e6de744f420adf8b

# nginxサイトが配布するPGPキーを追加
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -

# リポジトリを一覧に追加
VCNAME=`cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2` && sudo sh -c "echo \"deb http://nginx.org/packages/mainline/ubuntu/ $VCNAME nginx\" >> /etc/apt/sources.list"
VCNAME=`cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2` && sudo sh -c "echo \"deb-src http://nginx.org/packages/mainline/ubuntu/ $VCNAME nginx\" >> /etc/apt/sources.list"

# アップデート後、nginxをインストール
sudo apt-get update
sudo apt-get install nginx

# バージョンを確認
nginx -v
> nginx version: nginx/1.13.0

おまけ: Nginxのアンインストール方法

参考: https://askubuntu.com/a/235349

sudo apt-get remove nginx nginx-common # Removes all but config files.
sudo apt-get purge nginx nginx-common # Removes everything.
sudo apt-get autoremove # After using any of the above commands, use this in order to remove dependencies used by nginx which are no longer required.
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1