Last active
February 5, 2016 15:38
-
-
Save takp/2593213e69cef6fc4efa to your computer and use it in GitHub Desktop.
Nginxでブラウザ言語判定してリダイレクトさせる方法 ref: http://qiita.com/tak_nishida/items/cc5ad5cb80a00d997b48
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget http://nginx.org/download/nginx-1.9.10.tar.gz | |
$ tar xvf nginx-1.9.10.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/giom/nginx_accept_language_module.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
... | |
set_from_accept_language $lang en ja; | |
rewrite ^(.*)$ $scheme://$lang.example.com$1; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
... | |
add_header debug_var $lang; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /usr/local/src | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz | |
$ wget http://zlib.net/zlib-1.2.8.tar.gz | |
$ wget https://www.openssl.org/source/openssl-1.0.1r.tar.gz | |
$ tar xvf pcre-8.38.tar.gz | |
$ tar xvf zlib-1.2.8.tar.gz | |
$ tar xvf openssl-1.0.1r.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./configure: error: the HTTP rewrite module requires the PCRE library. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./configure \ | |
--add-module=/usr/local/src/nginx_accept_language_module \ | |
--with-pcre=/usr/local/src/pcre-8.38 \ | |
--with-zlib=/usr/local/src/zlib-1.2.8 \ | |
--with-openssl=/usr/local/src/openssl-1.0.1r \ | |
--with-http_ssl_module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ make | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nginx -v | |
nginx version: nginx/1.9.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /etc/init.d | |
$ sudo vim nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx="/usr/local/nginx/sbin/nginx" | |
... | |
NGINX_CONF_FILE="/etc/nginx/nginx.conf" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo service nginx start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment