はじめに
概要
- 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インストール
- ここからインストールし、解凍
- CyberDuckで
/var/www/html
配下にコピー
サンプルファイルを元に設定する
$ :~$ 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のセットアップ画面を開くまでに困ったこととその対処法
- VirtualHostの設定を行っていたら、 まったくwordpressの画面を開いてくれなかった
- いったん設定解除で対応
- データベース確立エラーとの表示
- wp-config.phpのユーザ名がDBの権限を与えたユーザ名になっていなかった
- VirtualHostの設定を行っていたら、 まったくwordpressの画面を開いてくれなかった
管理画面の使い方
- パーマリンクの設定変更
- .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
-