Es Durの前立腺

支離滅裂

WordPress

環境

Ubuntu 14.04

PHPMySQL、Apachインストール

$ sudo apt-get install php5 php5-mysql mysql-server apache2

サービス起動

$ sudo /usr/sbin/apachectl start
$ sudo initctl mysql start

MySQL

項目 設定値
データベース wpdb
ユーザ wpuser
パスワード wp12345
$ mysql -u root -p
create database wpdb;
grant all on wpdb.* to wpuser@localhost identified by 'wp12345';

WordPress

ダウンロード

$ wget https://ja.wordpress.org/wordpress-4.5.1-ja.tar.gz
$ tar xzvf wordpress-4.5.1-ja.tar.gz

wp-config-sample.phpをwp-config.phpにリネーム

$ mv ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

wp-config.phpの設定内容を更新

$ vim ~/wordpress/wp-config.php
// ** MySQL 設定 - この情報はホスティング先から入手してください。 ** //
/** WordPress のためのデータベース名 */
define('DB_NAME','wpdb');

/** MySQL データベースのユーザー名 */
define('DB_USER', 'wpuser');

/** MySQL データベースのパスワード */
define('DB_PASSWORD', 'wp12345');

/** MySQL のホスト名 */
define('DB_HOST', 'localhost');

/** データベースのテーブルを作成する際のデータベースの文字セット */
define('DB_CHARSET', 'utf8');

/** データベースの照合順序 (ほとんどの場合変更する必要はありません) */
define('DB_COLLATE', '');

認証用ユニークキー設定
wp-configの以下に記載のあるURLを開く

/**#@+
 * 認証用ユニークキー
 *
 * それぞれを異なるユニーク (一意) な文字列に変更してください。
 * {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org の秘密鍵サービス} で自動生成するこ
ともできます。
 * 後でいつでも変更して、既存のすべての cookie を無効にできます。これにより、すべてのユーザーを強制的に再
ログインさせることになります。
 *
 * @since 2.6.0
 */

以下の結果をコピー
f:id:Guigui1919:20160504115542p:plain

wp-config.phpに追記

define('AUTH_KEY',         'xxxxxxxxxxxx');
define('SECURE_AUTH_KEY',  'xxxxxxxxxxxx');
define('LOGGED_IN_KEY',    'xxxxxxxxxxxx');
define('NONCE_KEY',        'xxxxxxxxxxxx');
define('AUTH_SALT',        'xxxxxxxxxxxx');
define('SECURE_AUTH_SALT', 'xxxxxxxxxxxx');
define('LOGGED_IN_SALT',   'xxxxxxxxxxxx');
define('NONCE_SALT',       'xxxxxxxxxxxx');

apacheのドキュメントルートへ
配置場所はどこでも良いが、取り敢えずデフォルトのドキュメントルートに置く
wordpressは長いのでwpに変更

$ sudo mv ~/wordpress /var/www/html/wp

WordPressの初期設定
以下のURLからWordPressを開く
http://[url or ip]/wp/wp-admin/install.php f:id:Guigui1919:20160504115553p:plain

FTPなしでPlugin導入

wp-config.phpに以下の記述を追記

define('FS_METHOD', 'direct');

ディレクトリの所有者を取り敢えずApacheユーザに変更

$ sudo chown -R www-data:www-data /var/www/html/wp

Vagrant簡単メモ

簡単に仮想環境が作れるツールVagrant
Rubyで作られてます。


Box追加

vagrant box add [box_name] [url]

boxはhttps://github.com/chef/bentoなどから取得



box一覧

vagrant box list


box削除

vagrant box remove [box_name]

仮想マシン起動

vagrant init [box_name]
vagrant up

vagrant initでカレントディレクトリにvagrantfileができる。
vagrant upで仮想サーバが起動する。


仮想マシンに接続

vagrant ssh

仮想マシン削除

vagrant destroy


仮想マシンシャットダウン

vagrant halt


仮想マシン再起動

vagrant reload


仮想マシン保留状態に

vagrant suspend

仮想マシンの保留状態解除

vagrant resume


仮想マシンIPアドレス設定
vagrantfileを修正します。

vim vagrantfile
...

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
   config.vm.network "private_network", ip: "111.222.33.44"

...

エラーが出る
yum updateしたらどうやらvagrantfile修正したらエラーが出るっぽい。
Vagrant 1.8.1

Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

vagrant sshは可能だけど、ls /vagrantすると空っぽ。。。
本来ならホストOSのカレントディレクトリが共有されるから、vagrantfileが見えないと行けないんだけど、見えないってことは共有が出来てない。
ゲスト側のマウント関係が壊れたっぽいんで、再構築します。

sudo yum -y install kernel-devel
sudo yum -y install gcc
sudo /etc/init.d/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [失敗]
(Look at /var/log/vboxadd-install.log to find out what went wrong)
Doing non-kernel setup of the Guest Additions              [  OK  ]

OpenGLは失敗でも問題ないみたいなんで、再度vagrant reloadしてみてエラーが出なかったら、
ゲストOSにログインしてls /vagrantでvagrantfileがあればOK!


【追記】
CentOS 7.2ではvboxaddは以下。
「5.0.26」の部分は変わるみたい。

sudo /opt/VBoxGuestAdditions-5.0.26/init/vboxadd setup

あと、kernelをアップデートするほうが良いかもしれない。
結果としてよかった。

sudo yum update kernel*

Linux 設定メモ

日本語ディレクトリ名を英語に変換

LANG=C xdg-user-dirs-gtk-update


サービス自動起動設定

chkconfig [サービス名] on

サービス起動確認

service [サービス名] status
service --status-all


SELinux確認

getenforce
sestatus


SELinux一時無効、一時有効
無効

setenforce 0

有効

setenforce 1


SELinux無効化

vim /etc/selinux/config
SELINUX=disabled

tar.gzファイル解凍

tar zxvf filename

tarオプション

  • -z : gzipを通して解凍
  • -x : 書庫からファイルを取り出す
  • -v : ファイル一覧の表示
  • -f : ファイル名の指定


sudo利用

visudo
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
username  ALL=(ALL)   ALL

※usernameを追記