参考文献:Nginx Google 扩展中关于从发行版迁移的部分,修改自 lingyue 的 openstick 脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
cd /home/flymemory #安装依赖包 sudo apt-get install build-essential git gcc g++ make #下载最新版模块 wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz" wget "https://www.openssl.org/source/openssl-1.1.0d.tar.gz" wget "http://zlib.net/zlib-1.2.11.tar.gz" #Git Clone git clone https://github.com/cuber/ngx_http_google_filter_module git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module #解压缩 tar xzvf pcre-8.40.tar.gz tar xzvf openssl-1.1.0d.tar.gz tar xzvf zlib-1.2.11.tar.gz #Check for current configuration: sudo /usr/local/nginx/sbin/nginx -V #nginx version: nginx/1.9.4 #built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) #built with OpenSSL 1.0.1f 6 Jan 2014 #TLS SNI support enabled #configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-google_perftools_module #备份并修改原脚本 cd lnmp/include/ sudo cp upgrade_web.sh upgrade_web-backup.sh sudo nano upgrade_web.sh #Look for this line: if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ];then #Change "$OLD_Nginx_version" to 1.9 to cheat the script if [ "$NEW_Nginx_version" != "1.9" ];then #Look for this line: ./configure $nginx_configure_arguments #Add one more line for more configuration, remember to add a "\" for first line ./configure $nginx_configure_arguments \ --with-pcre=/home/flymemory/pcre-8.40 --with-openssl=/home/flymemory/openssl-1.1.0d --with-zlib=/home/flymemory/zlib-1.2.11 --add-module=/home/flymemory/ngx_http_google_filter_module --add-module=/home/flymemory/ngx_http_substitutions_filter_module #运行升级脚本,选Nginx,版本号1.9.4 cd /home/flymemory/lnmp sudo ./upgrade.sh #Check for new configuration sudo /usr/local/nginx/sbin/nginx -V #nginx version: nginx/1.9.4 #built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) #built with OpenSSL 1.0.2d 9 Jul 2015 #TLS SNI support enabled #configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-google_perftools_module --with-pcre=/home/flymemory/pcre-8.36 --with-openssl=/home/flymemory/openssl-1.0.2d --with-zlib=/home/flymemory/zlib-1.2.8 --add-module=/home/flymemory/ngx_http_google_filter_module --add-module=/home/flymemory/ngx_http_substitutions_filter_module |
这篇文章能发出去,说明编译应该是成功了,然后添加一个新的虚拟虚拟主机,修改主机配置文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
upstream google { server 74.125.224.80:443 max_fails=3; server 74.125.224.81:443 max_fails=3; server 74.125.224.82:443 max_fails=3; server 74.125.224.83:443 max_fails=3; server 74.125.224.84:443 max_fails=3; } server { listen 80; server_name mstar.top www.mstar.top; access_log /home/wwwlogs/mstar.top_nginx.log combined; index index.html index.htm index.jsp index.php; include other.conf; root /home/wwwroot/mstar.top; listen 443 ssl; #ssl on; ssl_certificate /etc/nginx/mstar.top.crt; ssl_certificate_key /etc/nginx/mstar.top.key; #rewrite to SSL if ($scheme = http) { return 301 https://$server_name$request_uri; } resolver 8.8.8.8; location / { google on; google_scholar on; google_language "en"; } } |
2 thoughts on “在 lnmp 基础上重新编译 Nginx 以支持 Google 反代模块”