読者です 読者をやめる 読者になる 読者になる

masayuki5160's diary

名古屋でWeb系エンジニアしてます

LAMP環境構築めも

MySQL PHP

PHP,MySQL,Apacheのインストールめも
CentOSで。)

1.PHPをインストール
# yum install php php-pear php-devel php-mbstring php-mysql php-pdo php-xml
2.確認
# php -v
3.MySQLをインストール
# yum install mysql-server
4.Apacheがはいってるか確認
# rpm -qa httpd
※はいってないならインストール
# yum -y install httpd

5.Apache動くか確認
# /sbin/service httpd start
6.ためしにドキュメントルートにphpファイルをおいて、
ブラウザから"localhost/info.php"とアクセス。
# vi /var/www/html/info.php


※2012/3/19 追記
PHPの設定

画面にエラーを出力するには。
/etc/php.iniのdisplay_errorsをOnにする。

;エラーを出力しない場合
display_errors = Off

;エラーを出力する場合
display_errors = On



参考
http://www.24w.jp/study_contents.php?bid=php&iid=php&sid=setting&cid=001

作業ログ

[root@localhost masayuki]# yum install php php-pear php-devel php-mbstring php-mysql php-pdo php-xml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package php.i386 0:5.1.6-27.el5_7.5 set to be updated
    • > Processing Dependency: php-cli = 5.1.6-27.el5_7.5 for package: php
    • > Processing Dependency: php-common = 5.1.6-27.el5_7.5 for package: php
      • > Package php-devel.i386 0:5.1.6-27.el5_7.5 set to be updated
    • > Processing Dependency: autoconf for package: php-devel
    • > Processing Dependency: automake for package: php-devel
      • > Package php-mbstring.i386 0:5.1.6-27.el5_7.5 set to be updated
      • > Package php-mysql.i386 0:5.1.6-27.el5_7.5 set to be updated
    • > Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: php-mysql
    • > Processing Dependency: libmysqlclient.so.15 for package: php-mysql
      • > Package php-pdo.i386 0:5.1.6-27.el5_7.5 set to be updated
      • > Package php-pear.noarch 1:1.4.9-6.el5 set to be updated
      • > Package php-xml.i386 0:5.1.6-27.el5_7.5 set to be updated
    • > Running transaction check
      • > Package autoconf.noarch 0:2.59-12 set to be updated
    • > Processing Dependency: imake for package: autoconf
      • > Package automake.noarch 0:1.9.6-2.3.el5 set to be updated
      • > Package mysql.i386 0:5.0.95-1.el5_7.1 set to be updated
    • > Processing Dependency: perl(DBI) for package: mysql
      • > Package php-cli.i386 0:5.1.6-27.el5_7.5 set to be updated
      • > Package php-common.i386 0:5.1.6-27.el5_7.5 set to be updated
    • > Running transaction check
      • > Package imake.i386 0:1.0.2-3 set to be updated
      • > Package perl-DBI.i386 0:1.52-2.el5 set to be updated
    • > Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
php i386 5.1.6-27.el5_7.5 updates 2.3 M
php-devel i386 5.1.6-27.el5_7.5 updates 504 k
php-mbstring i386 5.1.6-27.el5_7.5 updates 996 k
php-mysql i386 5.1.6-27.el5_7.5 updates 86 k
php-pdo i386 5.1.6-27.el5_7.5 updates 65 k
php-pear noarch 1:1.4.9-6.el5 base 344 k
php-xml i386 5.1.6-27.el5_7.5 updates 97 k
Installing for dependencies:
autoconf noarch 2.59-12 base 647 k
automake noarch 1.9.6-2.3.el5 base 476 k
imake i386 1.0.2-3 base 319 k
mysql i386 5.0.95-1.el5_7.1 updates 4.9 M
perl-DBI i386 1.52-2.el5 base 600 k
php-cli i386 5.1.6-27.el5_7.5 updates 2.1 M
php-common i386 5.1.6-27.el5_7.5 updates 153 k

Transaction Summary
====================================================================================================================================================================================
Install 14 Package(s)
Upgrade 0 Package(s)

