
Это сложный вопрос для поиска в Google или даже для заголовка.
Я могу успешно запустить свой сайт Wordpress, используя это:
Но это не срабатывает:
Если вы попытаетесь зайти на домен с этого адреса, вы увидите синюю веб-страницу с логотипом DigitalOcean, изображением акулы и следующей ошибкой: «Войдите в свой сервер через SSH, чтобы настроить установку LAMP».
У меня есть дроплет DigitalOcean, работающий под управлением Ubuntu 16.04 с Apache 2 и несколькими доменами. На одном из доменов находится сайт Wordpress, перенесенный с другого хоста. Домен настроен так же, как и все мои другие домены, включая сертификат, установленный через letsencrypt.
Я не думаю, что проблема в сертификате. Я думаю, что проблема в Wordpress, потому что другие сайты на моем сервере работают нормально во всех 4 условиях (http:// и https:// и www и без www)
Вот мой (анонимный) файл .conf:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/example>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xh$
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
а вот моя папка .htaccess внутри /var/www/example
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#test
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END WordPress
а вот мои настройки DNS, вставленные и анонимизированные:
CNAME
ftp.example.com is an alias of example.com.
A
example.com directs to 159.65.36.136
CNAME
www.example.com is an alias of example.com.
NS
example.com directs to ns1.digitalocean.com.
NS
example.com directs to ns2.digitalocean.com.
NS
example.com directs to ns3.digitalocean.com.
и вот мой вывод apache2ctl -S
VirtualHost configuration:
*:443 is a NameVirtualHost
default server othersite1.com (/etc/apache2/sites-enabled/othersite1.com-le-ssl.conf:2)
port 443 namevhost othersite1.com (/etc/apache2/sites-enabled/othersite1.com-le-ssl.conf:2)
alias www.othersite1.com
port 443 namevhost othersite2.co (/etc/apache2/sites-enabled/othersite2.co-le-ssl.conf:2)
alias www.othersite2.co
port 443 namevhost example.com (/etc/apache2/sites-enabled/example.com-le-ssl.conf:2)
alias www.example.com
port 443 namevhost othersite3.com (/etc/apache2/sites-enabled/othersite3.com-le-ssl.conf:2)
alias www.othersite3.com
port 443 namevhost othersite4.com (/etc/apache2/sites-enabled/othersite4.com-le-ssl.conf:2)
alias www.othersite4.com
port 443 namevhost othersite5.net (/etc/apache2/sites-enabled/othersite5.net-le-ssl.conf:2)
alias www.othersite5.net
port 443 namevhost othersite6.com (/etc/apache2/sites-enabled/othersite6.com-le-ssl.conf:2)
alias www.othersite6.com
*:80 is a NameVirtualHost
default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost othersite1.com (/etc/apache2/sites-enabled/othersite1.com.conf:1)
alias www.othersite1.com
port 80 namevhost othersite2.co (/etc/apache2/sites-enabled/othersite2.co.conf:1)
alias www.othersite2.co
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
alias www.example.com
port 80 namevhost othersite3.com (/etc/apache2/sites-enabled/othersite3.com.conf:1)
alias www.othersite3.com
port 80 namevhost othersite4.com (/etc/apache2/sites-enabled/othersite4.com.conf:1)
alias www.othersite4.com
port 80 namevhost othersite5.net (/etc/apache2/sites-enabled/othersite5.net.conf:1)
alias www.othersite5.net
port 80 namevhost othersite6.com (/etc/apache2/sites-enabled/othersite6.com.conf:1)
alias www.othersite6.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
решение1
Возможность №1
Похоже, ваш VirtualHost по умолчанию для *:80
, используя файл конфигурации, 000-default.conf
соответствует namevhost example.com
в верхней части вывода... ;
VirtualHost configuration:
default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)
тогда как вы хотите, чтобы здесь это совпадало;
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
alias www.example.com
Вероятно, происходит следующее: страница с текстом «Войдите в свой сервер через SSH, чтобы настроить установку LAMP» — это содержимое по умолчанию из /var/www/html
.
Поэтому я бы попробовал удалить /etc/apache2/sites-enabled/000-default.conf
и убедиться, что example.com
соответствует правильному VHost.
Возможность №2
Проверьте свои настройки в wp-config.php
, они должны совпадать с тем, на что в конечном итоге указывают ваши перенаправления;
define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');
Иногда это приводит к проблемам с WordPress, когда он не соответствует тому, что хочет Apache.
Дальнейшее устранение неполадок
Другое дело, что вы вставили конфигурацию дляhttp://example.com:80/сайт;
<VirtualHost *:80>
ServerName example.com
...
</VirtualHost>
Однако правило перезаписи, похоже, будет отклонять все запросы на https://
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Поэтому нам, вероятно, также потребуется увидеть конфигурацию https.
Кроме того, вам, вероятно, следует вставить вывод access.log и error.log, относящийся к одному конкретному запросу, чтобы увидеть, какие перенаправления действительно произошли.
Кроме того, если вы по-прежнему не видите проблему, вы можете включить ведение журнала перезаписи;
LogLevel alert rewrite:trace3
а затем проследить журнал на предмет запросов;
tail -f error_log|fgrep '[rewrite:'