apache 本地主机上的 jquery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2000147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jquery on localhost
提问by ace
I am using Linuxmint (= ubuntu linux 9.10)
I installed LAmp server which have apache,php mysql
and now i am trying to write jquery code
i made a file and it worked perfectly with this link : file:///var/www/jquery/jquery.html
but when i use this link, then it doesnt work anymore : http://localhost/jquery/jquery.html
我正在使用 Linuxmint(= ubuntu linux 9.10)我安装了具有 apache、php mysql 的 LAmp 服务器,现在我正在尝试编写 jquery 代码,我制作了一个文件,它与此链接完美配合:file:///var/www/ jquery/jquery.html
但是当我使用此链接时,它不再起作用:http://localhost/jquery/jquery.html
the file jquery.min.js is in the same folder and i already changed the src of it in source code to
文件 jquery.min.js 在同一个文件夹中,我已经在源代码中将它的 src 更改为
<script type="text/javascript" src="/var/www/jquery/jquery.min.js"></script><script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="/var/www/jquery/jquery.min.js"></script><script type="text/javascript" src="jquery.min.js"></script>
but none of them works (with localhost link) using firebug I saw these errors:
但是它们都没有使用 firebug 工作(使用 localhost 链接)我看到了这些错误:
- The requested URL /var/www/jquery/jquery.min.js was not found on this server.
- You don't have permission to access /jquery/jquery.min.js on this server.
- 在此服务器上找不到请求的 URL /var/www/jquery/jquery.min.js。
- 您无权访问此服务器上的 /jquery/jquery.min.js。
Apache/2.2.12 (Ubuntu) Server at localhost Port 80
本地主机端口 80 上的 Apache/2.2.12 (Ubuntu) 服务器
so what do I have to do to make it run?
那么我该怎么做才能让它运行?
回答by Victor Nicollet
The second approach should work, if the apache server has read access to file /var/www/jquery/jquery.min.js.
如果 apache 服务器对 file 具有读访问权限,则第二种方法应该有效/var/www/jquery/jquery.min.js。
回答by stefita
If apache's user is wwwrun and the group is www, do the following:
如果 apache 的用户是 wwwrun,组是 www,请执行以下操作:
chmod -R 0744 /var/www/
chown -R wwwrun:www /var/www/
This will ensure, that the apache user will have the rights to view, execute, etc. the files in your web-folder.
这将确保 apache 用户将有权查看、执行等。您的 web 文件夹中的文件。
回答by Benoit Vidis
You also need to make sure your Apache configuration allows you to serve js files.
您还需要确保您的 Apache 配置允许您提供 js 文件。
Try to access http://localhost/jquery/jquery.min.jsand see if you can get the file.
尝试访问http://localhost/jquery/jquery.min.js并查看是否可以获取文件。

