CentOSにいわゆるAPMを揃える

というわけでまたまた続きです。
いわゆるAPM(Apahce+PHP+MySQL)を入れます。

…といってもやむやむするだけです。
適当に必要そうなやつを選んでやむやむしました。(多分いらないものも混ざってるし、足りないものは勝手に選んでくれる。)

今回選んだのはこやつら。

  • httpd.i686 : Apache HTTP Server
  • php.i686 : PHP scripting language for creating dynamic web sites
  • php-cli.i686 : Command-line interface for PHP
  • php-common.i686 : Common files for PHP
  • php-devel.i686 : Files needed for building PHP extensions
  • php-mbstring.i686 : A module for PHP applications which need multi-byte string handling
  • php-mysql.i686 : A module for PHP applications that use MySQL databases
  • php-pear.noarch : PHP Extension and Application Repository framework
  • php-pecl-apc.i686 : APC caches and optimizes PHP intermediate code
  • php-xml.i686 : A module for PHP applications which use XML
  • php-xmlrpc.i686 : A module for PHP applications which use the XML-RPC protocol
  • mysql.i686 : MySQL client programs and shared libraries
  • mysql-server.i686 : The MySQL server and related files

[cc lang=”teraterm”]
[root@centos ~]# yum install httpd php php-cli php-common php-devel php-mbstring php-mysql php-pear php-pecl-apc php-xml php-xmlrpc mysql mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package httpd.i686 0:2.2.15-29.el6.centos will be installed
–> Processing Dependency: httpd-tools = 2.2.15-29.el6.centos for package: httpd-2.2.15-29.el6.centos.i686
–> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-29.el6.centos.i686
—> Package mysql.i686 0:5.1.69-1.el6_4 will be installed
–> Processing Dependency: mysql-libs = 5.1.69-1.el6_4 for package: mysql-5.1.69-1.el6_4.i686
—> Package mysql-server.i686 0:5.1.69-1.el6_4 will be installed
–> Processing Dependency: perl-DBI for package: mysql-server-5.1.69-1.el6_4.i686
–> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.69-1.el6_4.i686
–> Processing Dependency: perl(DBI) for package: mysql-server-5.1.69-1.el6_4.i686
—> Package php.i686 0:5.3.3-23.el6_4 will be installed
—> Package php-cli.i686 0:5.3.3-23.el6_4 will be installed
—> Package php-common.i686 0:5.3.3-23.el6_4 will be installed
—> Package php-devel.i686 0:5.3.3-23.el6_4 will be installed
—> Package php-mbstring.i686 0:5.3.3-23.el6_4 will be installed
—> Package php-mysql.i686 0:5.3.3-23.el6_4 will be installed
–> Processing Dependency: php-pdo(x86-32) for package: php-mysql-5.3.3-23.el6_4.i686
—> Package php-pear.noarch 1:1.9.4-4.el6 will be installed
—> Package php-pecl-apc.i686 0:3.1.9-2.el6 will be installed
—> Package php-xml.i686 0:5.3.3-23.el6_4 will be installed
–> Processing Dependency: libxslt.so.1(LIBXML2_1.0.24) for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libxslt.so.1(LIBXML2_1.0.22) for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libxslt.so.1(LIBXML2_1.0.18) for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libxslt.so.1(LIBXML2_1.0.13) for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libxslt.so.1(LIBXML2_1.0.11) for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libxslt.so.1 for package: php-xml-5.3.3-23.el6_4.i686
–> Processing Dependency: libexslt.so.0 for package: php-xml-5.3.3-23.el6_4.i686
—> Package php-xmlrpc.i686 0:5.3.3-23.el6_4 will be installed
–> Running transaction check
—> Package apr-util-ldap.i686 0:1.3.9-3.el6_0.1 will be installed
—> Package httpd-tools.i686 0:2.2.15-29.el6.centos will be installed
—> Package libxslt.i686 0:1.1.26-2.el6_3.1 will be installed
—> Package mysql-libs.i686 0:5.1.66-2.el6_3 will be updated
—> Package mysql-libs.i686 0:5.1.69-1.el6_4 will be an update
—> Package perl-DBD-MySQL.i686 0:4.013-3.el6 will be installed
—> Package perl-DBI.i686 0:1.609-4.el6 will be installed
—> Package php-pdo.i686 0:5.3.3-23.el6_4 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================
Installing:
httpd i686 2.2.15-29.el6.centos updates 828 k
mysql i686 5.1.69-1.el6_4 updates 917 k
mysql-server i686 5.1.69-1.el6_4 updates 8.8 M
php i686 5.3.3-23.el6_4 updates 1.1 M
php-cli i686 5.3.3-23.el6_4 updates 2.2 M
php-common i686 5.3.3-23.el6_4 updates 525 k
php-devel i686 5.3.3-23.el6_4 updates 507 k
php-mbstring i686 5.3.3-23.el6_4 updates 454 k
php-mysql i686 5.3.3-23.el6_4 updates 78 k
php-pear noarch 1:1.9.4-4.el6 base 393 k
php-pecl-apc i686 3.1.9-2.el6 base 96 k
php-xml i686 5.3.3-23.el6_4 updates 101 k
php-xmlrpc i686 5.3.3-23.el6_4 updates 53 k
Installing for dependencies:
apr-util-ldap i686 1.3.9-3.el6_0.1 base 15 k
httpd-tools i686 2.2.15-29.el6.centos updates 73 k
libxslt i686 1.1.26-2.el6_3.1 base 451 k
perl-DBD-MySQL i686 4.013-3.el6 base 134 k
perl-DBI i686 1.609-4.el6 base 705 k
php-pdo i686 5.3.3-23.el6_4 updates 74 k
Updating for dependencies:
mysql-libs i686 5.1.69-1.el6_4 updates 1.2 M

Transaction Summary
================================================================================================================================================================
Install 19 Package(s)
Upgrade 1 Package(s)

Total download size: 19 M
Is this ok [y/N]: y
Downloading Packages:
(1/20): apr-util-ldap-1.3.9-3.el6_0.1.i686.rpm | 15 kB 00:00
(2/20): httpd-2.2.15-29.el6.centos.i686.rpm | 828 kB 00:00
(3/20): httpd-tools-2.2.15-29.el6.centos.i686.rpm | 73 kB 00:00
(4/20): libxslt-1.1.26-2.el6_3.1.i686.rpm | 451 kB 00:00
(5/20): mysql-5.1.69-1.el6_4.i686.rpm | 917 kB 00:00
(6/20): mysql-libs-5.1.69-1.el6_4.i686.rpm | 1.2 MB 00:00
(7/20): mysql-server-5.1.69-1.el6_4.i686.rpm | 8.8 MB 00:00
(8/20): perl-DBD-MySQL-4.013-3.el6.i686.rpm | 134 kB 00:00
(9/20): perl-DBI-1.609-4.el6.i686.rpm | 705 kB 00:00
(10/20): php-5.3.3-23.el6_4.i686.rpm | 1.1 MB 00:00
(11/20): php-cli-5.3.3-23.el6_4.i686.rpm | 2.2 MB 00:00
(12/20): php-common-5.3.3-23.el6_4.i686.rpm | 525 kB 00:00
(13/20): php-devel-5.3.3-23.el6_4.i686.rpm | 507 kB 00:00
(14/20): php-mbstring-5.3.3-23.el6_4.i686.rpm | 454 kB 00:00
(15/20): php-mysql-5.3.3-23.el6_4.i686.rpm | 78 kB 00:00
(16/20): php-pdo-5.3.3-23.el6_4.i686.rpm | 74 kB 00:00
(17/20): php-pear-1.9.4-4.el6.noarch.rpm | 393 kB 00:00
(18/20): php-pecl-apc-3.1.9-2.el6.i686.rpm | 96 kB 00:00
(19/20): php-xml-5.3.3-23.el6_4.i686.rpm | 101 kB 00:00
(20/20): php-xmlrpc-5.3.3-23.el6_4.i686.rpm | 53 kB 00:00
—————————————————————————————————————————————————————-
Total 6.0 MB/s | 19 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-common-5.3.3-23.el6_4.i686 1/21
Updating : mysql-libs-5.1.69-1.el6_4.i686 2/21
Installing : php-cli-5.3.3-23.el6_4.i686 3/21
Installing : perl-DBI-1.609-4.el6.i686 4/21
Installing : 1:php-pear-1.9.4-4.el6.noarch 5/21
Installing : perl-DBD-MySQL-4.013-3.el6.i686 6/21
Installing : mysql-5.1.69-1.el6_4.i686 7/21
Installing : php-pdo-5.3.3-23.el6_4.i686 8/21
Installing : httpd-tools-2.2.15-29.el6.centos.i686 9/21
Installing : libxslt-1.1.26-2.el6_3.1.i686 10/21
Installing : apr-util-ldap-1.3.9-3.el6_0.1.i686 11/21
Installing : httpd-2.2.15-29.el6.centos.i686 12/21
Installing : php-5.3.3-23.el6_4.i686 13/21
Installing : php-devel-5.3.3-23.el6_4.i686 14/21
Installing : php-xml-5.3.3-23.el6_4.i686 15/21
Installing : php-mysql-5.3.3-23.el6_4.i686 16/21
Installing : mysql-server-5.1.69-1.el6_4.i686 17/21
Installing : php-pecl-apc-3.1.9-2.el6.i686 18/21
Installing : php-xmlrpc-5.3.3-23.el6_4.i686 19/21
Installing : php-mbstring-5.3.3-23.el6_4.i686 20/21
Cleanup : mysql-libs-5.1.66-2.el6_3.i686 21/21
Verifying : php-mysql-5.3.3-23.el6_4.i686 1/21
Verifying : php-xml-5.3.3-23.el6_4.i686 2/21
Verifying : php-common-5.3.3-23.el6_4.i686 3/21
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.i686 4/21
Verifying : perl-DBI-1.609-4.el6.i686 5/21
Verifying : php-xmlrpc-5.3.3-23.el6_4.i686 6/21
Verifying : perl-DBD-MySQL-4.013-3.el6.i686 7/21
Verifying : httpd-2.2.15-29.el6.centos.i686 8/21
Verifying : php-cli-5.3.3-23.el6_4.i686 9/21
Verifying : 1:php-pear-1.9.4-4.el6.noarch 10/21
Verifying : mysql-5.1.69-1.el6_4.i686 11/21
Verifying : php-devel-5.3.3-23.el6_4.i686 12/21
Verifying : mysql-libs-5.1.69-1.el6_4.i686 13/21
Verifying : php-mbstring-5.3.3-23.el6_4.i686 14/21
Verifying : mysql-server-5.1.69-1.el6_4.i686 15/21
Verifying : libxslt-1.1.26-2.el6_3.1.i686 16/21
Verifying : httpd-tools-2.2.15-29.el6.centos.i686 17/21
Verifying : php-5.3.3-23.el6_4.i686 18/21
Verifying : php-pdo-5.3.3-23.el6_4.i686 19/21
Verifying : php-pecl-apc-3.1.9-2.el6.i686 20/21
Verifying : mysql-libs-5.1.66-2.el6_3.i686 21/21

