Ferrets家的Wordpress

杂记

权限

CentOS下web服务器无法发送邮件的权限修复

2017年1月16日 by Ferrets Leave a Comment

不得不承认,不愧是服务器血统,这权限管理真的严格的,搭建好的owncloud报告没法发邮件,经过一番bing之后,找到了答案。

参考:http://stackoverflow.com/questions/25517281/swiftmailer-connection-could-not-be-established-with-host-smtp-gmail-com-conne

解决办法如下:

  1.  检查httpd_can_sendmail 是否设置为on
    getsebool httpd_can_sendmail
    • 如果返回的输出是 httpd_can_sendmail –> off , 运行
      setsebool -P httpd_can_sendmail 1
    • 如果你看到 httpd_can_sendmail –> on 那么跳到下一步
  2.  检查 httpd_can_network_connect 是否为on
    getsebool httpd_can_network_connect
    • 如果返回的输出是 httpd_can_network_connect –> off ,运行
      setsebool -P httpd_can_network_connect 1
    • 如果你看到 httpd_can_network_connect –> on 那么就跳到下一步
  3. 在服务器地址直接填ip而不是域名。

第三步感觉是另外的问题,而不是SELinux的权限阻止了邮件发送。

Posted in: 搭建服务 Tagged: Apache, CentOS, http, httpd_can_network_connect, httpd_can_sendmail, php, SELinux, smtp, web, 权限

CentOS用apache当web服务器时出现的权限问题

2016年12月10日 by Ferrets Leave a Comment

参考:https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/

一般的文件读写权限,所属用户和组这些先不讨论,毕竟这些相关的文档太多,也相对基础了点。这里记录的是CentOS种由SELinux引起的权限问题。

刚在家重新搭建了owncloud,这时候出现了一个非常诡异的权限问题,文件和文件夹的所有权都是apache(CentOS中默认的所属用户和用户组),但是访问owncloud的安装程序的时候却提示没有写权限。我试过用sudo切换到apache用户来执行touch创建文件,没问题,甚至写一个简易的php脚本来测试文件的读写,都没有遇到权限的问题,但是在使用浏览器访问的时候,php脚本就遇到了权限的问题。

经过一番Google,确定时SELinux的问题。

用ls -Z可以看到一些额外的属性,像这样

drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 application
-rw-r--r--. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 index.php
修复的办法是
# SELinux serve files off Apache, resursive
sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R
# Allow write only to specific dirs
sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R

httpd_sys_content_t – 允许apache读取文档
httpd_sys_rw_content_t – 允许apache读写文档
更加详细的标记说明,可以参考https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/sect-Managing_Confined_Services-The_Apache_HTTP_Server-Types.html

Posted in: 网络 Tagged: CentOS, permission, readwrite, Redhat, SELinux, 权限, 读写

搜索站点

日历

2022年 6月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 3月    

分类

  • Android
  • docker
  • Linux
  • OpenWrt
  • PHP
  • Proxmox
  • RaspberryPi
  • RouterOS
  • Windows
  • 吐槽
  • 搭建服务
  • 未分类
  • 生活
  • 网络

近期文章

  • Proxmox中LXC容器中docker调用宿主机的显卡加速
  • Linux上iptables端口触发拦截
  • 通过DHCP指定mtu
  • openwrt 国内镜像源
  • 为RDP启用显卡加速,提升远程桌面效果
  • 为proxmox启用intel核显的虚拟化
  • windows无法解析域名
  • 在openwrt路由上运行shairplay作为远程音箱
  • 建立私有docker镜像源
  • RouterOS上抵挡扫描的防火墙策略

友链

  • ntzyz's space
  • Openwrt中文论坛
  • SNGR
  • Trevikids行止由心
  • 煎蛋

归档

管理

  • 登录
  • 条目feed
  • 评论feed
  • WordPress.org

Copyright © 2022 Ferrets家的Wordpress.

Omega WordPress Theme by ThemeHall