将动态 PHP/mySQL 网站转换为存档的 HTML 版本?

发布于 2024-10-16 10:34:19 字数 480 浏览 6 评论 0原文

我有一个 PHP/mySQL 站点,不再添加任何新内容。但我想保留我所拥有的内容作为档案并将其保存在网上。理想情况下,我想将其转换为静态站点,以便它不再需要数据库。

如果其他人经历过这个过程,是否有任何工具、脚本或方法可以自动化这个过程,或者至少让这个过程变得更容易?我希望能够做一些事情,例如确保所有链接仍然有效(因此它们必须以某种方式转换以正确指向新的静态版本),诸如此类的事情。

我可以通过 ssh 访问相关服务器。我对 PHP 和 Python 都比较熟悉,因此使用这些语言的工具将是理想的选择。

注意:我这样做有两个基本原因:

  1. 成本,因为仅托管一组静态文件比动态网站便宜得多(我正在使用 NearlyFreeSpeech 并使用我的带宽)我估计我的成本会下降到远低于 1 美元/月)。
  2. 垃圾邮件发送者以某种方式找到了我的网站并继续注册帐户(此时,他们无论如何都无法发表评论,但这仍然很烦人)。

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:

  1. 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).
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

高冷爸爸 2024-10-23 10:34:19

如果您可以通过 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

謸气贵蔟 2024-10-23 10:34:19

我最近使用以下方法取得了良好的效果:

wget --mirror -w 2 -p --html-extension --convert-links -P folder_to_save_to http://mysite.com

您可能需要使用 wget 脚本的完整路径。这将更改所有链接,以便您的网站完全静态且独立。

I have recently used the following to good effect:

wget --mirror -w 2 -p --html-extension --convert-links -P folder_to_save_to http://mysite.com

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.

江南烟雨〆相思醉 2024-10-23 10:34:19

使用 PHP,您可以编写一个简单的脚本来执行以下操作:

  1. 保存当前页面。
  2. 单击该页面中的链接并保存这些页面(并且对于每个页面,从 1 开始重复)。
  3. 将当前页面上的 URL 替换为指向已保存页面的 URL。

Using PHP you could write a simple script that would do this:

  1. Save current page.
  2. Follow links from that page and saving those pages (and for each page repeat from 1).
  3. Replace URLs on current page with those leading to saved pages.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文