## WeBWorK Main Forum

### Error when displaying static graphic images in problem sets

by Daniel An -
Number of replies: 19
Hello,

I am currently running a WeBWork server, upgraded from "WW2.7 (Ubuntu 12.04) livedvd" to WW2.9 and PG 2.9 and the latest OPL.

Somehow, after installation, all the static graphic image in the problem produce errors. For example, I tried:
Library/UMN/calculusStewartET/s_12_2_prob01/s_12_2_prob01.pg

and instead of showing the vector2.png, it shows the text:
\{

image("vector2.png",width=>400,height=>400,tex_size=>400)

\}

At the bottom of the page, I see Warning:

ERROR in old_safe_ev, PGbasicmacros.pl:

## There is an error occuring inside evaluation brackets \{ ...code... \}
## somewhere in an EV2 or EV3 or BEGIN_TEXT block.
## Code evaluated:
## image("$g1",width=>400,height=>400,tex_size=>400) ##Timeout after processing this problem for 60 seconds. Check for infinite loops in problem source. ## at line 1671 of [PG]/macros/PGbasicmacros.pl  I've updated both WeBWork and PG with 'git pull' command. There isn't any problem displaying equations or dynamically generated graphs. I put the server name on both site.conf and apache2.conf. Thank you. In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Danny Glin - Are you using lighttpd to serve static images? When I switched to lighttpd for static images, I ran into this same issue. Switching back to having apache serve everything solved it for me. I haven't had time to try to troubleshoot further. In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Arnold Pizer - Hi, Look at http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2641 for help in debugging this problem. Arnie In reply to Arnold Pizer ### Re: Error when displaying static graphic images in problem sets by Daniel An - Thank you Danny and Arnold, Danny: I actually tried to use lighttpd to see if this resolved the issue, because it happened before using lighttpd. Now I am not using it. I undid the wwtmp option (option A in thee installation guide) to see if that fixed it but it didn't. So it doesn't look like that's the problem. Arnold: My problem is not about latex, so latex .log file won't help me. It's just the static files included in the problem pg file. (I checked the pg file's directory to make sure that the .png files are there.) The screenshot looks like In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Davide Cervone - Is there anything useful in the server's error log? Sometimes there is additional information there that doesn't get shown in the WeBWorK page's error messages. In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Arnold Pizer - Hi Daniel, Just to be clear since the above image is from the library browser, do you get the same behavior looking at problems in a real course? Arnie In reply to Arnold Pizer ### Re: Error when displaying static graphic images in problem sets by Daniel An - Arnold: I tried it after seeing what you wrote, and the error occurs when working on the problem itself. So it's not the library. David: Thank you for your suggestion. I went to look at the apache2 error.log file and it tells me what's the problem. I see that everytime this error happens, in the log it says: Error opening file for reading: Permission denied several times. Could it be that there is some kind of firewall? The server actually has two ip addresses, one internal facing (that can be only accessed when the user is connected to in-school network) and another one outside facing. I can't write the internal ip address here, for security reasons, but outside school, the webwork url is: http://192.195.176.176/webwork2 Now, what's strange is that in the site.conf file, I have$server_root_url='http://localhost' and I thought changing this to $server_root_url='http://192.195.176.176' may fix it, but instead 'Add' buttons in the library browser stops working while the above mentioned error continues. So I have it back to$server_root_url='http://localhost'. I also tried to put
ServerName 192.195.176.176
in the apache2.conf file and nothing changed.

Since the apache2 error.log was showing that file access is denied, I checked the OPL directory to see if the permission settings are correct. The permissions are all set as 775, so permission settings are not a problem.

Another thing that I found which maybe related is when I go to the pg directory and type 'git show', I see:
Merge pull request #144 from mgage/master_IO_fix
Fix 'fileFromPath not defined or not exported' error
(My pg files are "Already up-to-date." according to 'git pull origin master' command.)

Could it be that the path names are wrong somehow?

So in summary I am suspicious of two things:
2. some internal setting that gives the wrong path name to the 'image()' function.

I tried everything I can think of so far. So if anyone has any leads, it would be greatly appreciated.

### Re: Error when displaying static graphic images in problem sets

