views:

96

answers:

2

Hello! I need to run inkscape in PHP so I can convert an svg image to PDF. However every time I try:

//some PHP code system("inkscape -z --file=svg.svg --export-pdf=pdf.pdf"); //more code

I get no new file and I get this in the apache erro log.

(inkscape:28607): libgnomevfs-WARNING **: Unable to create ~/.gnome2 directory: Permission > denied

Emergency save activated! Emergency save completed. Inkscape will close now. If you can reproduce this crash, please file a bug at www.inkscape.org with a detailed description of the steps leading to the crash, so we can fix it. ** Message: Error: Inkscape encountered an internal error and will close now.

Segmentation fault

I am running on ubuntu with apache server. What can I do to correct this problem?

+2  A: 

This is related to system permissions, the easier way to fix is create a .gnome2 folder at root home folder of the user who's running that code and give it permissions to write (666 should be fine).

Note that if you're doing this by FTP folders/files starting with . (hidden files on linux), might not show up on listings depending on your client's config.

Rodrigo
The user that tries to run inkscape is www-data, the user who runs apache, I think. Any way, I believe the problem is that this user doesn't have a home folder, in fact the only home folder in the PC where the problem is happening is my home folder.Is it possible to create a home folder for www-data? would this resolve the problem? If yes, how can i create that folder?
petermlm
Assuming you're running this on apache, find out under what user the httpd process is running at top, then create the .gnome2 folder under that user, that will probably fix the issue. Usually apache runs under apache user and apache group, you may need to create a /home/apache/.gnome2, sounds unusual, but might work. Don't forget to chown.
Rodrigo
I can't get it to work. Isn't it possible to edit the sudoers file to get it to work.
petermlm
It worked! I created the directories: /var/www/.gnome2 /var/www/.config /var/www/.config/inkscape. And modified the owner of this directories with chown so that the owner would be www-data, the user that runs apache.Thank you very must!
petermlm
A: 

Inkscape is executed by the webserver-user normally www-data. The default setup that Ubuntu provides for www-data locates the home directory of www-data in /var/www.

Ther are two possibilities:

a) Changing the home directory of www-data to /home/www-data

b) Disable the VirtualHost in /var/www

In both cases you have to change the rights of ~www-data. First "chown" the directory to www-data:www-data and give them writing privileges.

Next time if you execute inkscape via PHP (as www-data user) the missing directories will be created.

senglert