从事技术工作的朋友一般都会深谙至少一种打开谷歌搜索的方法,新手可以选择修改hosts,善于折腾的也可以考虑自建***等等。今天帮某位程序猿同学在廉价的美国主机上搭建一个简易的谷歌搜索镜像站,给大家分享一下搭建方法。说明一下,在国外垃圾主机上自建的谷歌镜像站不建议公开分享,最好独享或者只分享给极少部分的朋友使用。
某大佬的谷歌镜像站: (镜像演示,随时失效)
实验环境:美国垃圾主机
操作系统:CentOS 6.9
Pcre:8.42
Zlib:1.2.11
Nginx:1.14.0
OpenSSL:1.0.2o
Ngx_http_google_filter_module
Ngx_http_substitutions_filter_module
第一步 准备工作
禁用SElinux
- [root@Wanghualang ~]# setenforce 0
- [root@Wanghualang ~]# sed -ri 's#^(SELINUX=).*#\1disabled#g' /etc/selinux/config
禁用防火墙
- [root@Wanghualang ~]# service iptables stop
- [root@Wanghualang ~]# service ip6tables stop
- [root@Wanghualang ~]# chkconfig iptables off
- [root@Wanghualang ~]# chkconfig ip6tables off
安装常用软件
- [root@Wanghualang ~]# yum -y install wget vim unzip
第二步 下载解压源码包
以下为相关软件源码包的官方下载页面或作者发布页面:
https://ftp.pcre.org/pub/pcre/
http://zlib.net/
http://nginx.org/en/download.html
https://www.openssl.org/source/
https://github.com/cuber/ngx_http_google_filter_module
https://github.com/yaoweibin/ngx_http_substitutions_filter_module
下载、解压源码包
- [root@Wanghualang ~]# cd /usr/local/src/
- [root@Wanghualang src]# wget --no-check-certificate https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
- [root@Wanghualang src]# wget --no-check-certificate http://zlib.net/zlib-1.2.11.tar.gz
- [root@Wanghualang src]# wget --no-check-certificate https://www.openssl.org/source/openssl-1.0.2o.tar.gz
- [root@Wanghualang src]# wget --no-check-certificate http://nginx.org/download/nginx-1.14.0.tar.gz
- [root@Wanghualang src]# wget --no-check-certificate -O ngx_http_google_filter_module.zip https://github.com/cuber/ngx_http_google_filter_module/archive/master.zip
- [root@Wanghualang src]# wget --no-check-certificate -O ngx_http_substitutions_filter_module.zip https://github.com/yaoweibin/ngx_http_substitutions_filter_module/archive/master.zip
- [root@Wanghualang src]# tar xzf pcre-8.42.tar.gz
- [root@Wanghualang src]# tar xzf zlib-1.2.11.tar.gz
- [root@Wanghualang src]# tar xzf openssl-1.0.2o.tar.gz
- [root@Wanghualang src]# tar xzf nginx-1.14.0.tar.gz
- [root@Wanghualang src]# unzip ngx_http_google_filter_module.zip
- [root@Wanghualang src]# unzip ngx_http_substitutions_filter_module.zip
第三步 安装Nginx
精简版的操作系统,在接下来的configure阶段肯定会出现缺失相关开发包的报错,根据提示安装相关开发包即可。教程中为了做到一气呵成,先提前安装好需要的开发包。
- [root@Wanghualang ~]# yum -y install make gcc gcc-c++
编译安装软件
- [root@Wanghualang ~]# cd /usr/local/src/nginx-1.14.0
- [root@Wanghualang nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=../pcre-8.42 --with-openssl=../openssl-1.0.2o --with-zlib=../zlib-1.2.11 --add-module=../ngx_http_google_filter_module-master --add-module=../ngx_http_substitutions_filter_module-master
- [root@Wanghualang nginx-1.14.0]# make
- [root@Wanghualang nginx-1.14.0]# make install
第四步 配置启动Nginx
编辑Nginx主配置文件,
- [root@Wanghualang ~]# vim /usr/local/nginx/conf/nginx.conf
大约在第37行,找到server_name localhost,把localhost修改为VPS主机的IP地址,也可以修改为域名。接着在这一行下面插入内容:resolver 8.8.8.8;
最终修改如下:
- server_name google.wanghualang.com;
- resolver 8.8.8.8;
大约在第43行,找到location / {,在这一行往下插入内容:
- google on;
- google_scholar on;
最终修改如下:
- location / {
- google on;
- google_scholar on;
- root html;
- index index.html index.htm;
- }
启动Nginx
- [root@Wanghualang ~]# /usr/local/nginx/sbin/nginx
也可以直接下载附件中已编译好的Nginx,解压后修改一下主配置文件中的ServerName,就可以启动使用。
使用浏览器访问:地址,若能看到谷歌搜索首页,表示配置成功!
【声明:本文来源于】