How to set JS source directory in apache2?

7,198

Because you are using ScriptAlias, it is treating everything in that directory like a CGI script. What you'll want to use instead is Alias:

Alias /lib "/SomeFolder/lib"

Andrew

Share:
7,198

Related videos on Youtube

highBandWidth
Author by

highBandWidth

Updated on September 17, 2022

Comments

  • highBandWidth
    highBandWidth over 1 year

    I am trying to run a very basic webserver for development/debugging. The static HTML seems to be delivered correctly, but it seems that the JavaScript libraries are not being delivered to the browser. The page HTML says something like

    <html>
    <head>
      <script type='text/javascript' src="/lib/json.js"></script>
    ...
    

    Now, I have set up a link for /lib/ in my httpd.conf as:

    Scriptalias /lib/ "/SomeFolder/lib/"
    

    When I do this, it can't fetch the files because this is what I see in my apache error log:

    ... [error] [client ::1] client denied by server configuration: /SomeFolder/lib/json.js, referer: http://localhost/SomeSite
    

    It seems that apache is not allowing access to the folder, so I add this to httpd.conf:

    <Directory "/SomeFolder/lib/">
        Allow from all
    </Directory>
    

    After this, browsing the page still does not run the JS, instead I see the following error in my apache error log:

    [error] [client ::1] (13)Permission denied: exec of '/SomeFolder/lib/json.js' failed, referer: http://localhost/SomeSite
    

    So now, it seems that apache is trying to run the JS files on the server like a cgi script or something. But I have not made that folder a cgi-bin folder. The only lines where SomeFolder is mentioned by name is in these lines in httpd.conf:

    Scriptalias /lib/ "/SomeFolder/lib/"
    <Directory "/SomeFolder/lib/">
        Allow from all
    </Directory>