wordpress 管理画面が重たい



$ top   ←メモリ使用量
 mysql
 php-fpm ← 複数ある

mysql> show variables like 'table_definition_cache';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| table_definition_cache | 1400  |
+------------------------+-------+

mysql> show variables like 'performance_schema';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| performance_schema | ON    |
+--------------------+-------+

# vi /etc/my.cnf

[mysql.d]
# 以下を追記
table_definition_cache = 400
performance_schema = 0

#vi /etc/php-fpm.d/www.cnf

pm = static
pm.max_children = 2
pm.max_requests = 500

# service php-fpm restart

https://autovice.jp/articles/104

モーダルを閉じさせない、コードを書いて開く、コードで閉じる(Bootstrap)



  $('#nameModalCenter').on('hide.bs.modal', function (e) {
     // 閉じられる前のイベント、XでCloseとBackDropもこれでキャッチできる

  $('#name_modal_close').click( function() {
    // これは閉じない
    return false;

  jQuery(document).on('click', '#name_modal_close', function() {
    // これは閉じる(というか、閉じてからここに来る)
    return false;


jQueryでモーダルを開く



 $('#nameModalCenter').modal();//modalを出す


都道府県 / 州 / 郡 woocommerce

翻訳ファイルの修正

WooCommerceの日本語ファイル
/wp-content/languages/plugins/woocommerce-ja.mo

woocommerce-ja.po が編集用のファイルなので、このファイルをダウンロード

翻訳ファイルの編集ソフト「Poedit」 をインストール
書き換え後に ファイル MOにコンパイル → woocommerce-ja.mo をアップして上書き

laravel8 クエリービルダー サブクエリ 複数条件 算術演算 groupBy複数 orderBy DESC混在 生のSQL chank


    サブクエリ
    変数はたいていグローバル化しないと渡せない

    $ranks_tags = DB::table('ranks_tags')->where('label',$this->range_w);

        DB::table('post_tags as p')->select(
            DB::raw(   //この中の''は1セット。最初と最後のみで全体を囲む
            'p.fave_id , p.tag_id, f.name , f.cnt_cheer , s.before_cnt_cheer
            , f.cnt_cheer - s.before_cnt_cheer AS incre_cheer 
            , f.cnt_post, s.before_cnt_post
            , f.cnt_post - s.before_cnt_post AS incre_post
            , cnt_share
            , s.id as ranktag_id'
            )
        )
        ->LeftJoin( 'tags as t' , 'p.tag_id' ,'t.id')
        ->LeftJoin( 'faves as f', 'p.fave_id','f.id')
        ->LeftJoinSub($ranks_tags, 's', function ($join) {
            $join->on('s.tag_id' , 'p.tag_id' );
            $join->on('p.fave_id' , 's.fave_id');
        })
        ->groupBy('p.tag_id' , 'p.fave_id' , 'incre_cheer' , 'ranktag_id' )
        ->orderBy('p.tag_id' ,'asc')
        ->orderBy('incre_cheer' ,'DESC')
        ->orderBy('cnt_post' ,'DESC')
        ->limit(999999)
        // ->toSql(); ←素のSQL文を書き出せる
        ->chunk( $this->max_lows, function ($tag_fave) {
            foreach ($tag_fave as $key => $row) {
                // DB::table('tags')
                //     ->where('id', $tags->id)
                //     ->update(['created_at' => $this->ranges['day']]);
                var_dump($key, $row );
							
			}
            return false; //← これで終わる
		});

linux command よく使うやつ (centos)

書き換えてからコピーできる

特定の文字列含むファイルを検索するコマンド

特定の文字列含むファイルを拡張子指定で検索するコマンド

ディレクトリ(strage)を除外して特定の文字列(admin)含むファイルを拡張子指定で検索するコマンド

現在実行されているプロセスを知る

サブディレクトリ以下の特定ファイルを一括して削除する


ファイル名で指定ディレクトリ以下を検索

日付で検索する (10日以内に編集)

ディレクトリを除外して日付で検索する (3日以内に編集)

更新日順に表示する

更新日順にディレクトリを除外して表示する

  • find -type f はファイルのみを対象とする
  • find -print0 は検出されたファイルのフルパスをNULLキャラクターで分割して出力する
  • xargs -0 もしくは xargs --null 入力ストリームの分割はNULLキャラクターを用いる
 
特定の日に更新したファイルを見つける
 find . -type f -name "*.php" -newermt "2020-09-25"

管理者:グループの変更

一括変更

パーミッション変更

ファイル移動 、名前変更

コピー A to B

viエディタに行番号


全てのphpが755に、htmlは644になる

ローカルのファイルをリモートにアップロード
# -a オプションでアスキー転送 (デフォルトはバイナリ転送)

FTPserver : ftp.exzample.daa.jp
FTP account : daa.jp-user

php.ini すべてのエラーを表示する

   検索する
	/display_errors
   470行目くらい  OffをOnに変える
	display_errors = On

apache再起動

ubuntu18 ポートスキャン
20-83のあいだの開いているポートを探す


 nc -vz localhost 20-83 2>&1|grep succeeded

wsl2 Apache バーチャルホスト設定

Windowsのhosts ファイルに追加

 
  172.25.29.190       sample.org

※↑ipアドレスはUbuntu起動時のもの、127。0。0.1 ではないことに注意



<VirtualHost *:80>
    ServerAdmin webmaster@sample.org
    ServerName sample.org
    ServerAlias sample.org
    DocumentRoot /var/www/web/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
   <Directory /var/www/web/public>
        AllowOverride All
        Options All
        Require all granted
    </Directory>
</VirtualHost>