Total download size: 13 M
Is this ok [y/N]: y
Downloading Packages:
(1/14): php-pdo-5.1.6-27.el5_7.5.i386.rpm | 65 kB 00:00
(2/14): php-mysql-5.1.6-27.el5_7.5.i386.rpm | 86 kB 00:00
(3/14): php-xml-5.1.6-27.el5_7.5.i386.rpm | 97 kB 00:00
(4/14): php-common-5.1.6-27.el5_7.5.i386.rpm | 153 kB 00:00
(5/14): imake-1.0.2-3.i386.rpm | 319 kB 00:00
(6/14): php-pear-1.4.9-6.el5.noarch.rpm | 344 kB 00:00
(7/14): automake-1.9.6-2.3.el5.noarch.rpm | 476 kB 00:00
(8/14): php-devel-5.1.6-27.el5_7.5.i386.rpm | 504 kB 00:00
(9/14): perl-DBI-1.52-2.el5.i386.rpm | 600 kB 00:00
(10/14): autoconf-2.59-12.noarch.rpm | 647 kB 00:00
(11/14): php-mbstring-5.1.6-27.el5_7.5.i386.rpm | 996 kB 00:00
(12/14): php-cli-5.1.6-27.el5_7.5.i386.rpm | 2.1 MB 00:00
(13/14): php-5.1.6-27.el5_7.5.i386.rpm | 2.3 MB 00:00
(14/14): mysql-5.0.95-1.el5_7.1.i386.rpm | 4.9 MB 00:00

                                                                                                                                                                                                                                                                                                                                                                      • -

Total 4.8 MB/s | 13 MB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-common 1/14
Installing : php-cli 2/14
Installing : php 3/14
Installing : php-pdo 4/14
Installing : imake 5/14
Installing : perl-DBI 6/14
Installing : mysql 7/14
Installing : php-mysql 8/14
Installing : php-mbstring 9/14
Installing : php-xml 10/14
Installing : autoconf 11/14
Installing : automake 12/14
Installing : php-devel 13/14
Installing : php-pear 14/14

Installed:
php.i386 0:5.1.6-27.el5_7.5 php-devel.i386 0:5.1.6-27.el5_7.5 php-mbstring.i386 0:5.1.6-27.el5_7.5 php-mysql.i386 0:5.1.6-27.el5_7.5 php-pdo.i386 0:5.1.6-27.el5_7.5
php-pear.noarch 1:1.4.9-6.el5 php-xml.i386 0:5.1.6-27.el5_7.5

Dependency Installed:
autoconf.noarch 0:2.59-12 automake.noarch 0:1.9.6-2.3.el5 imake.i386 0:1.0.2-3 mysql.i386 0:5.0.95-1.el5_7.1 perl-DBI.i386 0:1.52-2.el5 php-cli.i386 0:5.1.6-27.el5_7.5
php-common.i386 0:5.1.6-27.el5_7.5

Complete!
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# php -v
PHP 5.1.6 (cli) (built: Feb 2 2012 18:24:47)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.yz.yamagata-u.ac.jp
* extras: ftp.yz.yamagata-u.ac.jp
* updates: ftp.yz.yamagata-u.ac.jp
Setting up Install Process
Resolving Dependencies

    • > Running transaction check
      • > Package mysql-server.i386 0:5.0.95-1.el5_7.1 set to be updated
    • > Processing Dependency: perl-DBD-MySQL for package: mysql-server
    • > Running transaction check
    • > Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================================
Installing:
mysql-server i386 5.0.95-1.el5_7.1 updates 9.8 M
Installing for dependencies:
perl-DBD-MySQL i386 3.0007-2.el5 base 148 k

Transaction Summary
====================================================================================================================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)

Total download size: 10 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): perl-DBD-MySQL-3.0007-2.el5.i386.rpm | 148 kB 00:00
(2/2): mysql-server-5.0.95-1.el5_7.1.i386.rpm | 9.8 MB 00:01

                                                                                                                                                                                                                                                                                                                                                                      • -

Total 5.6 MB/s | 10 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-DBD-MySQL 1/2
Installing : mysql-server 2/2

Installed:
mysql-server.i386 0:5.0.95-1.el5_7.1

Dependency Installed:
perl-DBD-MySQL.i386 0:3.0007-2.el5

Complete!
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# yum -y install httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.riken.jp
* extras: ftp.riken.jp
* updates: ftp.riken.jp
Setting up Install Process
Package httpd-2.2.3-53.el5.centos.3.i386 already installed and latest version
Nothing to do
[root@localhost masayuki]# rpm -qa httpd
httpd-2.2.3-53.el5.centos.3
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# /sbin/service httpd start
httpd 繧定オキ蜍穂クュ: [ OK ]
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# vi /etc/httpd/conf/httpd.conf
[root@localhost masayuki]# vi /etc/httpd/conf/httpd.conf
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]# vi /var/www/html/info.php
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#
[root@localhost masayuki]#