Question: Why does the following command line command:
wkhtmltopdf /path/to/html/input/file.html /path/to/pdf/output/file.pdf
work as expected when executed via Mac OSX Terminal but fail when executed via PHP's shell_exec() function via MAMP?
Answer: You need to comment out two lines of code within one of MAMP's configuration files.
Within MAMP's /Applications/MAMP/Library/bin/envvars file you'll notice the following two lines:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
Comment both of them out as demonstrated below (note the "#" prefix on each line):
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
Lastly, within the same file, add the following command to make sure the $PATH environment variable inherited by PHP from Apache includes the directory that contains your wkhtmltopdf executable. Your command will look something like:
export PATH=/parent/path/of/wkhtmltopdf/executable:$PATH
Looking for a cloud-based catalog and CRM platform? Checkout http://rocware.com/
Subscribe to:
Post Comments (Atom)
About Me
- John Erck
- I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.
Thanks a lot. You are a savior. I had this exact issue on my MAC which has MAMP and after a lot of searching and debugging I found your page. I have this same issue on my production machine which is having redhat and a normal Apache setup. No MAMP. Any insights as to how I can make it work there?
ReplyDeleteI'm glad my post helped you out. I didn't have any issues when deploying to my production machines running Debian Squeeze. If you figure out the solution though you should consider adding it as a comment to this post for other users experiencing the same issue you're facing. Thanks.
DeleteI was able to get it to work. It was a permissions issue. The SELinux firewall was not allowing apache to spawn a new process for the wkhtmltopdf binary. All I had to do was set the "httpd_execmem" boolean in SELinux to ON. You can do this by executing the command "setsebool httpd_execmem on" on your terminal.
ReplyDeleteman i could kiss you for this =)
ReplyDeleteWell researched article and I appreciate this. The blog is subscribed and will see new topics soon.
ReplyDeleteData Science training in Chennai
Data science online training
Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
ReplyDeleteBest Devops online Training
Online DevOps Certification Course - Gangboard
You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
ReplyDeleteData Science course in kalyan nagar
Data Science course in OMR
Data Science course in chennai
Data science course in velachery
Data science course in jaya nagar
Data Science interview questions and answers
Data science course in bangalore
I was taking a gander at some of your posts on this site and I consider this site is truly informational! Keep setting up digital marketing platforms
ReplyDeleteperde modelleri
ReplyDeleteMOBİL ONAY
Mobil odeme bozdurma
nft nasıl alınır
ankara evden eve nakliyat
trafik sigortası
dedektör
website kurma
ask kitaplari
SMM PANEL
ReplyDeletesmm panel
İsilanlariblog.com
instagram takipçi satın al
HİRDAVATCİ
BEYAZESYATEKNİKSERVİSİ.COM.TR
Servis
tiktok jeton hilesi indir
nft nasıl alınır
ReplyDeleteen son çıkan perde modelleri
en son çıkan perde modelleri
yurtdışı kargo
özel ambulans
uc satın al
minecraft premium
lisans satın al