LoginSignup
3
3

More than 5 years have passed since last update.

CentOSにWordPress(日本語版)をインストールする手順

Last updated at Posted at 2014-02-07

CentOS release 6.5 (Final)

必要なパッケージのインストール

yum instal httpd mysql-server php php-mysql php-mbstring vsftpd

apache準備

# vi /etc/httpd/conf/httpd.conf
httpd.conf
ServerName www.example.com:80 #<- コメントアウトを外して変更
DirectoryIndex index.html index.html.var index.php #<- index.phpを追加
AddType application/x-httpd-php .php #<- 追加
AllowOverride All #<- None から Allへ変更 .htaccessの許可(WPパーマリンク設定とか)
# service httpd start
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]
# chkconfig httpd on

mysql準備

初期設定

# vi /etc/my.cnf
my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0
character-set-server = utf8 #<- 追加
# service mysqld start
MySQL データベースを初期化中:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
mysqld を起動中:                                           [  OK  ]
# chkconfig mysqld on

初期設定

# mysql_secure_installation


NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): #<- 空エンター
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y #<- Y でroot用パスワードを設定する
New password: PASSWORD #<- 入力
Re-enter new password: PASSWORD #<- 確認再入力
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y #<- 匿名ユーザーを削除
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y #<- リモートからのrootログインを許可しない
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y #<- テスト用DB削除
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y #<- 再読み込み
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

#

確認

# mysql -uroot -p
Enter password: #<- 先ほど設定したパスワードでログインできればOK
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

WordPress用DBを作成

mysql> CREATE DATABASE db_wordpress CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON db_wordpress.* TO "user_wordpress"@"localhost" IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> EXIT
Bye

ftp準備

初期設定

# vi /etc/vsftpd/vsftpd.conf
vsftpd.conf
anonymous_enable=NO #<- 匿名ユーザーのログイン禁止
# 接続・転送ログを記録
xferlog_enable=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=NO
# アスキーモードでのアップロード・ダウンロードを許可
ascii_upload_enable=YES
ascii_download_enable=YES
# 追加
use_localtime=YES #<- タイムスタンプ時間を日本時間にする
pasv_addr_resolve=YES #<- PASVモード接続先IPアドレスをホスト名から取得する
pasv_address=centossrv.dip.jp #<- PASVモード接続先IPアドレスが牽けるホスト名※
pasv_min_port=60000 #<- PASVモード接続時の最小ポート番号
pasv_max_port=60030 #<- PASVモード接続時の最大ポート番号
# service vsftpd start
vsftpd 用の vsftpd を起動中:                               [  OK  ]
# chkconfig vsftpd on

WordPress設置

# cd /usr/local/src/
# wget http://ja.wordpress.org/wordpress-3.8.1-ja.zip
--2014-02-07 10:05:23--  http://ja.wordpress.org/wordpress-3.8.1-ja.zip
ja.wordpress.org をDNSに問いあわせています... 66.155.40.250, 66.155.40.249
ja.wordpress.org|66.155.40.250|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 6844731 (6.5M) [application/octet-stream]
`wordpress-3.8.1-ja.zip' に保存中

100%[==================================>] 6,844,731   2.11M/s 時間 3.1s    

2014-02-07 10:05:27 (2.11 MB/s) - `wordpress-3.8.1-ja.zip' へ保存完了 [6844731/6844731]

# unzip wordpress-3.8.1-ja.zip 
# mv wordpress [PASS TO WORDPRESS]
# chown apache:apache -R [PASS TO WORDPRESS]/

iptablesで80番ポートを許可

# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# service iptables reload

エラー集

yum installでスペル間違ってた

# yum instal *******
Loaded plugins: fastestmirror, security
No such command: instal. Please use /usr/bin/yum --help

instalになってたらこんなエラーが。
正しくはinstall。初めてであったエラーなので記録。

ServerNameを設定していない

# service httpd start
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
  • networkでHOSTNAMEを設定する
HOSTNAME www.example.com #<- なければ追加
  • hosts設定
127.0.0.1 www.example.com localhost #<- www.example.com追加
  • httpd.confServerNameを設定する
/etc/httpd/conf/httpd.conf
ServerName www.example.com:80 #<- コメントアウトを外して変更
3
3
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
3
3