fopen(dbinfo.php):无法打开流:权限被拒绝,Ubuntu 12.04 LTS [英] fopen(dbinfo.php): failed to open stream: Permission denied Ubuntu 12.04 LTS

查看:155
本文介绍了fopen(dbinfo.php):无法打开流:权限被拒绝,Ubuntu 12.04 LTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在UBuntu上运行一个php项目.它具有一个用于创建mysql数据库的安装脚本. 当我尝试运行脚本时,出现以下错误:

I am trying to run a php project on UBuntu . It has an install script which creates the mysql database. When i try to run the script i am getting the following errors:

Warning: fopen(dbinfo.php): failed to open stream: Permission denied in /opt/lampp/htdocs/project/install.php on line 12

Warning: fwrite() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/project/install.php on line 19

Warning: fclose() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/project/install.php on line 20

Warning: include(dbinfo.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/project/install.php on line 21

Warning: include(): Failed opening 'dbinfo.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/project/install.php on line 21

Notice: Undefined variable: host in /opt/lampp/htdocs/project/install.php on line 23

Notice: Undefined variable: user in /opt/lampp/htdocs/project/install.php on line 23

Notice: Undefined variable: password in /opt/lampp/htdocs/project/install.php on line 23

Notice: Undefined variable: database in /opt/lampp/htdocs/project/install.php on line 25

Notice: Undefined variable: database in /opt/lampp/htdocs/project/install.php on line 26
Error connecting to database.

我知道这些错误是由于拒绝权限引起的,但是我不知道如何解决这个问题.该脚本没有编辑或创建数据库的权限.我是Ubuntu的新手,无法站稳脚跟问题.抱歉英语不好.

I know these errors are due to Permission denial.But i don't know how to resolve this.It seems the script does not have permission to edit or create a databse.I am new to Ubuntu and cannot get a stand of the problem.Sorry for the bad english.

推荐答案

我假设您的用户可能拥有/opt/lampp的权限,因此您可以编辑文件.但是,如果不是这种情况,则可以同时授予用户和apache组的访问权限.下一个显示的是第一个用户,然后是组:

I assume that maybe your user has rights over /opt/lampp and because of that you can edit the files. However, if that's not the case you can grant access to both, your user and the apache group. The next shows firs the user, then the group:

sudo chown -R youruser:www-data /opt/lampp

通过这种方式,您可以将所有权设置为用户,然后是组.之后,您必须授予对三个组的访问权限:用户,组和其他:

In that way you're setting the ownership to the user and then the group. After that you must grant the access for the three groups: User, group and others:

sudo chmod -R xxx /opt/lampp

注意:最右边是指文件所有者,组和其他用户的权限.

Note: The rightmost refer to permissions for the file owner, then the group and other users.

现在,xxx是什么意思?

Now, what does the xxx mean?

7-完整-111

6-读写-110

5-读取并执行-101

5 - read and execute - 101

4-只读-100

3-编写并执行-011

3 - write and execute - 011

2-只写-010

1-仅执行-001

1 - execute only - 001

0-无-000

或者您可以使用:

chmod [reference][operator][mode] fileOrFolder

引用为:u(ser),g(roup),o(thers)和a(ll).

Where the reference is: u(ser), g(roup), o(thers) and a(ll).

运算符为:+(将指定的模式添加到指定的引用中),-(删除)和=(必须将指定的模式设置为与指定的引用完全相同的模式)

The operator is: + (adds the specified modes to the specified references), - (removes) and = (the modes specified must be made the exact modes for the specified references)

最后,这些模式是:r(ead),w(rite),x(execute),[X(special execute),s和t(不太常见)].

Finally the modes are: r(ead), w(rite), x(execute), [X(special execute), s and t (that are not so common)].

希望这就是您想要的.

这篇关于fopen(dbinfo.php):无法打开流:权限被拒绝,Ubuntu 12.04 LTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