Heroku 免费搭建 YouTube 镜像网站

PS: 本教程已过时, 请移步 https://github.com/justsweetpotato/you2php-heroku

本教程不需要拥有自己的服务器, 使用 Heroku 的免费应用托管服务.

Heroku 是什么? Heroku 是一个支持多种编程语言的云平台即服务。在 2010 年被 Salesforce.com 收购。
Heroku 作为最开始的云平台之一,从 2007 年 6 月起开发,当时它仅支持 Ruby,但后来增加了对 Java、Node.js、Scala、Clojure、Python 以及 PHP 和 Perl 的支持。

注册 Heroku 账号

https://www.heroku.com/

下载 Heroku CLI 客户端

https://devcenter.heroku.com/articles/getting-started-with-php#set-up

部署

1
2
3
4
5
6
7
8
9
10
11
$ heroku login
$ git clone https://github.com/justsweetpotato/you2php-heroku.git
# 修改 web/config.php 文件. 详细看第 4 步.
$ cd you2php-heroku
$ heroku create [Your APP Name]
$ heroku git:remote -a [Your APP Name]
$ git add .
$ git commit -am "make it better"
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open

[可选] 修改 web/confing.php 文件

1
2
3
4
5
6
7
8
9
10
<?php
$gl=(isset($_COOKIE['gl']) && $_COOKIE['gl'])?$_COOKIE['gl']:'US';
define('ROOT_PART', Root_part());
define('APIKEY', '你的 APIKEY');
define('GJ_CODE', $gl);
define('SITE_NAME', '你的网站名');
define('TITLENAME', '你的网站title');
define('EN2DEKEY', '一个随机字符串, 用于加密');
define('EMAIL', '你的邮箱, 用于处理版权纠纷');
?>

APIKEY 不修改使用我提供的也可以, 但是建议修改, 每个 APIKEY 有每日配额, 用自己的绝对够用.
申请方法: https://you2php.github.io/doc/
给网站加上密码也可以参考这篇教程: https://you2php.github.io/doc/

参考资料:

  1. https://github.com/You2php/you2php-heroku
  2. https://github.com/You2php/you2php