centos7 wordpress5.2.2 配置FTP,安装中文语言包,插件,主题
在安装Wordpress时遇到不少问题,比如官方中文站点下载wordpress安装包,安装出来后还是英文。并且wordpress连不上站点的FTP,安装不了插件、主题。
按照官方给出的办法:
1、通过FTP、SSH等方式打开并编辑站点根目录下的wp-config.php文件。
查找define('WPLANG', '');一行,在第二个参数处填入zh_CN,变成define('WPLANG', zh_CN');并保存文件。
2、进入站点控制板(dashboard),看到更新提示后进行升级即可。WordPress会自动从官方网站下载中文语言包并安装。

一切照做,填写上传WordPress的FTP地址、账号,又改了设置里面的语言,结果还是不行出现:
ERROR: There was an error connecting to the server, Please verify the settings are correct.后来想到是不是SElinux的问题,于是把SElinux暂时设置成宽容模式:
setenforce 0最后升级成功!
这只是临时设置,当系统重启后,又连接不上ftp了,想要一劳永逸,还需要分析SElinux限制的原因:
需要用到两个服务auditd和setroubleshootd
如果没有安装,直接yum安装:
yum -y install audit* setroubleshoot*它们都会整合在auditd中,所以直接启动auditd就行了。
其中auditd,centos7 应该是默认安装了,可以先检查下状态:
systemctl status auditd没启动需要重启,这里必须用这种方式,用systemctl 启动不了:
service auditd restart然后开始检查问题:
cat /var/log/messages | grep setroubleshoot出现:
/var/log/messages:Jun 26 09:06:34 jslxx setroubleshoot: SELinux is preventing php-fpm from name_connect access on the tcp_socket port 21. For complete SELinux messages run: sealert -l f7111197-f9e6-4667-a6dc-c08c70f7685d关键在最后一句,执行它就进行SElinux限制的原因分析:
sealert -l f7111197-f9e6-4667-a6dc-c08c70f7685d也可以直接用sealert命令分析,它写在另外一个日志,两种分析效果是一样的:
sealert -a /var/log/audit/audit.log出现了分析结果:
SELinux is preventing php-fpm from name_connect access on the tcp_socket port 21.
***** 插件 catchall_boolean (24.7 置信度) 建议 ************************************
If you want to allow httpd to can network connect
Then 必须启用 'httpd_can_network_connect' 布尔值告知 SELinux 此情况。
Do
setsebool -P httpd_can_network_connect 1
***** 插件 catchall_boolean (24.7 置信度) 建议 ************************************
If you want to allow httpd to can network relay
Then 必须启用 'httpd_can_network_relay' 布尔值告知 SELinux 此情况。
Do
setsebool -P httpd_can_network_relay 1
***** 插件 catchall_boolean (24.7 置信度) 建议 ************************************
If you want to allow httpd to can connect ftp
Then 必须启用 'httpd_can_connect_ftp' 布尔值告知 SELinux 此情况。
Do
setsebool -P httpd_can_connect_ftp 1
***** 插件 catchall_boolean (24.7 置信度) 建议 ************************************
If you want to allow nis to enabled
Then 必须启用 'nis_enabled' 布尔值告知 SELinux 此情况。
Do
setsebool -P nis_enabled 1
***** 插件 catchall (3.53 置信度) 建议 ********************************************
If you believe that php-fpm should be allowed name_connect access on the port 21 tcp_socket by default.
Then 应该将这个情况作为 bug 报告。
可以生成本地策略模块以允许此访问。
Do
allow this access for now by executing:
# ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm
# semodule -i my-phpfpm.pp
更多信息:
源环境 (Context) system_u:system_r:httpd_t:s0
目标环境 system_u:object_r:ftp_port_t:s0
目标对象 port 21 [ tcp_socket ]
源 php-fpm
源路径 php-fpm
端口 21
主机 jslxx
源 RPM 软件包
目标 RPM 软件包
策略 RPM selinux-policy-3.13.1-229.el7_6.12.noarch
Selinux 已启用 True
策略类型 targeted
强制模式 Enforcing
主机名 jslxx
平台 Linux jslxx 5.1.3-1.el7.elrepo.x86_64 #1 SMP Thu
May 16 17:49:50 EDT 2019 x86_64 x86_64
警报计数 11出现了3个可能,置信度都在24.7%,仔细回顾下出错原因,还真是httpd连接网络和FTP的问题。
于是照做:
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_relay 1
setsebool -P httpd_can_connect_ftp 1我只运行了第一个setsebool -P httpd_can_network_connect 1,问题就解决了,后面后面两个为了免得以后又出什么奇怪的问题,也可以执行!

同时,插件、主题都能通过连上FTP安装了!
















