AWSLinux

AWS EC2 Amazon Linux 2 AMI 2.0インスタンス PHP.ini 日本語 Mailなど初期設定 WordPress

1 Mins read

Amazon Linux 2 AMI 2.0.20181008 x86_64 HVM gp2
Apache 2.4.39
PHP 7.3.6

メール送信するだけならこの設定だけで対応できると思います。中継及びメール受信を考慮していないのでAWSのセキュリティ[In]に25、587の穴を開ける必要もありません。
AWSのVPC内から大量のメール送信や受信を目指す場合、AWSへのメール解除申請など結構な労力を取られます。現時点の情報では24時間200通、1秒に1通まで制限がかからないので管理メールなどの使用意図であれば問題ないでしょう。

mtx確認

# インストールされているmtx確認コマンド 
alternatives --display mta

mta -ステータスは自動です。
リンクは現在 /usr/sbin/sendmail.postfix を指しています。

sendmail.postfixがインストールされていると思いますがない場合はyumなどでインストールする

PHP.ini

; ポートを587へ
smtp_port=587

; mtxパス&コマンド設定
sendmail_path = /usr/sbin/sendmail.postfix -t -i

; 標準文字コード
default_charset = UTF-8

; mbstringデフォルト
mbstring.language = Japanese
; HTTP入力文字のエンコーディングを内部文字のエンコーディングに自動変換しない

mbstring.encoding_translation = Off

; 文字コード自動検出する際の優先順位
mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII

; タイムゾーンを日本標準時間
date.timezone = Asia/Tokyo

; セキュリテイ向上、PHPのバージョン情報を非表示
expose_php = Off
Related posts
LinuxPHPWordpressパソコンのこと

Wordpress "mixed content the page at ' url ' was loaded over https" nginx reverse proxy

1 Mins read

Nginx のリバースプロキシ環境において、フロントエンドの Nginx が 443 (HTTPS) でリクエストを受け付け、内部では 80 (HTTP) でラウンドロビン方式の負荷分散を行っている場合、Chrome で Mixed Content エラー が発生することがあります。

この問題を解決するために、wp-config.php の冒頭に以下の設定を追加すると効果的です。

/** mixed content the page at ' url ' was loaded over https wordpress nginx */
/** プロキシ設定の場合、httpsでリダイレクトするように設定が必要! */
/** HTTP_X_FORWARDED_FOR の環境変数名はAWSなどお使いのサーバー環境により若干変更されている時があるので要確認すること */
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $_SERVER['HTTPS'] = 'on';
}

内部では 80 (HTTP)側の nginx.conf ファイルを操作できる方は、以下の設定でも対応可能です。

どちらかお好みでOK

location ~ \.php$ {
    include fastcgi_params;

    # mixed content the page at ' url ' was loaded over https wordpress nginx
    # プロキシ設定の場合、httpsでリダイレクトするように設定が必要!ここから
    fastcgi_param HTTPS on;
    fastcgi_param HTTP_X_FORWARDED_PROTO https;
    # ここまで

    fastcgi_intercept_errors on;
    fastcgi_pass php-fpm;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
LinuxmacOSRubyパソコンのこと

Rails 7.0.8.7 Updateで起動エラー "Logger::Severity.constants.each do |severity|"

1 Mins read

Ruby 3.2.6

Ruby on Rails 7.0.8.7

起動でこける

原因はgem

gem 'concurrent-ruby', '1.3.5'

Gemfileの末尾に追記して、しばらく固定にしておく

gem 'concurrent-ruby', '1.3.4'

追記したらインストール

bundle install

# Fetching concurrent-ruby 1.3.4 (was 1.3.5)
# Installing concurrent-ruby 1.3.4 (was 1.3.5)

以下ログ

# gem 'concurrent-ruby', '1.3.5' では以下エラーになるので'1.3.4'固定にしておく
#
# bundler: failed to load command: puma (/app-root/vendor/bundle/ruby/3.2.0/bin/puma)
# /app-root/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.7/lib/active_support/logger_thread_safe_level.rb:12:in `<module:LoggerThreadSafeLevel>': uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger (NameError)
#
# Logger::Severity.constants.each do |severity|
# ^^^^^^^^^^
AWSLinux

.htaccess IP制御 AWS ELB ロードバランサー環境

1 Mins read

Apache 2.4.39

[.htaccess] Or [httpd.conf]

# 0.0.0.0にアクセス許可のIPを設定する
# AWS ELB 用 管理画面アクセス制御
<location "/wp-admin">
  # 管理用IP
  SetEnvIf X-Forwarded-For "0.0.0.0.*" allowed_ip_admin
  SetEnvIf X-Forwarded-For "0.0.0.0.*" allowed_ip_admin
  Order Deny,Allow
  Deny from all
  Allow from env=allowed_ip_admin
</location>

チームを強化する

サービスの
サブスクリプションの利点を説明するテキストを追加します。