How to install wkhtmltopdf on a linux based (shared hosting) web server

后端 未结 11 1704
刺人心
刺人心 2020-11-30 17:58

I have tried in all ways to get wkhtmltopdf installed on our web server but unfortunately it is not getting installed. I cannot access user/bin folder as st

相关标签:
11条回答
  • 2020-11-30 18:36

    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!

    0 讨论(0)
  • 2020-11-30 18:45

    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.

    # Install dependencies
    apt-get install libfontconfig \
        zlib1g \
        libfreetype6 \
        libxrender1 \
        libxext6 \
        libx11-6
    
    # TEMPORARY FIX! SEE: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001
    apt-get install libssl1.0.0=1.0.2g-1ubuntu4.8
    apt-get install libssl-dev=1.0.2g-1ubuntu4.8
    
    # Download, extract and move binary in place
    curl -L -o wkhtmltopdf.tar.xz https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    tar -xf wkhtmltopdf.tar.xz
    mv wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
    chmod +x /usr/local/bin/wkhtmltopdf
    

    Test it out:

    wkhtmltopdf http://www.google.com google.pdf
    

    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!

    0 讨论(0)
  • 2020-11-30 18:47

    If you have sudo access...

    Ubuntu 14.04 / 15.04 / 18.04:

    sudo apt-get install wkhtmltopdf
    # or
    sudo apt install wkhtmltopdf
    

    Others

    Look at the other answers.

    0 讨论(0)
  • 2020-11-30 18:50

    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:

    $ wget {relavant url to binary from link above}
    $ tar -xvf {filename of above wget'd file}
    

    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:

    $ ./wkhtmltopdf-amd64 http://www.example.com example.pdf
    
    • Note remember that if you're in the folder in which the executable is, you should probably preface it with ./ just to be sure.

    Worked for me anyway

    0 讨论(0)
  • 2020-11-30 18:56

    After trying, below command work for me

    cd ~
    yum install -y xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 openssl git-core fontconfig
    wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    mv wkhtmltox/bin/wkhtmlto* /usr/bin
    
    0 讨论(0)
  • 2020-11-30 18:57

    Debian 8 Jessie
    This works sudo apt-get install wkhtmltopdf

    0 讨论(0)
提交回复
热议问题