LoginSignup
0
1

More than 5 years have passed since last update.

WordPressのセットアップ手順

Last updated at Posted at 2016-07-07

はじめに

概要

  • WordPressとはブログシステム

公式サイト

セットアップ

  • データベース作成
    • ローカル開発環境 or VPSでMySQLにログインし、DB作成
[ ~]$ mysql -u root -p
Enter password:

mysql> create database dotinstall_wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> grant all on dotinstall_wordpress.* to dbuser@localhost identified by '42Uwxf2';
Query OK, 0 rows affected (0.00 sec)
  • WordPressインストール

  • サンプルファイルを元に設定する

$ :~$ cd wordpress/
$ :~/wordpress$ cp wp-config-sample.php wp-config.php

 28 /** WordPress のためのデータベース名 */
 29 define('DB_NAME', 'database_name_here');
 30
 31 /** MySQL データベースのユーザー名 */
 32 define('DB_USER', 'user_name');
 33
 34 /** MySQL データベースのパスワード */
 35 define('DB_PASSWORD', 'password_here');

 ↓

 28 /** WordPress のためのデータベース名 */
 29 define('DB_NAME', 'dotinstall_wordpress');
 30
 31 /** MySQL データベースのユーザー名 */
 32 define('DB_USER', 'dbuser');
 33
 34 /** MySQL データベースのパスワード */
 35 define('DB_PASSWORD', '42Uwxf2');
  • セキュリティのためのキー設定

    55 define('AUTH_KEY',         'put your unique phrase here');
    56 define('SECURE_AUTH_KEY',  'put your unique phrase here');
    57 define('LOGGED_IN_KEY',    'put your unique phrase here');
    58 define('NONCE_KEY',        'put your unique phrase here');
    59 define('AUTH_SALT',        'put your unique phrase here');
    60 define('SECURE_AUTH_SALT', 'put your unique phrase here');
    61 define('LOGGED_IN_SALT',   'put your unique phrase here');
    62 define('NONCE_SALT',       'put your unique phrase here');
    
  • ここまでできればWordPressのセットアップ画面を開けるはず
    スクリーンショット 2016-07-07 17.05.52.png

  • WordPressのセットアップ画面を開くまでに困ったこととその対処法

    • VirtualHostの設定を行っていたら、 まったくwordpressの画面を開いてくれなかった
      • いったん設定解除で対応
    • データベース確立エラーとの表示
      • wp-config.phpのユーザ名がDBの権限を与えたユーザ名になっていなかった

管理画面の使い方

  • パーマリンクの設定変更
    • .htaccessの変更をしろと言われるので、ファイルを作ってコピペ ※ うまく.htaccessくんが読み込めてなくて、記事ページがNotFoundになるので一旦設定解除
$ :~$ vim /var/www/html/wordpress/.htaccess

  1 <IfModule mod_rewrite.c>
  2 RewriteEngine On
  3 RewriteBase /wordpress/
  4 RewriteRule ^index\.php$ - [L]
  5 RewriteCond %{REQUEST_FILENAME} !-f
  6 RewriteCond %{REQUEST_FILENAME} !-d
  7 RewriteRule . /wordpress/index.php [L]
  8 </IfModule>

 304     AllowOverride None
 304     AllowOverride All
  • 画像をアップロードできるようにするには専用のフォルダを作り、パーミッションを変更する
$ :~$ mkdir /var/www/html/wordpress/wp-content/uploads

$ :~$ ll /var/www/html/wordpress/wp-content/
drwxrwxr-x 2 dotinstall dotinstall 4096  7月  7 17:40 2016 uploads

$ :~$ chmod 777 /var/www/html/wordpress/wp-content/uploads

$ :~$ ll /var/www/html/wordpress/wp-content/
drwxrwxrwx 2 dotinstall dotinstall 4096  7月  7 17:40 2016 uploads

基本的な使い方

  • 記事投稿
    • 表示オプションでスラッグを有効にする

その他

  • アクセスログの場所

    • httpd.confに記載されている内容を見てみる
    $ :/var/www/html/wordpress$ sudo cat /etc/httpd/conf/httpd.conf | grep 'access_log' | grep -v '^#'
    CustomLog logs/access_log combined
    
    • 相対パスしか書かれていない。このディレクトリはどこかというのはServerRootを見れば分かる
    $ :/var/www/html/wordpress$ sudo cat /etc/httpd/conf/httpd.conf | grep 'ServerRoot'
    # with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
    # with ServerRoot set to "/etc/httpd" will be interpreted by the
    # ServerRoot: The top of the directory tree under which the server's
    ServerRoot "/etc/httpd"
    
    • つまりアクセスログはここ
    $ :/var/www/html/wordpress$ sudo ls -l /etc/httpd/logs/
    合計 340
    -rw-r--r-- 1 root root   7571  7月 11 11:03 2016 access_log
    -rw-r--r-- 1 root root 310069  7月 10 03:04 2016 access_log-20160710
    -rw-r--r-- 1 root root   1468  7月 11 11:03 2016 error_log
    -rw-r--r-- 1 root root   8127  7月 10 05:25 2016 error_log-20160710
    

参考URL

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1