Closed8

KUSANAGIセットアップ

Hide(ひで)Hide(ひで)

kusanagiのec2にssh接続。
ユーザーはcentos。

はいった後に

sudo su

# yum update kusanagi -y
# yum --enablerepo=remi,remi-php56 update -y
# reboot

ここまで問題なし。

Hide(ひで)Hide(ひで)

作成されるディレクトリ

[root@ip-172-16-1-77 kusanagi_html]# ls -al
合計 4
drwxr-xr-x. 6 kusanagi kusanagi   66  8月 26 15:56 .
drwx-----x. 4 kusanagi kusanagi   95  8月 26 15:56 ..
drwxrwxrwx. 5 kusanagi kusanagi 4096  8月 26 15:56 DocumentRoot
drwxr-xr-x. 4 kusanagi kusanagi   32  8月 26 15:56 log
drwxr-xr-x. 2 kusanagi kusanagi   34  7月 21 09:53 settings
drwxr-xr-x. 2 kusanagi kusanagi   30  8月 26 15:56 tools

初期.htaccess

[root@ip-172-16-1-77 DocumentRoot]# cat .htaccess 
<Files ~ "^\.ht">
	Deny from all
</Files>

<Files wp-login.php>
	Order deny,allow
	Deny from all
	Allow from all
	#Allow from 127.0.0.1
	AuthType Basic
	AuthName "ENTER YOUR NAME & PASSWORD TO LOGIN"
	AuthUserFile /home/kusanagi/.htpasswd
	Require valid-user
	Satisfy any
</Files>

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	#RewriteRule Shibboleth.sso - [L]
	RewriteRule ^index\.php$ - [L]
	RewriteCond %{REQUEST_URI} !\.(gif|css|js|swf|jpeg|jpg|jpe|png|ico|swd|pdf|svg|eot|ttf|woff)$
	RewriteCond %{REQUEST_FILENAME} !-f
	#RewriteCond %{REQUEST_URI} !(^/Shibboleth.sso/)
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
</IfModule>

[root@ip-172-16-1-77 DocumentRoot]# 

初期nginx設定

[root@ip-172-16-1-77 conf.d]# cat kusanagi_html_http.conf 
#=======================================
# プロビジョニング時に設定したホスト名(FQDN)
#---------------------------------------

server {
	listen 80;
	server_name プロビジョニング時に設定したホスト名(FQDN);
	access_log  /home/kusanagi/kusanagi_html/log/nginx/access.log main;
	error_log   /home/kusanagi/kusanagi_html/log/nginx/error.log warn;

	# rewrite ^(.*)$ https://プロビジョニング時に設定したホスト名(FQDN)$uri permanent; # SSL ONLY
	charset UTF-8;
	client_max_body_size 16M;
	root  /home/kusanagi/kusanagi_html/DocumentRoot;
	index index.php index.html index.htm;

	location = /50x.html {
		return 403;
	}

	rewrite /wp-admin$ $scheme://$host$uri/ permanent;

	location / {
		try_files $uri $uri/ /index.php?$args;
		#include naxsi.d/wordpress/*.conf;
	}

	location = /favicon.ico {
		log_not_found off;
		access_log off;
	}

	location ~* /\.well-known {
		allow all;
	}

	location ~* /\. {
		deny all;
	}

	#include templates.d/shibd.conf;
	#include templates.d/multisite.conf;

	location ~* /(?:uploads|files)/.*\.php$ {
		deny all;
	}

	location ~* \.(jpg|jpeg|gif|png|css|js|swf|ico|pdf|svg|eot|ttf|woff|woff2|map)$ {
		expires 60d;
		access_log off;
	}

	location ~* \.(json)$ {
		access_log off;
	}

	location ~* /wp-login\.php|/wp-admin/((?!(admin-ajax\.php|images/)).)*$ {
		satisfy any;
		allow 0.0.0.0/0;
		allow 127.0.0.1;
		deny all;
		auth_basic "basic authentication";
		auth_basic_user_file  "/home/kusanagi/.htpasswd";
		location ~ [^/]\.php(/|$) {
			fastcgi_split_path_info ^(.+?\.php)(/.*)$;
			if (!-f $document_root$fastcgi_script_name) {
				return 404;
			}
			#include shib_fastcgi_params;
			#include shib_clear_headers;
			limit_req zone=one burst=10 nodelay;
			fastcgi_pass 127.0.0.1:9000;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
			fastcgi_buffers 256 128k;
			fastcgi_buffer_size 128k;
			fastcgi_intercept_errors on;
			fastcgi_read_timeout 120s;
			#include naxsi.d/wordpress/*.conf;
		}
		include conf.d/security.conf;
		#include naxsi.d/wordpress/*.conf;
	}

	location ~ [^/]\.php(/|$) {
		fastcgi_split_path_info ^(.+?\.php)(/.*)$;
		if (!-f $document_root$fastcgi_script_name) {
			return 404;
		}
		#include shib_fastcgi_params;
		#include shib_clear_headers;
		limit_req zone=one burst=10 nodelay;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_buffers 256 128k;
		fastcgi_buffer_size 128k;
		fastcgi_intercept_errors on;
		fastcgi_read_timeout 120s;

		set $do_not_cache 1; ## page cache
		set $device "pc";

		if ($request_method = POST) {
			set $do_not_cache 1;
		}

		if ($query_string != "") {
			set $do_not_cache 1;
		}

		if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
			set $do_not_cache 1;
		}

		if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
			set $do_not_cache 1;
		}

		if ($http_user_agent ~* " Android |\(iPad|Android; Tablet; .+Firefox") {
			set $device "tablet";
		}

		if ($http_user_agent ~* "Android .+ Mobile|\(iPhone|\(iPod|IEMobile|Android; Mobile; .+Firefox|Windows Phone") {
			set $device "smart";
		}

		fastcgi_cache        wpcache;
		fastcgi_cache_key    "$device:$request_method:$scheme://$host$request_uri";
		fastcgi_cache_valid  200 10m;
		fastcgi_no_cache     $do_not_cache;
		fastcgi_cache_bypass $do_not_cache;

		add_header X-F-Cache $upstream_cache_status;
		add_header X-Signature KUSANAGI;
		include conf.d/security.conf;
		#include naxsi.d/wordpress/*.conf;
	}

}
Hide(ひで)Hide(ひで)

プロビジョニング時にホスト名(FQDN)をEC2のパブリックIPに設定。
IPにアクセスするとnginxの502エラーになる。。

https://hacknote.jp/archives/38587/ を参考に。

/etc/php-fpm.d www.conf の以下がコメントアウトされていたのをはずしてみた。

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660

その後

kusanagi php-fpm

実行で動いた。

というか

kusanagi status

*** (active) php-fpm ***
というのが元から表示されていなかった。

kusanagi php-fpm

後はactiveになっていた。

Hide(ひで)Hide(ひで)

wordpress管理画面のプラグイン更新時のFTP情報について。
ホスト名とユーザー名は最初から入力されている。

FTPSはパスワードが違うと言われる。
FTPは最初に設定したやつで通る。

Hide(ひで)Hide(ひで)

wp-config.php

define('FS_METHOD', 'ftpext');
define('FTP_HOST', 'localhost');
define('FTP_USER', 'kusanagi');
#define('FTP_PASS', '*****');

定義されてるから、デフォルト値みたいにセットされてるのかな?

このスクラップは2022/10/26にクローズされました