by Hedley Pinsent -
Just a housekeeping note really:

The temporary files

The webwork temp folder is sometimes var/www/wwtmp

and there is the system /tmp location: make sure everybody can read and write to it and clean out old files; this one has caused me trouble before.

Both these are not in the webwork directories and can be overlooked in a "permissions" review.

hp

### Re: Error when displaying static graphic images in problem sets

by Debbie Yuster -
Just wanted to add an additional piece of information about the issue (Daniel An and I are colleagues): the images do get displayed in the PDF hardcopies of the sets, but they won't display when looking at the individual problems on the site. So clearly the image exists and is accessible under certain circumstances, just not all.

I hope this helps you help us - thanks!

Debbie

### Re: Error when displaying static graphic images in problem sets

by Danny Glin -
If I recall correctly, the difference between displaying the image on-screen and printing it in the hardcopy is that the screen version creates a symbolic link to the image file in a web-accessible directory, while the hardcopy just embeds the image itself.

Based on this, it looks like the link creation is failing, which from Daniel's log file looks to be based on a permissions issue.

In my experience obscure permission issues are usually a result of SElinux.  I find that it is best to just disable SElinux completely, unless you are willing to learn the paradigm that it uses for security.

Alternatively, the issue may just be that apache is unable to write to the course html directory.  The easiest way to fix this is to re-run the permission statements in the installation manual.

Danny

### Re: Error when displaying static graphic images in problem sets

by Daniel An -
Sorry, I am back with the same issue.
My IT department was going through an audit and they blocked the ssh port for a while, so I wasn't able to follow through the suggestions.

1.I checked that the SElinux was disabled.
2. I re-applied the permission settings listed in the installation manual.
3. I made /var/www/wwtmp as 777 and checked that the system tmp could be written by anyone.

But still the problem persists. Static images in the problem fails to show. The pdf file shows the picture, and that's what we are asking the students to do for the time being.

The current operating system is still ubuntu 12.04 LTS version - updated to the latest because of the shellshock bug.

I am pasting apache restart log, just in case if you notice something strange:
$sudo apache2ctl graceful webwork.apache2-config: WeBWorK server is starting webwork.apache2-config: WeBWorK root directory set to /opt/webwork/webwork2 in webwork2/conf/webwork.apache2-config webwork.apache2-config: The following locations and urls are set in webwork2/co nf/site.conf webwork.apache2-config: PG root directory set to /opt/webwork/pg webwork.apache2-config: WeBWorK server userID is www-data webwork.apache2-config: WeBWorK server groupID is wwdata webwork.apache2-config: The webwork url on this site is http://localhost/webwork2 WebworkSOAP::WSDL: webwork_directory set to /opt/webwork/webwork2 via$WeBWorK::
Constants::WEBWORK_DIRECTORY set in webwork.apache2-config
WebworkSOAP::WSDL: rpc_url set to http://localhost/webwork2_rpc
WebworkWebservice: webwork_directory set to /opt/webwork/webwork2 via $WeBWorK:: Constants::WEBWORK_DIRECTORY set in webwork.apache2-config webwork.apache2-config: WeBWorK server is starting webwork.apache2-config: WeBWorK root directory set to /opt/webwork/webwork2 in webwork2/conf/webwork.apache2-config webwork.apache2-config: The following locations and urls are set in webwork2/co nf/site.conf webwork.apache2-config: PG root directory set to /opt/webwork/pg webwork.apache2-config: WeBWorK server userID is www-data webwork.apache2-config: WeBWorK server groupID is wwdata webwork.apache2-config: The webwork url on this site is http://localhost/webwork2 Localize.pm: Full path for the localization directory set to |/opt/webwork/webwo rk2/lib/WeBWorK/Localize| WebworkSOAP::WSDL: webwork_directory set to /opt/webwork/webwork2 via$WeBWorK::
Constants::WEBWORK_DIRECTORY set in webwork.apache2-config
WebworkSOAP::WSDL: rpc_url set to http://localhost/webwork2_rpc
WebworkWebservice: webwork_directory set to /opt/webwork/webwork2 via $WeBWorK:: Constants::WEBWORK_DIRECTORY set in webwork.apache2-config Thank you! Dan In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Michael Gage - Sorry to get in on this a little late. I agree with Danny's assessment -- the alias/link from the temporary directory to the static image is not being created, or is not created correctly. It could be that the directory path to the temporary directory or the url address of this temporary directory is incorrect. You can get more information by inserting \{alias("vector2.png")\} in your problem. Alias will print out the url that is being used to import the picture. (Alias is used inside of the image macro.) You should be able to look for the link inside your temporary directory if you have command line access. Verify that it is created and links to the correct place. You should also be able to access this link directly from your browser. Use these methods to trouble shoot the problem. In reply to Daniel An ### Re: Error when displaying static graphic images in problem sets by Ben Markham - We are experiencing exactly the same issue with a new install of version 2.10 on a virtual server. I've followed the thread and repeated the process indicated. Was there a final solution to this particular issue? Would anyone like to share? Thanks! Ben In reply to Ben Markham ### Re: Error when displaying static graphic images in problem sets by Michael Gage - Try my suggestion of inserting \{alias("filename.png")\} in the problem. Then see if you can reach that url from a browser. I expect it will hang. It could be because the alias for the .png file isn't created or it might be because the url being created is incorrect ( in that case check site.conf to make sure that you have properly set the basic site url. ) Or a firewall could cause this problem. The timeout infinite loop warning is probably misleading -- what I think is happening is that there is an internal check to see if the url can be reached and that check is simply hanging -- neither succeeding or failing. In reply to Michael Gage ### Re: Error when displaying static graphic images in problem sets by Ben Markham - Inserting \{ alias("filename.png") \} using the real image file name seems to point to the proper location on the file system. Here's the result below highlighted in red. You mention trying to reach the location with a browser. Should I be seeing a complete URL listed? -------------- (1 point) local/ContribDir/ITCC/MATH123/setSection_07_Homework/QRSection7Q24/QRSection7Q24.pg According to AAA ('Triple' A), the median amount that Americans spent over the 2012 Labor Day Holiday was$775.00. Consider the pie chart below.

