質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

VMware

VMwareとは、 ハードウェアで動作するOS上で仮想マシンを作成、実行するソフトウェアです。 Windows上でUNIX系OSを動作させたり、他のOS上で別の仮想OSを動作することが可能です。

Q&A

解決済

3回答

2871閲覧

httpsでwordpressにアクセスできない

wangzj

総合スコア53

Ubuntu

Ubuntuは、Debian GNU/Linuxを基盤としたフリーのオペレーティングシステムです。

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

VMware

VMwareとは、 ハードウェアで動作するOS上で仮想マシンを作成、実行するソフトウェアです。 Windows上でUNIX系OSを動作させたり、他のOS上で別の仮想OSを動作することが可能です。

0グッド

0クリップ

投稿2020/05/26 09:48

編集2020/05/27 05:19

前提・実現したいこと

Azureにubuntu VMを構築して、wordpressをインストールしました。
http://13.71.0.00でサイトを見えます。
「設定」>「一般」でwordpressのアクセスURLをhttpsに変えました。
https://13.71.0.00でサイトを見えなくなっています。

httpでアクセスできるように戻りたいです。
復旧できる方法をご指導ください。

発生している問題・エラーメッセージ

Failed to connect to 13.71.**.** port 443: Connection refused

試したこと

1.受信規則に443を公開している
2.さらに、下記のように443公開を追加した

  sudo iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT   sudo iptables-save | sudo tee /etc/iptables.rules   cd /etc/network/if-pre-up.d/   sudo vi iptables_start     #!/bin/sh     /sbin/iptables-restore < /etc/iptables.rules     exit 0   sudo chmod a+x /etc/network/if-pre-up.d/iptables_start   reboot

3./etc/apache2/site-available/001-wordpress.confに下記を追加

<VirtualHost *:443> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/wordpress <Directory "/var/www/wordpress"> Options FollowSymLinks # .htaccess による設定変更を許可 AllowOverride All DirectoryIndex index.php Order allow,deny Allow from all </Directory> # wp-config.phpへのアクセスをすべて拒否します。 <Files wp-config.php> order allow,deny deny from all </Files> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost>

4./etc/apache2/ports.conf

# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default.conf Listen 80 <IfModule ssl_module> Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

CHERRY

2020/05/26 10:31

SSL 証明書は、どのように取得してセットアップされたのでしょうか?
wangzj

2020/05/26 10:34

SSL証明書はまだ設定してないです。
guest

回答3

0

SSL証明書はまだ設定してないです。

https 設定すると Web サーバーが SSL証明書を必要とするので、SSL 証明書を設定していない場合は、アクセスできなくなります。


wp option update home 'http://11.11.11.10&#039;
wp option update siteurl 'http://11.11.11.10&#039;

を実行した結果は、どうだったのでしょうか?
アクセスできなかったのでしょうか。

また、 wp コマンドは、変更したい WordPress のディレクトリで実行されましたか? ( wp-config.php があるディレクトリ )


以下、一般的な修正方法を...

WordPress の「サイトURL」と「WordPress アドレス」を間違えて変更したのであれば、下記の方法 (方法1 又は 方法2)で修正できないでしょうか?

方法1)

functions.php の編集 してデータベースを書き換える

お使いのテーマの functions.php の1行目の <?php の次の行に下記を記載する

update_option( 'siteurl', 'http://example.com' ); update_option( 'home', 'http://example.com' );

http://example.com の部分は、ご自身のWordPress の正しい URL を記載する。

方法2)

wp-config.php の編集 して、wp-config.php に下記を記載する。

define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');

http://example.com の部分は、ご自身のWordPress の正しい URL を記載する。

方法3)

リロケート・メソッド」を使う

方法4)

データベースで URL を直接編集する


あたりを参照

投稿2020/05/27 05:12

CHERRY

総合スコア25171

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

wangzj

2020/05/27 05:33

ご回答ありがとうございます。 助かりました。 すでに解決しました。
guest

0

自己解決

1.まず、httpsからhttpに復旧する方法
WordPress アドレス (URL)、サイトアドレス (URL)、両方とも、誤ってhttpsに設定してしまったので、画面経由でURLの復旧には不可能です。
https://www.liquidweb.com/kb/install-wp-cli/
wpをインストールして、wpコマンドでURLを変えました。

wp option update home 'http://11.11.*.*'; wp option update siteurl 'http://11.11.*.*';

これで画面アクセスは可能になります。

2.wordpressのSSL化対応について
これは、いろいろ調べました。
まず、自分の環境を明確にします。
こちらの環境:ubuntu16、LAMP、wordpress
2.1.証明書を作成する
******.**は自分のドメイン

sudo apt-get install letsencrypt sudo service apache2 stop sudo letsencrypt certonly --standalone -d ****.** IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/****.**/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/****.**/privkey.pem Your cert will expire on 2020-08-25. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le sudo service apache2 start

2.2.Apacheの設定
証明書に関する設定

