如何在基于 Linux(共享主机)的 Web 服务器上安装 wkhtmltopdf
我已尝试各种方法在我们的网络服务器上安装 wkhtmltopdf 但不幸的是它没有安装。我无法访问 user/bin 文件夹,如安装教程中所述。
在服务器上的 public_html 文件夹中有一个子文件夹 _vti_bin,我从 wkhtmltopdf-0.9.1 复制了文件 wkhtmltopdf-i386 -static-i386,但我无法执行它。
如何在(共享托管)网络服务器上安装 wkhtmltopdf 并使其正常工作?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我已成功在我的共享托管帐户上安装 wkhtmltopdf-amd64,无需 root 访问权限。
这就是我所做的:
从这里下载相关的静态二进制文件 v0.10.0: http://code .google.com/p/wkhtmltopdf/downloads/list
编辑:以上内容已移至此处
通过我的共享主机上的 ssh 输入以下内容:
然后,您的主机上将拥有二进制文件,并且无论它是否位于 /usr/bin/ 文件夹中,都可以运行它。 (或者至少我能够)
测试:
./
以确保万无一失。无论如何为我工作
I've managed to successfully install wkhtmltopdf-amd64 on my shared hosting account without root access.
Here's what i did:
Downloaded the relevant static binary v0.10.0 from here: http://code.google.com/p/wkhtmltopdf/downloads/list
EDIT: The above has moved to here
via ssh on my shared host typed the following:
you'll then have the binary on your host and will be able to run it regardless of if its in the /usr/bin/ folder or not. (or at least i was able to)
To test:
./
just to be sure.Worked for me anyway
如果您有 sudo 访问权限...
Ubuntu 14.04 / 15.04 / 18.04:
其他
查看其他答案。
If you have
sudo
access...Ubuntu 14.04 / 15.04 / 18.04:
Others
Look at the other answers.
如果是 ubuntu,则继续执行此操作,已经测试过。:--
首先,
安装64 位操作系统的依赖项
为 32 位操作系统
If its ubuntu then go ahead with this, already tested.:--
first, installing dependencies
for 64bits OS
for 32bits OS
CentOS 最新更新:
sudo yum install -y libpng libjpeg openssl icu libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
wget https://github.com/ wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
code>sudo mv wkhtmltox/bin/* /usr/local/bin/
wkhtmltopdf -V
rm -rf wkhtmltox
rm -f wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
Latest update for CentOS:
sudo yum install -y libpng libjpeg openssl icu libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo mv wkhtmltox/bin/* /usr/local/bin/
wkhtmltopdf -V
rm -rf wkhtmltox
rm -f wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
Debian 8 杰西
这有效
sudo apt-get install wkhtmltopdf
Debian 8 Jessie
This works
sudo apt-get install wkhtmltopdf
如果没有完全访问此服务器(由于是托管帐户),您很可能会遇到问题。我什至可以说,我认为这是徒劳的努力——他们必须有充分的理由将服务器锁定在托管环境中。
致电您的托管公司并向他们提出安装请求,但不要指望得到好的答复 - 他们通常不会为单个用户安装非常自定义的项目,除非有充分的理由(例如错误修复)。
最后,根据您对服务器管理的熟悉程度以及您为服务器托管支付的费用,现在考虑类似 http://www .slicehost.com。每月 20 美元将为您提供一个低级网络服务器(256 内存),您可以安装任何您想要的东西。但是,如果您正在运行多个站点或负载很重,则成本将会上升,因为您需要更大的服务器。
GL!
Chances are that without full access to this server (due to being a hosted account) you are going to have problems. I would go so far as to say that I think it is a fruitless endeavor--they have to lock servers down in hosted environments for good reason.
Call your hosting company and make the request to them to install it, but don't expect a good response--they typically won't install very custom items for single users unless there is a really good reason (bug fixes for example).
Lastly, depending on how familiar you are with server administration and what you are paying for server hosting now consider something like http://www.slicehost.com. $20 a month will get you a low grade web server (256 ram) and you can install anything you want. However, if you are running multiple sites or have heavy load the cost will go up as you need larger servers.
GL!
自从添加了最热门的答案以来,一些事情发生了变化。它们曾经对我有用,但现在不再那么有效了,所以我花了一些时间,为 Ubuntu 16.04 提出了以下解决方案。对于 Ubuntu 14.04,请参阅答案底部的评论。如果这不适用于共享主机,我们深表歉意,但这似乎是一般 wkhtmltopdf 安装说明的转到答案。
测试一下:
当前工作目录中现在应该有一个名为
google.pdf
的文件。这种方法从网站下载二进制文件,这意味着您可以使用最新版本,而不必依赖包管理器进行更新。
请注意,截至今天,我的解决方案包括此错误的临时修复。我意识到这个解决方案确实不太好,但希望它能很快被删除。 在阅读此答案时,请务必检查链接的 GitHub 问题的状态,看看是否仍然需要修复!
对于 Ubuntu 14.04,您将需要降级到不同版本的 libssl。您可以在此处查找版本。无论如何,在任何生产服务器上执行降级 libssl 之前,请务必考虑降级的影响。
我希望这对某人有帮助!
A few things have changed since the top answers were added. They used to work out for me, but not quite anymore, so I have been hacking around for a bit and came up with the following solution for Ubuntu 16.04. For Ubuntu 14.04, see the comment at the bottom of the answer. Apologies if this doesn't work for shared hosting, but it seems like this is the goto answer for wkhtmltopdf installation instructions in general.
Test it out:
You should now have a file named
google.pdf
in the current working directory.This approach downloads the binary from the website, meaning that you can use the latest version instead of relying on package managers to be updated.
Note that as of today, my solution includes a temporary fix to this bug. I realize that the solution is really not great, but hopefully it can be removed soon. Be sure to check the status of the linked GitHub issue to see if the fix is still necessary when you read this answer!
For Ubuntu 14.04, you will need to downgrade to a different version of libssl. You can find the versions here. Anyways, be sure to consider the implications of downgrading libssl before doing so on any production server.
I hope this helps someone!
将 wkhtmltopdf 可执行文件放在服务器上并对其进行 chmod +x。
创建一个可执行 shell 脚本wrapp.sh,其中包含:
下载该体系结构所需的共享对象并将它们放置在名为“lib”的文件夹中:
(其中一些是符号链接)
...然后您就可以开始了:
如果您遇到所有字符都出现方形等字体问题,请显式定义 TrueType 字体:
Place the wkhtmltopdf executable on the server and chmod it +x.
Create an executable shell script wrap.sh containing:
Download needed shared objects for that architecture and place them an a folder named "lib":
(some of them are symlinks)
… and you're ready to go:
If you experience font problems like squares for all the characters, define TrueType fonts explicitly:
wkhtmltopdf 稳定版本列表: http://wkhtmltopdf.org/downloads.html
在 Debian 8.2 上安装 wkhtmltopdf (杰西)x64:
List of stable versions wkhtmltopdf: http://wkhtmltopdf.org/downloads.html
Installing wkhtmltopdf on Debian 8.2 (jessie) x64:
共享主机没有 ssh 或 shell 访问权限?
我是这样做的;
这是 wkhtmltox-0.12.4_linux-generic-i386.tar.xz
宾果!就这样,你就有了。您应该能够生成 PDF 文件。
Shared hosting no ssh or shell access?
Here is how i did it;
which is wkhtmltox-0.12.4_linux-generic-i386.tar.xz
Bingo! there you have it. You should be able to generate PDF files.
尝试后,下面的命令对我有用
After trying, below command work for me
我在共享托管服务上安装 wkhtmltopdf 时也遇到了问题,没有 rpm、dnf、apt 或任何安装任何工具的工具,所以我升级到专用服务器并使用早期帖子中的知识进行安装,即
ssh 到新服务器
I also had a problem installing wkhtmltopdf on a shared hosting service with no rpm,dnf,apt or any tool to install anything with so instead I upgraded to a dedicated server and installed using knowledge found in earlier posts i.e.
ssh into new server
wkhtmltopdf 12.5 版本现在仅在其下载页面上列出 DEB 文件。作为一名 Mac 用户,对 linux 或 DEB 文件了解不多,我无法使用发布的解决方案。
此页面帮助我克服了下载 DEB 文件的已知问题:http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/
基本上我做了什么是:
然后我发现“exec”功能在我的主机上被禁用。因此,如果您使用 PHP 来运行它,请确保您可以专门运行“exec”。 “我可以运行 wkhtmltopdf 二进制文件吗”不够具体。我的错。
Version 12.5 of wkhtmltopdf only lists DEB files on their download page now. Being a mac user and not knowing much linux or what DEB files were I couldn't use the solutions posted.
This page helped me get past the knew twist of downloading a DEB file: http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/
Basically what I did was:
Then I found out that the 'exec' function was disabled on my host. So make sure you can specifically run 'exec' if you're using PHP to run this. "Can I run the wkhtmltopdf binary" isn't specific enough. My fault.