简体   繁体   English

Centos 上的 Apache 权限问题

[英]Permission problems with Apache on Centos

I've set up a LAMP machine with Centos, apache, MySQL and PHP 7.4.我已经用 Centos、apache、MySQL 和 PHP 7.4 设置了一台 LAMP 机器。

my user via ssh is mformisano , I'm able to login via SFTP with mformisano and browse folders.我通过 ssh 的用户是mformisano ,我可以使用mformisano通过 SFTP 登录并浏览文件夹。 It's an intranet machine, so we are not so severe on restrictions, but, if I type the address into the browser I can execute PHP files, but these files are not able to extract files, create files, etc into the var/www/html folder.它是内网机器,所以我们对限制没有那么严格,但是,如果我在浏览器中输入地址,我可以执行 PHP 文件,但是这些文件无法提取文件,创建文件var/www/html文件夹。

Actually the www folder is:实际上www文件夹是:

drwxr-s---.  4 apache apache   31 29 ott 22.34 www

inside:里面:

drwxr-xr-x. 21 root   root   4096 29 ott 22.34 ..
drwxr-x---.  2 apache apache    6 19 ott 15.54 cgi-bin
drwxrwxr-x+  3 apache apache 4096  2 nov 10.49 HTML

If I give permission to mformisano , I can browse via FTP, PHP is executed.如果我允许mformisano ,我可以通过 FTP 浏览,执行 PHP。 If I give permission to apache:apache I cannot browse, PHP is executed.如果我授予apache:apache我无法浏览的权限,则执行 PHP。 If I give permission to mformisano:apache I can browse, PHP is executed.如果我允许mformisano:apache我可以浏览,则执行 PHP。 If I give permission to mformisano:mformisano I can browse, PHP is not executed.如果我允许mformisano:mformisano我可以浏览,则不会执行 PHP。

I do need to both browse and execute PHP, so mformisano:apache should be the right way, but when I execute kickstart.php (a WordPress plugin that extracts a .jpa archive) this is not extracting and give me an error about writing permissions.我确实需要浏览和执行 PHP,所以mformisano:apache应该是正确的方法,但是当我执行 kickstart.php(一个提取 .jpa 存档的 WordPress 插件)时,这不是提取并给我一个关于写入权限的错误.

What am I doing wrong?我究竟做错了什么?

The PHP files are going to be parsed by Apache. PHP 文件将由 Apache 解析。 Typically Apache will be running under the user www-data, in any case find out what user Apache is running under and give the appropriate permissions to the user that apache is running as.通常,Apache 将在用户 www-data 下运行,无论如何都要找出 Apache 正在运行的用户,并为运行 apache 的用户授予适当的权限。 If you are a single person running the sever I would recommend SFTP login as root user, this will give you permissions to modify whatever you want on the server, but remember to change the owner and groups for any files you create as root user before logging out.如果您是一个人运行服务器,我建议您以 root 用户身份登录 SFTP,这将使您有权在服务器上修改您想要的任何内容,但请记住在登录之前更改您以 root 用户身份创建的任何文件的所有者和组出去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM