WordPress を CentOS にインストール
環境
インストール
phpインストール
$ cd /usr/local/src/ $ sudo wget -O php-5.6.8.tar.gz http://jp1.php.net/get/php-5.6.8.tar.gz/from/this/mirror $ sudo tar xfzv php-5.6.8.tar.gz $ cd php-5.6.8
$ sudo yum install libxml2-devel libjpeg-devel libpng-devel libcurl-devel $ sudo yum -y install ncurses* $ sudo yum -y install gcc-c++ $ sudo yum -y install flex $ sudo yum -y install libxml* $ sudo yum -y install gdbm-devel $ sudo yum -y install gd gd-devel freetype freetype libpng libmng* libtiff* libjpeg* libc-client* giflib* $ sudo yum -y install httpd* $ sudo yum -y install pcre-devel $ sudo yum -y install unixODBC-devel $ sudo yum -y install net-snmp-devel $ sudo yum -y install openssl* $ sudo yum -y install bzip2* $ sudo yum -y install curl* $ sudo yum -y install gdbm* $ sudo yum -y install db4* $ sudo yum -y install gmp* $ sudo yum -y install libc-client* $ sudo yum -y install libmcrypt* $ sudo yum -y install mhash* $ sudo yum -y install freetds* $ sudo yum -y install mysql* $ sudo yum -y install postgresql* $ sudo yum -y install aspell* $ sudo yum -y install readline* $ sudo yum -y install libtidy* $ sudo yum -y install libxslt* $ sudo yum -y install libtool* $ sudo yum -y install openssl
$ sudo ./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --sysconfdir=/private/etc --with-config-file-path=/etc --with-libxml-dir=/usr --with-kerberos=/usr --with-curl=/usr --with-zlib-dir=/usr --enable-bcmath --enable-exif --enable-exif --with-bz2=/usr --enable-ftp --enable-mbstring --enable-mbregex --enable-calendar --enable-sockets --with-curl=/usr --sysconfdir=/private/etc --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-xmlrpc --with-xsl=/usr --with-pear --with-libxml-dir=/usr --with-iconv --with-pdo-mysql=mysqlnd --with-gd --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-shmop --with-xsl=/usr --with-iconv-dir=/usr --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-pcre-regex --with-mcrypt=/usr/local --enable-cli --with-pear --enable-opcache=no --with-openssl $ sudo make $ sudo make install
$ php -v PHP 5.6.8 (cli) (built: May 12 2015 02:24:44) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
パッケージインストール
$ sudo yum install httpd mysql-server php php-mysql php-mbstring
DBの準備
$ sudo chkconfig mysqld on $ sudo service mysqld start
$ sudo 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 New password: Re-enter new 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 ... 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 - 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 -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 10 Server version: 5.1.73 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>
mysql> create database jessicadb; mysql> grant all privileges on jessicadb.* to demo@localhost identified by 'password'; mysql> flush privileges; mysql> quit
$ cd /var/www/ $ sudo curl -LO http://ja.wordpress.org/latest-ja.tar.gz $ sudo tar xzfv latest-ja.tar.gz $ sudo chown -R jundo414:jundo414 wordpress/ $ sudo mv wordpress jessica $ sudo chmod -R apache:apache jessica $ cd jessica $ cp wp-config-sample.php wp-config.php $ vi wp-config.php
wp-config.php
// ** MySQL 設定 - こちらの情報はホスティング先から入手してください。 ** // /** WordPress のためのデータベース名 */ define('DB_NAME', ‘jessicadb’); /** MySQL データベースのユーザー名 */ define('DB_USER', ‘demo’); /** MySQL データベースのパスワード */ define('DB_PASSWORD', ‘password’); /** MySQL のホスト名 */ define('DB_HOST', 'localhost:/var/lib/mysql/mysql.sock'); /**#@+ * 認証用ユニークキー * * それぞれを異なるユニーク (一意) な文字列に変更してください。 * {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org の秘密鍵サービス} で自動生成することもできます。 * 後でいつでも変更して、既存のすべての cookie を無効にできます。これにより、すべてのユーザーを強制的に再ログインさせること になります。 * * @since 2.6.0 */ define('AUTH_KEY', 'kLseZWJUJzrrW4ABrPdxbJmn'); define('SECURE_AUTH_KEY', 'aBwZER5fg5DhYNYg9ZR32cnQ'); define('LOGGED_IN_KEY', 'HzksUTmMzr5eDkGBwVBAHdAy'); define('NONCE_KEY', 'fYbN4jbrzJaTuCXTjtunSLFG'); define('AUTH_SALT', '7DDPyZLBbSVzKyEJYNLuKGLL'); define('SECURE_AUTH_SALT', 'sLDE5t9Rpz2MSsgckT6fXHe6'); define('LOGGED_IN_SALT', 'bh6JdNFBtKyVYDzjNmDfhHMQ'); define('NONCE_SALT', 'RkuszrLj6dEEDFiWwk539xp4'); /** * WordPress データベーステーブルの接頭辞 * * それぞれにユニーク (一意) な接頭辞を与えることで一つのデータベースに複数の WordPress を * インストールすることができます。半角英数字と下線のみを使用してください。 */ $table_prefix = 'js_'; define('WP_DEBUG', true); define('WP_ALLOW_MULTISITE', true); define('FS_METHOD', 'direct');
$ sudo vi /etc/httpd/conf/httpd.conf —————————————————— #ServerName www.example.com:80 ServerName *:80 DirectoryIndex index.html index.html.var index.php AddType application/x-httpd-php .php ServerName subdomain.earthyworld.com DocumentRoot /home/*/public_html AllowOverride All Options FollowSymLinks Order allow,deny Allow from all
$ sudo vi /etc/php.ini error_reporting = E_ALL & ~E_NOTICE post_max_size = 20M default_charset = "UTF-8" upload_max_filesize = 20M date.timezone = Asia/Tokyo mbstring.language = Japanese mbstring.internal_encoding = UTF-8 mbstring.http_input = UTF-8 mbstring.http_output = pass mbstring.encoding_translation = On mbstring.detect_order = auto mbstring.substitute_character = none;
$ sudo chkconfig httpd on $ sudo service httpd start
$ sudo service mysqld stop $ sudo mysqld_safe --skip-grant-tables &
$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.73 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> mysql> use mysql; Database changed mysql> select host,user,password from user; +-----------+------+-------------------------------------------+ | host | user | password | +-----------+------+-------------------------------------------+ | localhost | root | *DDFB542AA0BD1D251995D81AEBEB96DEEAD1132F | | 127.0.0.1 | root | *DDFB542AA0BD1D251995D81AEBEB96DEEAD1132F | | localhost | demo | *2A2120AA322FA2DA8C628DBA792B98511F2DA413 | +-----------+------+-------------------------------------------+ 3 rows in set (0.00 sec) mysql> truncate table user; Query OK, 0 rows affected (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on *.* to root@localhost identified by 'Passw0rd' with grant option; Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on *.* to demo@localhost identified by 'password' with grant option; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> select host,user,password from user; +-----------+------+-------------------------------------------+ | host | user | password | +-----------+------+-------------------------------------------+ | localhost | root | *DDFB542AA0BD1D251995D81AEBEB96DEEAD1132F | | localhost | demo | *2A2120AA322FA2DA8C628DBA792B98511F2DA413 | +-----------+------+-------------------------------------------+ 2 rows in set (0.00 sec)
mysql> quit; $ sudo kill -9 <mysqld_safeのPID> <mysqldのPID> $ sudo service mysqld start
$ mkdir wp-content/uploads $ chmod 777 wp-content/uploads $ chmod 777 wp-content/themes/ $ chmod 777 wp-content/plugins/