Wordpress構築メモ

  1. 構築メモ
  2. 参考リンク

構築メモ

トップディレクトリ(/var/www/html)の下にサブディレクトリを作成して、 そこにwordpressを構築する。

  1. MySQL (MariaDB) でwordpress用のDBを作成してパーミッションも適切に設定しておく
  2. "/var/www/html/ディレクトリ" にwordpressを展開してインストールする
  3. テーマAttitudeをインストールする
  4. /etc/httpd/conf.d/wordpress.conf を作成する
    <Directory "/var/www/html/ディレクトリ">
        AllowOverride All
    </Directory>
  5. "/var/www/html/ディレクトリ/.htaccess"を編集して、海外からの直接攻撃を防ぐ
    <Files ~ "^(wp-login\.php|xmlrpc\.php)$">
    Order deny,allow
    Deny from all
    allow from 1.0.16.0/20
    allow from 1.0.64.0/18
    allow from 1.1.64.0/18
    (途中省略)
    allow from 223.223.164.0/22
    allow from 223.223.208.0/21
    allow from 223.223.224.0/19
    </Files>
    
    # 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]
    </IfModule>
    
    # END WordPress
  6. "/var/www/html/ディレクトリ/wp-contents/attitude-child"を作成する
  7. 作成したディレクトリにstyle.cssを作成する
    /*
    Theme Name: attitude-child
    Template: attitude
    /*
    
    body, input, textarea {
            color: #777;
            font: 13px "メイリオ", "Meiryo", "Osaka", "ヒラギノ角ゴ Pro W3″, "Hiragino Kaku Gothic Pro", "MS Pゴシック", "MS PGothic", sans-serif;
            line-height: 20px;
            word-wrap: break-word;
    }
  8. 同じくfunctions.phpを作成する
    <?php
    
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array('parent-style')
        );
    }
    
    // Remove old copyright text
    add_action( 'init' , 'mh_remove_copy' , 15 );
    function mh_remove_copy() {
            remove_action( 'attitude_footer', 'attitude_footer_info', 30 );
    }
    
    // Add my own copyright text
    add_action( 'attitude_footer' , 'mh_footer_info' , 30 );
    function mh_footer_info() {
       $output = '<div class="copyright">'.'Copyright &copy; 2015 Abcdefg Hijklmn, all rights reserved.'.'</div><!-- .copyright -->';
       echo $output;
    }
  9. Wordpressの管理画面でパーマネントリンクの設定を変更して、index.phpが表示されないようにする。
  10. wp-config.phpに以下の行を追加して、ログイン画面ではTLS/SSLを強制するようにする。
  11. define('FORCE_SSL_ADMIN', true);


    最終更新日:2015/09/10

    ↑ トップページ