Installed:
httpd.i686 0:2.2.15-29.el6.centos mysql.i686 0:5.1.69-1.el6_4 mysql-server.i686 0:5.1.69-1.el6_4 php.i686 0:5.3.3-23.el6_4
php-cli.i686 0:5.3.3-23.el6_4 php-common.i686 0:5.3.3-23.el6_4 php-devel.i686 0:5.3.3-23.el6_4 php-mbstring.i686 0:5.3.3-23.el6_4
php-mysql.i686 0:5.3.3-23.el6_4 php-pear.noarch 1:1.9.4-4.el6 php-pecl-apc.i686 0:3.1.9-2.el6 php-xml.i686 0:5.3.3-23.el6_4
php-xmlrpc.i686 0:5.3.3-23.el6_4

Dependency Installed:
apr-util-ldap.i686 0:1.3.9-3.el6_0.1 httpd-tools.i686 0:2.2.15-29.el6.centos libxslt.i686 0:1.1.26-2.el6_3.1 perl-DBD-MySQL.i686 0:4.013-3.el6
perl-DBI.i686 0:1.609-4.el6 php-pdo.i686 0:5.3.3-23.el6_4

Dependency Updated:
mysql-libs.i686 0:5.1.69-1.el6_4

Complete!
[root@centos ~]#
[/cc]

