Tag Archives: zend

Javascript folder permission issue on Ubuntu, Zend

ubuntu and zend server

I recently deployed a Zend Framework site from my Windows Zend CE dev environment to the production Ubuntu 10.10 Zend CE server. Of course this task seems easy enough. Sure, the folder structure is different, but this should be easy as pie and work out of the box, right? Well not quite.

I copied my project to /var/www/myproject, added the my virtual hot to the httpd.conf file:

DocumentRoot /var/www/myproject/web_root 
SetEnv APPLICATION_ENV "development"

        AllowOverride All
        Order allow,deny
        Allow from all

After restarting apache2,

sudo service apache2 restart

my site was visible at http://localhost/ . Zend seemed to be working. CSS was loaded, images were displaying, however no JavaScript files were being loaded.
To debug, I right-clicked on the page and viewed the source to see if everything was inserting correcly with $this->headScript()->.

From the source page, I was able to click on the css path in:

	

which took me to and opened the css file. Great! So it is loading the CSS, as expexted.

So then I clicked on the JavaScript file:


which then took me to a 404 page, stating:
The requested URL /javascript/ipm/imageflow/js/imageflow.packed.js was not found on this server.

Strange, that folder and file is there, just as the css. I am able to access http://localhost/css and view the contents and access files.
I am not allowed to access http://localhost/javascript as I get a You don’t have permission to access /javascript/ on this server.

So, I don’t have the permission? I checked the folder permissions and every thing is correct. What can it be??
Solution
Strangely enough, Google only turned out 1 result pertaining to a similar issue. Link
The user states that he is using a .htaccess file to rewrite the url (this is was Zend Framework project does).
He can access everything except the http://domain.com/javascript/ folder

Below a commenter reveals a bug related to Debian (Ubuntu is based on Debian). Link

Basically there is a “javascript” library located at “/etc/javascript-common/” on Debian/Ubuntu. In the configuration file, there is a GLOBAL Alias “/javascript” that overrides my web server folder, http://localhost/javascript”. Kinda stupid, since ‘javascript’ folders are common in websites and applications. And to be honest, i usually put them in a ‘js’ folder, however as per a requirement, ‘javascript’ was the name of the folder.

2 Solutions:
#1 Change your website’s javascript folder to something other that ‘javascript’ and update your code, or

#2 Change the Alias in the javascript-common.conf file from /javascript to /javascriptlib

I chose the latter, since I did not want to mess with my code base.

sudo vi /etc/javascript-common/javascript-common.conf

Change:

Alias /javascript /usr/share/javascript/

To:

Alias /javascriptlib /usr/share/javascript/

Then restart apache:

sudo service apache2 restart

Navigate to your page or directly to the ‘javascript’ folder and you should now have access. 🙂

Oh, what a night. My pain your gain!