自建google镜像站(教程)

安装nginx服务器

yum install nginx

如果无法安装nginx看下面的方法,可以就直接跳到下方启动nginx

rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

然后再次使用yum命令安装nginx库在使用第一条命令安装nginx

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.njupt.edu.cn * extras: mirrors.nju.edu.cn * updates: mirrors.nju.edu.cn Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:1.14.0-1.el6.ngx will be installed --> Processing Dependency: libpcre.so.0()(64bit) for package: nginx-1.14.0-1.el6.ngx.x86_64 --> Finished Dependency Resolution Error: Package: nginx-1.14.0-1.el6.ngx.x86_64 (nginx) Requires: libpcre.so.0()(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest

如果安装出现上面的情况有2种可能:

1.没有网络可以试着ping www.baidu.com,看有没有网没有就没法下载了。

2.缺少 epel-release

sudo yum install epel-release -y
sudo yum install nginx -y

在结尾出现Complete!     Nginx在服务器上完成安装。

nginx -v      #查看nginx版本
rpm -ql nginx #查看nginx的安装目录
nginx -t      #测试nginx的配置
systemctl start nginx  #启动nginx
systemctl enable nginx #设置开机自动启动nginx

如果防火墙在运行中,执行以下命令:

firewall-cmd --permanent --zone=public --add-service=http --permanent  #放行http
firewall-cmd --permanent --zone=public --add-service=https --permanent #放行https
firewall-cmd --reload  #使配置生效

接下来在浏览器输入服务器ip访问就可以了

%title插图%num

安装PHP

一. 更新yum安装包

CentOS 7.x
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
CentOS 6.x
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
CentOS 5.x
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm

二. yum安装PHP及组件

yum install php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 php70w-fpm -y

查看php已安装版本

php -v

创建phpinfo文件查看php状态

<php?
    phpinfo();
?/>

申请https证书

本篇不再重复,详情请见:xxxxxx 文章

修改nginx.conf配置文件

cd /etc/nginx
cp -p nginx.conf nginx.conf.bak
vim nginx.conf
server {
  listen 80;
  listen 443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/google.0513c.site.crt;#按照自己路径更改
  ssl_certificate_key /usr/local/nginx/conf/ssl/google.0513c.site.key;#按照自己路径更改
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_session_timeout 10m;
  ssl_prefer_server_ciphers on;
  ssl_ciphers CHACHA20:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!DSS:!PKS;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  proxy_redirect off;
  proxy_pass https://www.google.co.jp/;
  proxy_redirect http://www.google.com/ /;
  proxy_cookie_domain google.com guance.com;
  proxy_set_header Accept-Encoding "";
  proxy_set_header User-Agent $http_user_agent;
  proxy_set_header Accept-Language "zh-CN";
  resolver 8.8.8.8 8.8.4.4 valid=300s;
  resolver_timeout 5s;
  location / {
}
}
server {
listen 80;
server_name google.0513c.site;                #设置成自己绑定的主机头
rewrite ^(.*)$ https://$host$1 permanent;     #访问http跳转至https
}

测试nginx配置文件正确

nginx -t

正确的话重启服务

systemctl resatrt nginx

google反代网页至此搭建完成

为防止被墙建议设置验证账户密码

详见文章:NGINX配置访问密码,让用户输入用户名密码才能访问

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注