Ich habe eine EC2-Instanz mit dem Amazon Linux-Image eingerichtet und LAMP und Wordpress gemäß den Amazon-Dokumenten installiert.
Es funktioniert einwandfrei, dient der Standardseite Wordpress, aber sobald die Instanz neu gestartet wird, scheint der Webserver nicht mehr zu funktionieren. Die Indexseite wird nicht mehr geliefert. Curling localhost kehrt leer zurück.
Ich bin nicht sicher, welche Konfiguration beim Neustart verloren geht. Apache und MYSQL werden ausgeführt und sind so eingerichtet, dass sie beim Start ausgeführt werden.
Wenn ich es mit curl http://localhost
versuche und mir das Apache-Zugriffsprotokoll ansehe, sehe ich:
::1 - - [17/Jun/2017:00:56:26 +0000] "GET / HTTP/1.1" 301 350 "-" "curl/7.35.0"
::1 - - [17/Jun/2017:00:59:19 +0000] "GET / HTTP/1.1" 301 350 "-" "curl/7.35.0"
::1 - - [17/Jun/2017:00:59:21 +0000] "GET / HTTP/1.1" 301 350 "-" "curl/7.35.0"
Hier ist meine httpd.conf
ServerRoot "/etc/httpd"
Listen 80
Include conf.modules.d/*.conf
User Apache
Group Apache
ServerAdmin [email protected]
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
ErrorLog "logs/error_log"
LogLevel warn
<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
Antwort-Header von curl -v
[[email protected] ~]$ curl -v localhost
* Rebuilt URL to: localhost/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 17 Jun 2017 23:46:00 GMT
< Server: Apache/2.4.7 (Ubuntu)
< X-Powered-By: PHP/5.5.9-1ubuntu4.21
< X-Pingback: http://ec2-x-x-x-x.x-x-2.x.amazonaws.com/xmlrpc.php
< Location: http://ec2-x-x-x-x.x-x-2.x.amazonaws.com
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Curl_http_done: called premature == 0
* Connection #0 to Host localhost left intact
Ich habe das Problem herausgefunden. Beim Neustart einer AWS-Instanz ändert sich die DNS-Adresse. Da ich Wordpress verwende, muss ich die URL siteurl
und home
in der MySQL-Datenbank für die Site wordpress auf die neue DNS-Adresse aktualisieren.
In den folgenden Bildern sollte beispielsweise localhost durch die DNS-Adresse der Instanz ersetzt werden. Wenn die Instanz neu gestartet wird, muss diese bei jedem Neustart der Instanz durch die neue DNS-Adresse usw. ersetzt werden. Eigentlich hätte ich eine statische DNS-Adresse verwenden sollen, um mir den Schmerz dieses Problems zu ersparen :)