$ cd /etc/apache2/sites-available/ $ sudo nano default-ssl.conf SSL証明書関連は、下記のように記述。 SSLCertificateFile /etc/letsencrypt/live/****.**/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/****.**/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/****.**/fullchain.pem

httpsアクセスに関する設定

$ cd /etc/apache2/sites-available/ $ sudo nano 001-wordpress.conf

下記をファイルに追加

<IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin webmaster@localhost DocumentRoot /var/www/wordpress <Directory "/var/www/wordpress"> Options FollowSymLinks # .htaccess による設定変更を許可 AllowOverride All Order allow,deny Allow from all </Directory> <Files wp-config.php> order allow,deny deny from all </Files> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf # SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on # A self-signed (snakeoil) certificate can be created by installing # the ssl-cert package. See # /usr/share/doc/apache2/README.Debian.gz for more info. # If both key and certificate are stored in the same file, only the # SSLCertificateFile directive is needed. ##SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem ##SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLCertificateFile /etc/letsencrypt/live/****.**/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/****.**/privkey.pem # Server Certificate Chain: # Point SSLCertificateChainFile at a file containing the # concatenation of PEM encoded CA certificates which form the # certificate chain for the server certificate. Alternatively # the referenced file can be the same as SSLCertificateFile # when the CA certificates are directly appended to the server # certificate for convinience. #SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt SSLCertificateChainFile /etc/letsencrypt/live/****.**/fullchain.pem # Certificate Authority (CA): # Set the CA certificate verification path where to find CA # certificates for client authentication or alternatively one # huge file containing all of them (file must be PEM encoded) # Note: Inside SSLCACertificatePath you need hash symlinks # to point to the certificate files. Use the provided # Makefile to update the hash symlinks after changes. #SSLCACertificatePath /etc/ssl/certs/ #SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt # Certificate Revocation Lists (CRL): # Set the CA revocation path where to find CA CRLs for client # authentication or alternatively one huge file containing all # of them (file must be PEM encoded) # Note: Inside SSLCARevocationPath you need hash symlinks # to point to the certificate files. Use the provided # Makefile to update the hash symlinks after changes. #SSLCARevocationPath /etc/apache2/ssl.crl/ #SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl # Client Authentication (Type): # Client certificate verification type and depth. Types are # none, optional, require and optional_no_ca. Depth is a # number which specifies how deeply to verify the certificate # issuer chain before deciding the certificate is not valid. #SSLVerifyClient require #SSLVerifyDepth 10 # SSL Engine Options: # Set various options for the SSL engine. # o FakeBasicAuth: # Translate the client X.509 into a Basic Authorisation. This means that # the standard Auth/DBMAuth methods can be used for access control. The # user name is the `one line' version of the client's X.509 certificate. # Note that no password is obtained from the user. Every entry in the user # file needs this password: `xxj31ZMTZzkVA'. # o ExportCertData: # This exports two additional environment variables: SSL_CLIENT_CERT and # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the # server (always existing) and the client (only existing when client # authentication is used). This can be used to import the certificates # into CGI scripts. # o StdEnvVars: # This exports the standard SSL/TLS related `SSL_*' environment variables. # Per default this exportation is switched off for performance reasons, # because the extraction step is an expensive operation and is usually # useless for serving static content. So one usually enables the # exportation for CGI and SSI requests only. # o OptRenegotiate: # This enables optimized SSL connection renegotiation handling when SSL # directives are used in per-directory context. #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire <FilesMatch ".(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> </VirtualHost> </IfModule>

2.3.設定の確認後、SSLモジュールとバーチャルホストの有効化

$ sudo a2enmod ssl $ sudo a2ensite default-ssl $ sudo apache2ctl configtest $ sudo service apache2 restart

2.4.WordPressの管理画面からURLを変更する
管理ユーザでログインし、設定→一般設定 のURLを “https” に変更し保存。

2.5.[.htaccess]にリダイレクト用のコードを追記
http でのアクセス要求を、https にリダイレクト(転送)するように、WordPressのドキュメントルートの.htaccess ファイルを編集。

$ sudo nano /var/www/wordpress/.htaccess 下記内容を、先頭部分に追加。 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=on [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>

2.6.もう一回SSLモジュールとバーチャルホストの有効化(2.3.と同じ)

投稿2020/05/27 05:18

編集2020/05/27 05:30
wangzj

総合スコア53

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

http://13.71.0.00/wp-admin
など、管理画面には引き続きhttpでアクセスできると思います。
管理画面の「設定」>「一般」にて、「http」に戻してみてください。

投稿2020/05/26 13:24

new1ro

総合スコア4528

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

new1ro

2020/05/27 04:26

すみません「0」が2つになっていました。1つだとどうでしょうか? http://13.71.0.0/wp-admin ---------------- また別案として WordPressでデータベースの置換を行う場合 (サイトの移管、開発環境→本番環境への適用時、ドメイン変更時など)、「Search Replace DB」というツールをよく使うので使えるかもしれません。 https://wheelchair-coder.com/281/ https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
wangzj

2020/05/27 05:02

0.0はIPの省略です。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問