如何修复此错误:HTTP ERROR 500 和 chcon:无法将部分上下文应用于 WordPress 的未标记文件

如何修复此错误:HTTP ERROR 500 和 chcon:无法将部分上下文应用于 WordPress 的未标记文件

我正在尝试更正这段代码,但出现错误并且代码未执行。我也想使用公共 IP 来运行 WordPress。

问题是我无法运行 sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R 因为我收到错误“chcon:无法将部分上下文应用于未标记”

第二个问题是,如果我使用公共IPhttp://xxxx/wordpress对于浏览器中的 WordPress 实例,我收到 HTTP 错误 500。我的 WordPress 文件位于 /var/www/html 目录中,并且我的 Apache 正在运行。

错误:

aws_instance.wp (remote-exec): Failed to restart service\x0d.service: Unit not found.
aws_instance.wp (remote-exec): --2020-08-19 13:04:52--  https://wordpress.org/latest.tar.gz%0D
aws_instance.wp (remote-exec): Resolving wordpress.org (wordpress.org)... 198.143.164.252
aws_instance.wp (remote-exec): Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
aws_instance.wp (remote-exec): HTTP request sent, awaiting response... 400 Bad Request
aws_instance.wp (remote-exec): 2020-08-19 13:04:52 ERROR 400: Bad Request.

aws_instance.wp (remote-exec): tar: latest.tar.gz\r: Cannot open: No such file or directory
aws_instance.wp (remote-exec): tar: Error is not recoverable: exiting now
aws_instance.wp (remote-exec): mv: cannot stat ‘wordpress/*’: No such file or directory
aws_instance.wp (remote-exec): chown: cannot access ‘/var/www/html/\r’: No such file or directory
aws_instance.wp (remote-exec): chcon: invalid option -- '
aws_instance.wp (remote-exec): '
aws_instance.wp (remote-exec): Try 'chcon --help' for more information.
aws_instance.wp (remote-exec): sed: can't read /etc/selinux/config
aws_instance.wp (remote-exec): : No such file or directory
aws_instance.wp (remote-exec): setenforce: SELinux is disabled
aws_instance.wp: Creation complete after 58s [id=i-0068d9c9935666018]

我正在使用下面的代码:

#!/bin/bash#Update yum
sudo yum -y update
sudo yum -y install httpd
sudo systemctl enable httpd service
sudo systemctl start httpd service
sudo yum install wget -y
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php56
sudo yum install -y php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
sudo systemctl restart httpd service
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xvf latest.tar.gz
sudo rm -rf latest.tar.gz
sudo rm -rf /var/www/html/*
sudo mv wordpress/* /var/www/html/
sudo rm -rf wordpress
sudo chown -R apache:apache /var/www/html/
sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R
sudo sed -i s/^SELINUX=.*$/SELINUX=permissive/ /etc/selinux/config
sudo setenforce 0
sudo systemctl restart httpd.service

相关内容