\{

image("QRSection7Q24_1.png", width => 500, height => 500, tex_size => 700, extra_html_tags => 'alt= "Pie Chart of Spending"')

\} /wwtmp/MATH123-DEV-BMARKHAM/img/7e409448-5043-39c8-87aa-dff0b3982c10___af104928-6d52-3641-b655-1acb7ec2c51a.png

-----------------

Sorry for the questions, but WeBWork is new to us. So we're just getting the feel for it as we simultaneously roll it out across the entire college system. Nothing like jumping straight into the deep end...

Thanks!

Ben

### Re: Error when displaying static graphic images in problem sets

by Michael Gage -
I think perhaps you should see a complete url, particularly if you are using lighttpd or an alternate port to serve images.

and see if you can see the image.

also look at site.conf and see if you have:
 \$server_root_url = ''; # e.g. 'http://webwork.yourschool.edu' or 'http://localhost' # Note, if running a secure (ssl) server, you probably need 'https://...'

if that variable is initialized to blank as it is in the site.conf.dist file (and above)
-- you need to fill in server root url

### Re: Error when displaying static graphic images in problem sets

by Ben Markham -
Thanks so much for the help. We've finally resolved our issue. We did have the server root url listed; however,our distribution was installed in phases by several different people. Going back through the installation logs, I found that the internal server name didn't match the external DNS entry. Once, we set host, hostname, and apache all to the same external server name images began to display as expected.

Details are important...no matter how small.

Ben

### Re: Error when displaying static graphic images in problem sets

by Michael Gage -
Thanks for reporting back the resolution.

### Re: Error when displaying static graphic images in problem sets

by Daniel An -
Thank you for the suggestion. My IT staff is currently working to fix this problem.
I have a question. There is a NAT that translates the public ip address into internal ip address. It looks like if we only use internal ip address the problem does not occur. Once we put the server into the DMZ so that it can be accessed from outside, the problem occurs again. It looks like the static image url is resolved using the name of the server, not the url listed in the site.conf file. I don't have much knowledge about networking so this is my best attempt at explaining it. Can anyone review the script for loading static image to see if it uses the site.conf's url, instead of server name?
Thank you.