![](/img/trans.png)
[英]Apache. How to move wp-config.php and wp-content outside from wordpress core?
[英]Config apache + PDFlib + wordpress
我在我的 apache 中安裝 PDFlib 以在我的 wordpress 應用程序中使用時遇到問題。
我跟着教程PHP
我還是做了下面的命令,因為我又想到了關於安裝的另一個疑問:
echo "katleia.com.br localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
它是 katleia.com.br/worpress 我放在瀏覽器上訪問我的頁面的路線。
但是,當我發出命令時:
service apache2 restart
這是下一個錯誤退出:
* Restarting web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
AH00526: Syntax error on line 1 of /etc/apache2/conf-enabled/fqdn.conf:
Invalid command 'katleia.com.br', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
有人可以幫我配置 PDFlib 嗎? 因為我花了大約四個小時試圖讓它在 wordpress 中工作並且沒有什么是正確的。
我已經通知不想安裝 wordpress 插件了。
更新
要撤消此命令:
echo "katleia.com.br katleia" | sudo tee /etc/apache2/conf-available/fqdn.conf
更新2
我設法讓他停止給出錯誤,但仍然不起作用。
我執行了以下命令以便能夠重新啟動服務器:
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf
sudo a2enconf fqdn
service apache2 restart
有了這個,我的服務器恢復了工作,我將此代碼添加到了一個 php 文件中,該文件以單擊按鈕進行測試命名:
try{
$pdf = new PDFlib();
} catch (Exception $e) {
echo "error: ".$e->getMessage()."<br>";
} finally {
// open a file
pdf_open_file($pdf, "test.pdf");
// start a new page (A4)
pdf_begin_page($pdf, 595, 842);
// get and use a font object
$arial = pdf_findfont($pdf, "Arial", "host", 1);
pdf_setfont($pdf, $arial, 10);
// print text
pdf_show_xy($pdf, "There are more things in heaven and earth, Horatio,",50, 750);
pdf_show_xy($pdf, "than are dreamt of in your philosophy", 50,730);
// end page
pdf_end_page($pdf);
// close and save file
pdf_close($pdf);
}
他沒有任何錯誤,但是當我嘗試該文件時找不到任何地方。
更新3
有這個命令理論上是為了得到一個顯示 PDFlib 正在運行的輸出,但是當我在我的提示下執行它時它沒有顯示任何內容:
# php -i |grep PDF
PDFlib
PDFlib Support => enabled
PDFlib GmbH Binary-Version => 7.0.5p3
我可以做這部分工作是忘記添加extension = pdf.so
文件/etc/php5/cli/php.ini
。 在我重新啟動 apache 后,他給出了預期的輸出。
但它仍然沒有出現在任何地方的test.pdf
。
更新4
try {
$p = new PDFlib();
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "hello.php");
$p->set_info("Author", "Rainer Schaaf");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
$p->continue_text("(says PHP)");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=teste_do_katleia.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:\n" .
"[" . $e->get_errnum() . "] " . $e->get_apiname() . ": " .
$e->get_errmsg() . "\n");
}
catch (Exception $e) {
die($e);
}
$p = 0;
$len = mb_strlen($buf, 'ASCII');
exit();
用上面的代碼可以生成pdf並在網站上查看,但這不是我想要的。 我想要的是將它保存在一個文件夾中,然后在另一個頁面上恢復。 有誰知道我必須更改此代碼才能做到這一點?
用上面的代碼可以生成pdf並在網站上查看,但這不是我想要的。 我想要的是將它保存在一個文件夾中
您應該檢查 begin_document() 之前行中的注釋:
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
此外,您應該查看PDFlib 7 教程,第 3.1.4 章“在內存中生成 PDF 文檔”以獲取更多詳細信息。
提示:在光盤上創建文件時,不能使用 get_buffer(),它從內存中獲取 PDF 數據。 (請參閱 API 參考,該參考也包含在您的 PDFlib 7 包中的 doc 目錄中)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.