AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 477635
Accepted
Antonio
Antonio
Asked: 2013-02-12 07:15:19 +0800 CST2013-02-12 07:15:19 +0800 CST 2013-02-12 07:15:19 +0800 CST

Selinux 在 CentOS 6.3 中阻止 wordpress

  • 772

我使用命令将 wordpress 3.5 安装到 CentOS 6.3:

yum install wordpress

并启动了 httpd。现在我可以在 apache 日志中看到以下错误:

PHP 致命错误:require_once(): 需要打开失败 '/usr/share/wordpress/wp-includes/class-simplepie.php' (include_path='.:/usr/share/pear:/usr/share/php')在第 4 行的 /usr/share/wordpress/wp-includes/class-feed.php 中,referer: http ://www.mycompany.com/wp-admin/

我想那是因为 SELinux:

ls -Z /usr/share/wordpress/wp-includes/class-simplepie.php 
lrwxrwxrwx. root root system_u:object_r:usr_t:s0 class-simplepie.php -> /usr/share/php/php-simplepie

ls -Z /usr/share/php/php-simplepie
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0 autoloader.php
drwxr-xr-x. root root unconfined_u:object_r:user_home_t:s0 SimplePie
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0 SimplePie.php

我想知道是否有办法让它在不禁用 SELinux 的情况下工作?

centos
  • 4 4 个回答
  • 2479 Views

4 个回答

  • Voted
  1. Michael Hampton
    2013-02-12T07:20:47+08:002013-02-12T07:20:47+08:00

    您的文件似乎有错误的 SELinux 安全上下文。当我安装php-simplepie包(它似乎来自 EPEL)并检查这些文件时,它们都具有usr_t类型,而不是user_home_t.

    尝试修复安全标签:

    restorecon -r -v /usr/share/php/php-simplepie
    
    • 2
  2. Jason Tan
    2013-02-12T07:39:39+08:002013-02-12T07:39:39+08:00

    如果您想验证它是 SElinux,请使用 setenforce 0 关闭 SE linux 或检查 audit.log。我认为它在 /var/log/audit/audit/log 中,但我不是 100% 确定。一旦您确定它是 SELinux,您就可以重新打开 SElinux。

    如果它是 SElinux 那么要做的事情就是使用semanage设置 selinux 策略,以便您的 PHP 内容所在的所有目录httpd_sys_rw_content_t

    semanage fcontext -a -t httpd_sys_rw_content_t  </path/to/php/dir>
    

    然后将该策略应用于restorecon目录及其子文件/目录:

    restorecon -R </path/to/php/dir>
    

    如果semanage/restorecon没有安装安装policycoreutils-python包。

    顺便说一句,如果你想查看策略中的默认文件上下文,你可以这样做:

    semanage fcontext -l
    

    但是它可能不是 SELinux。我相信大多数 redhat 发行版上开箱即用的 apache 不会遵循符号链接(尽管我认为你遇到了一个错误,说明在这种情况下不遵循符号链接),所以你可能需要添加:

    Options FollowSymLinks
    

    到 apache 配置并重新启动 apache。

    当然,它可能既是 selinux 又不是遵循符号链接。

    • 2
  3. flickerfly
    2015-07-17T14:46:22+08:002015-07-17T14:46:22+08:00

    这是我为我们的开发人员创建的一个小 shell 脚本。这样,每次他们推出 WordPress 时,他们就不必记住所有要做什么。您的文件结构几乎肯定有些不同,因此需要稍微修改一下。请随时提出改进建议。SELinux 不是我的专长,但我正在学习它。

    #!/bin/sh
    # License: Public Domain
    # satisfies SELinux context requirements for a WordPress site
    # To operate properly on CentOS, etc.
    
    #Figure out what directory to apply this to and strip any trailing /
    if [ -d $1 ]; then
     site=${1%/}
    else
     site=`pwd`
    fi 
    
    #Check to make sure the setting of $site is sane and fail if not
    if [ ! -d $site/httpdocs/wp-content ]; then
      echo "ERROR: This does not appear to be an appropriate directory." 
      echo ${site}
      echo "Please specify directory for the site like /var/www/html/myssite as the only argument"
      exit 1
    fi
    
    #For visual appeal mostly
    content=$site/httpdocs/wp-content
    
    #Setup the contexts 
    chcon -R -v -t public_content_rw_t $content/plugins/ $content/themes/ $content/uploads/ $site/logs/
    semanage fcontext -a -t httpd_sys_rw_content_t $site/httpdocs/
    semanage fcontext -a -t httpd_sys_rw_content_t $site/httpsdocs/
    semanage fcontext -a -t httpd_sys_rw_content_t $site/logs/
    
    #Apply the contexts 
    restorecon -R $site/logs/
    restorecon -R $site/httpdocs/
    restorecon -R $site/httpsdocs/
    
    • 1
  4. Best Answer
    Antonio
    2013-02-12T12:52:42+08:002013-02-12T12:52:42+08:00

    我发现这个问题是 EPEL 中的一个错误:

    1. https://bugzilla.redhat.com/show_bug.cgi?id=722591
    2. https://bugzilla.redhat.com/show_bug.cgi?id=695698
    • 0

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve