ubuntu中的php项目。正确的路径,但禁止访问

时间:2014-09-23 09:51:52

标签: php .htaccess ubuntu apache2

我试图在ubuntu 12.04中运行一个windows7 php项目。我给出了正确的路径,因为我从Web控制台看到,但没有使用css文件和其他文件。 Web控制台显示的错误如下:

GET http://192.168.1.3/webserver/css/myCSSfile.css [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/css/search.css [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/css/button.css [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/css/button2.css [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/js/resolutionfinder.js [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/js/changeInputValue.js [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/js/ajaxcalls.js [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/js/ajaxcalls.js [HTTP/1.1 403 Forbidden 0ms]
GET http://192.168.1.3/webserver/images/logo.jpg [HTTP/1.1 403 Forbidden 0ms]

有人告诉我,我必须检查.htaccess文件,以确保我允许访问css,js和images子目录,但我在ubuntu中实际上是新的,我对它有点困惑。如果有帮助我使用apache2。谢谢你的时间。

如果我写ps -ef |终端上的grep apache结果就是这个

root      1058     1  0 20:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  1067  1058  0 20:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  1068  1058  0 20:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  1070  1058  0 20:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  1072  1058  0 20:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2431  1058  0 20:33 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2432  1058  0 20:33 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2433  1058  0 20:33 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2464  1058  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2465  1058  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
www-data  2466  1058  0 20:35 ?        00:00:00 /usr/sbin/apache2 -k start
manos     2541  2485  0 20:36 pts/3    00:00:00 grep --color=auto apache

此外,如果我做cd cd / var / www然后ls -la 结果是这个

total 12
drwxr-xr-x  3 root root 4096 Sep  21 23:16 .
drwxr-xr-x 14 root root 4096 Sep  23 13:04 ..
drwxr-xr-x  8 root root 4096 Sep  23 20:35 webserver

2 个答案:

答案 0 :(得分:1)

这可能是由错误的文件权限引起的

Apache正在运行什么用户? 您可以使用(在终端中)进行检查:

ps -ef | grep apache   (could also be running as 'httpd')

它可能无法读取/写入项目文件。 检查

中的文件权限
cd /var/www   (or what directory you have)
ls -la

答案 1 :(得分:1)

正如Paul所说,根文件夹(/ var / www)中的权限与此命令有关,一切正常。

sudo chmod -R ugo+rw /var/www

命令解释: 权限细分如下:

u – user

g – group

o – other

'其他'条目是危险的,因为它有效地赋予每个人文件夹/文件的权限。您可以为文件或文件夹授予的权限是:

r – read

w – write

x – execute

使用-R开关很重要。如果SHARE目录中有许多子文件夹和文件,并且您希望将权限从父对象(包含文件夹)应用于子对象(子文件夹和文件),则必须使用 - R(递归)切换,所以相同的权限一直应用到父文件中包含的最深文件夹。

相关问题