이 코드를 수정하려고 하는데 오류가 발생하고 코드가 실행되지 않습니다. 또한 공용 IP를 사용하여 WordPress를 실행하고 싶습니다.
문제는 "chcon: 태그가 지정되지 않은 부분 컨텍스트를 적용할 수 없습니다"라는 오류가 발생하기 때문에 sudo chcon -t httpd_sys_rw_content_t /var/www/html/ -R을 실행할 수 없다는 것입니다.
두 번째 문제는 공인 IP를 사용하면http://xxxx/워드프레스브라우저의 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