さくらvpsにwordpressを入れる

WordPressをさくらvpsに何度もインストールし直したりしたのでそのまとめ。

参考にしたページ:

普通に

ssh root@hogehoge

としてやると、

ssh: connect to host hogehoge port 22: Connection refused

なんて言われる。

解決策をぐぐってみると、なんと再起動したら直るとのことww しかし、何度もOS再インストールしてると、

>ssh root@hogehoge
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
01:23:45:67:89:ab:cd:ef:01:23:45:67:89:ab:cd:ef
Please contact your system administrator.
Add correct host key in /Users/hoge/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/hoge/.ssh/known_hosts:5
RSA host key for hogehoge has changed and you have requested strict checking.
Host key verification failed.

なんてことになる。

これは
SSH接続エラー回避方法:.ssh/known_hostsから特定のホストを削除する/削除しないで対処する3つの方法
を参考にして、

>ssh-keygen -R hogehoge
>ssh root@hogehoge

これで無事ssh接続できた。

phpapachemysql等をインストール

参考にしたページの通り、yumを使いさくっと入れようとすると、

> yum update
Failed to set locale, defaulting to C

ふむふむ、、、localeがsetできないと。

Failed to set locale, defaulting to C

こんなのが原因みたい。 とりあえず動かしたいだけなので、

>LC_ALL=C
>export LC_ALL
>yum update
Error: File /var/cache/yum/x86_64/6/epel/metalink.xml is not XML

また問題発生だけど、どうやらcasheファイルがおかしい とりあえず、

>sudo yum clean all
>yum update

としてアップデートできたので、

yum install -y mysql-server php php-devel php-mbstring php-mysql php-pdo php-xml php-gd httpd

としてインストール。

mysqlapacheの設定

ここら辺はコピペ。

まずはmysqlの設定ファイル

>vi /etc/my.cnf
### 下記コードをmy.cnfの一番下に追記
[mysqld]
default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci

[client]
default-character-set = utf8

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8
### ここまで

そしてmysqlを起動して、テーブルを作成

>sudo /etc/init.d/mysqld start
>mysqladmin -u root password '自分のパスワード'
>mysql -uroot -p
Enter password:'自分のパスワード'

mysql>create database wordpress default character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql>exit;

完了!

そしてapacheの設定

>vi /etc/httpd/conf.d/virtualhost.conf
### 下記コードを追加
NameVirtualHost *:80
Include conf.d/sites/*.conf
###

>vi /etc/httpd/conf.d/sites/wordpress.conf
### 下記コードで新規作成
<VirtualHost *:80>
  DocumentRoot /var/www/html/wp/wordpress
  DirectoryIndex index.php
</VirtualHost>
###

>/etc/init.d/httpd configtest
>/etc/init.d/httpd start

起動完了

WordPressをインストール

ドキュメントルートに移動してインストールするだけ!

>mkdir /var/www/html/wp
>cd /var/www/html/wp

>wget http://ja.wordpress.org/wordpress-3.*.*-ja.zip    <- 適当なバージョン
>unzip wordpress-3.*.*-ja.zip
>chown apache:apache -R wordpress

apache権限にしたらこれで完了。

あとはページに接続して、 データベースのユーザー名:root パスワード:'自分のパスワード' をいれて、入力していくと無事終了