今回はこのようなバージョンになりました。
[cc lang=”teraterm”]
[root@centos ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Aug 13 2013 17:27:11
[root@centos ~]# php -v
PHP 5.3.3 (cli) (built: Jul 12 2013 20:21:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[root@centos ~]# mysql –version
mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (i386) using readline 5.1
[root@centos ~]#
[/cc]

うっかり忘れてましたが今回の目的はComposerを使うことです。
ComposerはPHP5.3.2以上が必須らしいので危なかったです。

もろもろを起動する前に。
php.iniでタイムゾーンをAsia/Tokyoにし、
my.cnfで文字コードをUTF-8にしておきます。

/etc/php.ini
[cc lang=”ini”]
[Date]
data.timezone = Asia/Tokyo
[/cc]

/etc/my.cnf
[cc lang=”ini”]
[mysqld]
character-set-server = utf8
[mysql]
default-character-set = utf8
[/cc]

起動と自動起動も設定。

Apache
[cc lang=”teraterm”]
[root@centos ~]# /etc/init.d/httpd start
httpd を起動中: httpd: apr_sockaddr_info_get() failed for centos.kurosuke.org
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@centos ~]#
[/cc]

MySQL
[cc lang=”teraterm”]
[root@centos ~]# chkconfig httpd on
[root@centos ~]# /etc/init.d/mysqld start
MySQL データベースを初期化中: WARNING: The host ‘centos.kurosuke.org’ could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
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 centos.kurosuke.org 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 ]
[root@centos ~]# chkconfig mysqld on
[/cc]

なんかMySQL起動時に怒られてるけどとりあえず気にしな…しておこう。
/etc/hostsに追記。
[cc lang=”ini”]
127.0.0.1 centos.kurosuke.org
[/cc]

念のため再起動

Apache
[cc lang=”teraterm”]
[root@centos ~]# /etc/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: httpd: Could not reliably determine the server’s fully qualified domain name, using centos.kurosuke.org for ServerName
[ OK ]
[root@centos ~]#
[/cc]

MySQL
[cc lang=”teraterm”]
[root@centos ~]# /etc/init.d/mysqld restart
mysqld を停止中: [ OK ]
mysqld を起動中: [ OK ]
[root@centos ~]#
[/cc]

MySQLの設定確認とrootパスワードの設定
[cc lang=”teraterm”]
[root@centos ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.69 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> show variables like ‘character_set%’;
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password(‘******’) where user = ‘root’;
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
[root@centos ~]#
[/cc]

Apacheにつないでみる。
ホストマシンのブラウザからhttp://localhost:8080にアクセス!


…..
………..?

つながらない。

iptablesの編集。
/etc/sysconfig/iptables
[cc lang=”ini”]
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
[/cc]
iptablesの再起動
[cc lang=”teraterm”]
[root@centos ~]# /etc/init.d/iptables restart
iptables: ファイアウォールルールを消去中: [ OK ]
iptables: チェインをポリシー ACCEPT へ設定中filter [ OK ]
iptables: モジュールを取り外し中: [ OK ]
iptables: ファイアウォールルールを適用中: [ OK ]
[root@centos ~]#
[/cc]

ホストマシンのブラウザからhttp://localhost:8080にアクセス!(2回目)

Apache 2 Test Page
powered by CentOS

おk.

PHPの確認。
[cc lang=”teraterm”]
[root@centos ~]# cd /var/www/html/
[root@centos html]# echo “ phpinfo.php
[root@centos html]#
[/cc]

ホストマシンのブラウザからhttp://localhost:8080/phpinfo.phpにアクセス!

おk.

と、こんなかんじで。
これでとりあえず開発環境のベースは整いました。

そろそろ目的を見失い始めていますが、もうちょっと続きます。

コメントを残す

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください