Epub export failed

When exporting EPUB files, I get message “Error: The export failed. See logs for more details.”

When I check the log file, following is the message

[Fri Jun 15 05:42:16.698234 2018] [:error] [pid 16738] [client 139.59.34.212:49310] PHP Warning: mkdir(): open_basedir restriction in effect. File() is not within the allowed path(s): (/home/admin/web/books.manarkeni.com/public_html:/home/admin/tmp) in /home/admin/web/books.manarkeni.com/public_html/wp-content/plugins/pressbooks/inc/modules/export/class-export.php on line 350,

open_basedir string: Limit the files that can be accessed by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off. When a script tries to access the filesystem, for example using include, or fopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to access it.

http://php.net/manual/en/ini.core.php#ini.open-basedir

Configure your server.

I did change the configuration and the problem still persists.

I could export the following files properly
PDF (for print)
PDF (for digital distribution)
XHTML
HTMLBook
Pressbooks XML
WordPress XML

But I get this error, when I export the following book type…
EPUB (for Nook, iBooks, Kobo etc.)
MOBI (for Kindle)
EPUB 3

Is it not all the exported files stored in single directory, if that is the case, how come some works and some does not work…

Because those modules require the ability to create a temporary directory using this function (in this location):

http://php.net/manual/en/function.sys-get-temp-dir.php

I am having some hard time to fix this…

When I export following I get the error message “Error: The export failed. See logs for more details.”
EPUB (for Nook, iBooks, Kobo etc.)
MOBI (for Kindle)
EPUB 3

When I check the log file…This is the error details in the log file

[:error] [pid 2320] [client 139.59.34.212:54324] PHP Warning: tempnam(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/home/admin/web/books.manarkeni.com/public_html:/home/admin/tmp) in /home/admin/web/books.manarkeni.com/public_html/wp-content/plugins/pressbooks/inc/modules/export/class-export.php on line 348, referer: http://books.manarkeni.com/avvaiyarkathai/wp-admin/admin.php?page=pb_export&export_error=true

When we check the server configuration, there is not any restriction for open_basedir. I am attaching you the basedir.stpl file content

This is the server configuration file content

root@cp:/usr/local/vesta/data/templates/web/apache2# less basedir.stpl
<VirtualHost %ip%:%web_ssl_port%>

ServerName %domain_idn%
%alias_string%
ServerAdmin %email%
DocumentRoot %sdocroot%
ScriptAlias /cgi-bin/ %home%/%user%/web/%domain%/cgi-bin/
Alias /vstats/ %home%/%user%/web/%domain%/stats/
Alias /error/ %home%/%user%/web/%domain%/document_errors/
#SuexecUserGroup %user% %group%
CustomLog /var/log/%web_system%/domains/%domain%.bytes bytes
CustomLog /var/log/%web_system%/domains/%domain%.log combined
ErrorLog /var/log/%web_system%/domains/%domain%.error.log
<Directory %sdocroot%>
    AllowOverride All
    SSLRequireSSL
    Options +Includes -Indexes +ExecCGI
    php_admin_value open_basedir %docroot%:%home%/%user%/tmp
    php_admin_value upload_tmp_dir %home%/%user%/tmp
    php_admin_value session.save_path %home%/%user%/tmp
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f info@%domain_idn%"
</Directory>
<Directory %home%/%user%/web/%domain%/stats>
    AllowOverride All
</Directory>
SSLEngine on
SSLVerifyClient none
SSLCertificateFile %ssl_crt%
SSLCertificateKeyFile %ssl_key%
%ssl_ca_str%SSLCertificateChainFile %ssl_ca%

<IfModule mod_ruid2.c>
    RMode config
    RUidGid %user% %group%
    RGroups www-data
</IfModule>
<IfModule itk.c>
    AssignUserID %user% %group%
</IfModule>

IncludeOptional %home%/%user%/conf/web/s%web_system%.%domain%.conf*

appreciate if you could guide with right solution.

That’s an Apache config. That’s the wrong config.

Find your php.ini file:

PHP: The configuration file - Manual

Check if you are in safe mode. Turn this off.

http://php.net/manual/en/features.safe-mode.php

Check if you are running Suhosin. Uninstall.

https://suhosin.org/stories/index.html

Look for all the other settings previously discussed and set the correctly.

Restart your webserver. Create a test.php file with <?php phpinfo(); ?> then go to http://yoursite/test.php to verify that your settings are correct. Rinse and repeat.

PHP: phpinfo - Manual

Regards,

EDIT: Seen php_admin_value open_basedir %docroot%:%home%/%user%/tmp after submit. See next posts.

If you want to override using an Apache config instead of modifying php.ini, read these documents:

PHP: How to change configuration settings - Manual
PHP: List of php.ini directives - Manual

Short version (although at this point I strongly recommend reading the docs I linked…)

Do:

php_value open_basedir none

Or change what you have and add :/tmp at the end. (where : is the seperator)

php_admin_value open_basedir %docroot%:%home%/%user%/tmp:/tmp

PS: I feel you are copy/pasting error messages, config files, but not actually reading them. Each line in an error message and a config file matters. They are supposed to be read, not ignored as blobs of mystery text…

In your last message you say:

"When we check the server configuration, there is not any restriction for open_basedir. "

!!BUT!!

The error message says:

Warning: tempnam(): open_basedir restriction in effect.

And your config says:

php_admin_value open_basedir %docroot%:%home%/%user%/tmp

So what you are saying is obviously wrong. Please pay more attention. It’s not the community’s responsibility to be your sysadmin?

Regards,

thank you @dac.chartrand for detailed guidance, I could fix this problem and it works fine.

1 Like