将动态 PHP/mySQL 网站转换为存档的 HTML 版本?
我有一个 PHP/mySQL 站点,不再添加任何新内容。但我想保留我所拥有的内容作为档案并将其保存在网上。理想情况下,我想将其转换为静态站点,以便它不再需要数据库。
如果其他人经历过这个过程,是否有任何工具、脚本或方法可以自动化这个过程,或者至少让这个过程变得更容易?我希望能够做一些事情,例如确保所有链接仍然有效(因此它们必须以某种方式转换以正确指向新的静态版本),诸如此类的事情。
我可以通过 ssh 访问相关服务器。我对 PHP 和 Python 都比较熟悉,因此使用这些语言的工具将是理想的选择。
注意:我这样做有两个基本原因:
- 成本,因为仅托管一组静态文件比动态网站便宜得多(我正在使用 NearlyFreeSpeech 并使用我的带宽)我估计我的成本会下降到远低于 1 美元/月)。
- 垃圾邮件发送者以某种方式找到了我的网站并继续注册帐户(此时,他们无论如何都无法发表评论,但这仍然很烦人)。
I have a PHP/mySQL site that is no longer going to get any new content added. But I'd like to keep what I do have as an archive and keep it online. Ideally I'd like to convert it to a static site so that it no longer requires a database.
If anyone else has gone through this process, are there any tools, scripts, or methodologies that can automate this or at least make this easier? I'd want to be able to do things like make sure that all the links still work (so they'd have to somehow be converted to correctly point to the new static versions), things like that.
I have ssh access to the server in question. I'm relatively comfortable with both PHP and Python so tools using those languages would be ideal.
Note: there are two basic reasons I'm doing this:
- cost, as it's much cheaper to host just a collection of static files than a dynamic website (I'm using NearlyFreeSpeech and with the bandwidth I'm using I estimate my costs would go down to well under $1/month).
- spammers have somehow found my site and keep signing up for accounts (at which point, they're blocked from making comments anyway, but it's still annoying).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您可以通过 shell 访问任何 Linux 机器(也许甚至您自己的网络服务器就足够了),我建议您使用 wget 抓取并下载您自己站点的镜像。 Wget 是一个实用程序,旨在将站点镜像为平面文件,并且已经使用了相当长的一段时间。我相信它应该对您很有帮助:
http://www.gnu.org/software /wget/manual/wget.html
我希望这有帮助。
克里斯
If you have shell access to any linux machine (perhaps even your own webserver would suffice), I'd recommend that you just spider and download a mirror of your own site using wget. Wget is a utility which is designed to mirror sites as flat files, and it has been in use for quite some time. I believe it should serve you well:
http://www.gnu.org/software/wget/manual/wget.html
I hope that's helpful.
Chris
我最近使用以下方法取得了良好的效果:
您可能需要使用 wget 脚本的完整路径。这将更改所有链接,以便您的网站完全静态且独立。
I have recently used the following to good effect:
You might need to use the full path to your wget script. This will change all the links so that your site is fully static and self contained.
使用 PHP,您可以编写一个简单的脚本来执行以下操作:
Using PHP you could write a simple script that would do this: