php - JavaScript not working - apache2 + Ubuntu - Stack Overflow

Setup: Apache2.2.14 (Ubuntu) PHP5.3.2-1ubuntu4.7 with Suhosin-Patch configuredetcdebian_version sho

Setup: Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.7 with Suhosin-Patch configured

/etc/debian_version shows "squeeze/sid".

Copied a javascript ts_picker.js file to /usr/lib/cgi-bin (the configured CGI directory in apache conf files). All my PHP programs are in the same directory as well.

Tried running a simple PHP script which refers the ts_picker.js file within a <script src> tag in the <HEAD>.

But no javascript works. Apache error.log shows:

[Wed Apr 13 19:05:41 2011] [error] [client 10.0.0.37] (8)Exec format error: exec of '/usr/lib/cgi-bin/ts_picker.js' failed, referer: .php
[Wed Apr 13 19:05:41 2011] [error] [client 10.0.0.37] Premature end of script headers: ts_picker.js, referer: .php

Tried checking for permissions on the .js: they are 755, just as with all my PHP scripts.

Tried grepping 'javascript' and 'js' recursively under /etc/apache2 and found nothing except a DEFLATE entry:

/etc/apache2/mods-available/deflate.conf:          # AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
/etc/apache2/mods-enabled/deflate.conf:          # AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript

Additionally, if I open the source of the PHP's HTML output on the browser and if I click on the ts_picker.js link there, it shows a 500 Internal error.

I am really stuck at this point and unable to do much. Any help is much appreciated. Thanks in advance.

Setup: Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.7 with Suhosin-Patch configured

/etc/debian_version shows "squeeze/sid".

Copied a javascript ts_picker.js file to /usr/lib/cgi-bin (the configured CGI directory in apache conf files). All my PHP programs are in the same directory as well.

Tried running a simple PHP script which refers the ts_picker.js file within a <script src> tag in the <HEAD>.

But no javascript works. Apache error.log shows:

[Wed Apr 13 19:05:41 2011] [error] [client 10.0.0.37] (8)Exec format error: exec of '/usr/lib/cgi-bin/ts_picker.js' failed, referer: http://10.0.27.200/cgi-bin/js.php
[Wed Apr 13 19:05:41 2011] [error] [client 10.0.0.37] Premature end of script headers: ts_picker.js, referer: http://10.0.27.200/cgi-bin/js.php

Tried checking for permissions on the .js: they are 755, just as with all my PHP scripts.

Tried grepping 'javascript' and 'js' recursively under /etc/apache2 and found nothing except a DEFLATE entry:

/etc/apache2/mods-available/deflate.conf:          # AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
/etc/apache2/mods-enabled/deflate.conf:          # AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript

Additionally, if I open the source of the PHP's HTML output on the browser and if I click on the ts_picker.js link there, it shows a 500 Internal error.

I am really stuck at this point and unable to do much. Any help is much appreciated. Thanks in advance.

Share Improve this question edited Apr 13, 2011 at 14:47 Martijn 13.6k4 gold badges50 silver badges59 bronze badges asked Apr 13, 2011 at 14:13 KrishnaChaitanyaKrishnaChaitanya 111 gold badge1 silver badge2 bronze badges 1
  • 1 This belongs on serverfault.. This is a server configuration question, not a programming question. – Diodeus - James MacFarlane Commented Apr 13, 2011 at 14:29
Add a ment  | 

1 Answer 1

Reset to default 3

Javascript files are statically served assets - they are not executed by your webserver, but by the client browser. So they should not be set as executable, nor should they be in a scripts folder like /cgi-bin: as a result apache is trying to execute these js files when requested, as opposed to just serving them back. You need to move your js files to wherever static resources live, and set them to read-only.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744784130a4593519.html

相关推荐

  • php - JavaScript not working - apache2 + Ubuntu - Stack Overflow

    Setup: Apache2.2.14 (Ubuntu) PHP5.3.2-1ubuntu4.7 with Suhosin-Patch configuredetcdebian_version sho

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信