-
create github private repo
-
create vercel.json in the private repo:
{ "builds":[{"src": "/api/*.php", "use": "[email protected]"}, {"src": "/api/*.go", "use": "@vercel/go"}, {"src": "**/*.ico", "use": "@vercel/static"}, {"src": "**/*.gif", "use": "@vercel/static"}, {"src": "**/*.js", "use": "@vercel/static"}, {"src": "**/*.png", "use": "@vercel/static"}, {"src": "**/*.jpg", "use": "@vercel/static"} ], "routes":[{"src":"/(.*)", "dest": "/api/$1"} ] }
-
create dir "api" in the private repo
-
copy your whole php website codes into "api"
-
login vercel.com, create project and import the github private repo, click "Configure Github App" and add this private repo in "Repository access (Only select repositories)"
-
done, you can visit your website "https://[your repo name]-[your vercel user name].vercel.app" or bind your own domain name.
-
by clicking the last commit hash(https://github.com/[your github user name]/[your repo name]/commit/[hash]) you can see the vercel build bot error(it's weired that it didn't list it in the deployments log page)
-
you can see all deployments and click "redeploy" on https://vercel.com/[your vercel user name]/[your repo name]/deployments, the github deployments log is delayed on https://github.com/[your github user name]/[your repo name]/deployments
-
it seems that the free vercel php serverless webserver has no difference with the normal nginx php webserver
-
except that there's no database with the vercel php serverless webserver
-
we can use the "1GB per project"(20000 writes per day) firestore database of the $0 plan(spark plan) of google firebase, we can create 5 to 10 projects
-
login https://console.firebase.google.com, create a project(eg: "[my username]-firestore-1"), create a database(test mode) and collection(data table)
-
find the " Web API Key" in https://console.firebase.google.com/project/[your project name]/settings/general
-
in vercel php, read line1 from firestore table1:
$row1=@json_decode(@file_get_contents('https://firestore.googleapis.com/v1/projects/[your project name]/databases/(default)/documents/table1/1?key=[your web api key]'), 1);
-
in vercel php, update line1 of firestore table1:
$context=stream_context_create(array('http'=>array('method'=>'PATCH',
'timeout'=>5,
'header'=>"Content-Type: application/json\r\n",
'content'=>json_encode(['fields'=>['visits'=>['integerValue'=>$visits+1]]])
),
)
);
@file_get_contents('https://firestore.googleapis.com/v1/projects/[your project name]/databases/(default)/documents/table1/1?updateMask.fieldPaths=visits&key=[your web api key]', false, $context);