Total Pageviews

Thursday, 1 December 2016

上传vps/本地电脑上的静态网站到netlify.com空间

 首先在本地机器的浏览器中,访问https://app.netlify.com/signup,(https://app.netlify.com/signup/email)注册账号。

然后在linux vps上搭建nodejs环境。
然后,
npm install netlify-cli -g
cd到某个静态网站的根目录,比如
cd /usr/local/heckle-by-marijnh/blog/_site
 
root@AR:/usr/local/heckle-by-marijnh/blog/_site# netlify deploy
会显示:
Please visite this authentication URL in your browser:
https://app.netlify.com/authorize?response_type=ticket&ticket=一长串字符
No site id specified, create a new site?(Yn) (回车)
Path to deploy? (current dir) (回车)
Deploying folder: /usr/local/heckle-by-marijnh/blog/_site (等待直到上传完成)

Deploy is live (permalink):
http://584119766686740e43ef4a1a.diplomat-transfer-70311.netlify.com

Last build is always accessible on http://diplomat-transfer-70311.netlify.com

root@AR:/usr/local/heckle-by-marijnh/blog/_site#
(改版后的提示: 
$ netlify deploy
This folder isn't linked to a site yet
? What would you like to do?
> Link this directory to an existing site
+ Create & configure a new site
用键盘的上下箭头选择。如果是第一次上传,选择第2项。如果已经上传过了,而现在是更新网站,
则选择第1项。然后回车,显示:
What would you like to do? Link this directory to an existing site

netlify link will connect this folder to a site on Netlify

? How do you want to link this folder to a site?
> Search by full or partial site name
Choose from a list of your recently updated sites
Enter a site ID
 
用键盘的上下箭头选择第2项,然后回车。显示:
How do you want to link this folder to a site? Choose from a list of your rece
ntly updated sites
Fetching recently updated sites...

? Which site do you want to link? (Use arrow keys)
> kaleidoscopic-jalebi-1cb83b
diplomat-transfer-70311
 
我最近更新的网站是第1个,所以选择第1个。用键盘的上下箭头选择第1项,然后回车。显示: 
Which site do you want to link? kaleidoscopic-jalebi-1cb83b

Directory Linked

Admin url: https://app.netlify.com/sites/kaleidoscopic-jalebi-1cb83b
Site url: https://kaleidoscopic-jalebi-1cb83b.netlify.app

You can now run other `netlify` cli commands in this directory
Please provide a publish directory (e.g. "public" or "dist" or "."):
? Publish directory (.)
输入. ,回车,就开始上传了。等待上传过程完成,最后显示:
If everything looks good on your draft URL, deploy it to your main site URL with 
the --prod flag.
netlify deploy --prod 
然后输入netlify deploy --prod ,回车。 显示:
$ netlify deploy --prod
Please provide a publish directory (e.g. "public" or "dist" or "."):
输入. ,回车,就开始上传了。等待上传过程完成。最后,最下一行显示:
Website URL:        https://kaleidoscopic-jalebi-1cb83b.netlify.app
网站就更新完成了。)

在你本地机器的浏览器中访问http://diplomat-transfer-70311.netlify.app,即可看到
上传到netlify.com空间的你的静态网站的内容。网站效果跟我在linux vps上搭建的静态网站
http://hc.bright.biz.st完全一样。
第二个例子:https://kaleidoscopic-jalebi-1cb83b.netlify.app 

当然,你也可把在本地的linux桌面系统或mac系统上搭建的静态网站上传到netlify.com空间。
(需先在本地的linux桌面系统或mac系统上,搭建nodejs环境,之后,跟linux vps上的操作
是一样的。) 
 
文档地址:https://www.netlify.com/docs/welcome/ 
-----------------------
另外,

Drag & drop. It’s online.

Drop a folder with your site’s HTML, CSS, and JS files.
We’ll give you a link to share it.

Drop a site, make it yours

Put your site online

Drag and drop your site folder, and you’ll have your site in the cloud at a temporary URL. No account needed.

from https://app.netlify.com/drop 

------

Run a local development environment

Netlify Dev brings the functionality of your Netlify production environment directly to your local machine.

For more information on how to configure and use Netlify Dev, refer to our local development with Netlify Dev doc.


Get help

To get usage tips and learn more about available commands from within Netlify CLI, run the following:

netlify help

For more information about a specific command, run help with the name of the command.

netlify help deploy

This also works for sub-commands.

netlify help sites:create

If you have additional questions or ideas for new features, you can start an issue on Netlify CLI’s open source repository. You can also visit our Support Forums to start or join a conversation. We’d love to hear from you!

#

--------------------------------------

Continuous deployment

Configuration for continuous deployment from a Git repository

Your site is linked to a Git repository for continuous deployment.

Learn more about continuous deployment in the docs


from https://app.netlify.com/sites/blog-of-brite/configuration/deploys#continuous-deployment

(netlify链接你的github仓库后,默认就是continuous deployment(持续部署,即自动部署。只要你的github仓库,比如github.com/briteming/zhonger.github.io发生了

变更,诸如新建了原帖之类: https://github.com/briteming/zhonger.github.io/tree/master/_posts/others,那么netlify就会自动把你仓库的内容上传到其空间,进行build,2分钟后,在netlify.com空间生成的网站https://blog-of-brite.netlify.app就会被自动更新。)

------------------------------


Deploys for blog-of-brite

https://blog-of-brite.netlify.app, https://blog-of-brite.netlify.app/blog/

Deploys from github.com/briteming/zhonger.github.io.

Published master@9436bf3

Auto publishing is on. Deploys from master are published automatically.

------------------------------------------------

类似的服务:http://briteming.blogspot.com/2016/08/surgesh.html
这个netlify.com空间比surge.sh空间要好用多了。 

--------------------------------------------------
上传vps/本地电脑上的静态网站到vercel.com空间
npm install -g vercel (会生成可执行文件vc)
然后cd到某个静态网站的根目录,
vc --cwd .
按照提示操作即可。
 可惜vercel.com空间只提供命令行版进行静态网站的根目录内容的上传,不提供网页版上传功能。
而netlify.com空间既提供命令行版进行静态网站的根目录内容的上传,也提供网页版。