mysqlデータベースと連携したphp WEBアプリまで。
●WEBサーバー
apache がインストールされているか確認
Server version: Apache/2.2.15 (Unix)
Server built: Apr 3 2014 23:56:16
mysql-server がインストールされているか確認
手元のブラウザで php の情報ページを確認。
http://IPアドレス/info.php
システム情報が表示されるので確認後 削除。
●phpライブラリpear
pear がインストールされているか確認
●GDライブラリ
phpで画像の拡大・縮小をするためインストール
●WEBサーバー
apache がインストールされているか確認
$ sudo yum list installed | grep httpdなければ apache をインストール
Server version: Apache/2.2.15 (Unix)
Server built: Apr 3 2014 23:56:16
$ yum info httpd $ sudo yum -y install httpd自動起動になっていなければ自動起動に変更
$ chkconfig --list | grep httpd $ sudo chkconfig httpd onapacheを起動してウェルカムページ確認
$ sudo service httpd starthttp://IPアドレス/ ●apacheグループに所属させる
$ sudo usermod -G apache admin $ id admin●データベースサーバー
mysql-server がインストールされているか確認
$ sudo yum list installed | grep mysql-servermysql Ver 14.14 Distrib 5.1.73 なければ mysql をインストール
$ yum info mysql-server $ sudo yum -y install mysql-servermysql-server を起動
$ 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 : Disallow root login remotely⁄ [Y/n] Y : Remove test database and access to it⁄ [Y/n] Y : Reload privilege tables now⁄ [Y/n] Y :日本語を使用する場合
sudo mv /etc/my.cnf /etc/my.cnf.org sudo cp /etc/my.cnf.org /etc/my.cnf sudo vi /etc/my.cnf[mysqld]のブロックに最低限
[mysqld] default-character-set = utf8 skip-character-set-client-handshake character-set-server = utf8 collation-server = utf8_general_ci init-connect = SET NAMES utf8を追記してmysqlサーバ再起動
$ sudo service mysqld restart自動起動になっていなければ自動起動に変更
$ chkconfig --list | grep mysql $ sudo chkconfig mysqld onmysql-server へログオン確認
$ mysql --show-warnings -u root -p●php php エンジンがインストールされているか確認
$ sudo yum list installed | grep phpPHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies なければ php をインストール
$ sudo yum info php $ sudo yum -y install phpphp でマルチバイトストリング(日本語)を使えるか確認
$ sudo yum list installed | grep php-mbstringなければ php-mbstring をインストール
$ yum info php-mbstring $ sudo yum -y install php-mbstringphp から mysql を使用できるか確認
$ sudo yum list installed | grep php-mysqlなければ php-mysql をインストール
$ yum info php-mysql $ sudo yum -y install php-mysql確認用の phpファイルを作成
$ vi /var/www/html/info.php $ cat /var/www/html/info.php <?php phpinfo(); ?>apacheを再起動
$ sudo service httpd restartここまで apache の設定ファイル httpd.conf はデフォルトのまま。
手元のブラウザで php の情報ページを確認。
http://IPアドレス/info.php
システム情報が表示されるので確認後 削除。
●phpライブラリpear
pear がインストールされているか確認
$ sudo yum list installed | grep php-pearなければ pear をインストール
$ yum info php-pear $ sudo yum -y install php-pearpear バージョン確認
$ pear version $ pear listPEAR Version: 1.9.5 下記のエラー
$ sudo pear install -a ethna/ethna Notice: Array to string conversion in PEAR/REST/13.php on line 80 PHP Notice: Array to string conversion in /usr/share/pear/PEAR/REST/13.php on line 80 Warning: Invalid argument supplied for foreach() in PEAR/REST/13.php on line 84 PHP Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/REST/13.php on line 84 PHP Fatal error: Cannot use string offset as an array in /usr/share/pear/PEAR/REST/10.php on line 263を解決するため
$ sudo pear clear-cachepear アップグレード
$ sudo pear list-upgrades $ sudo pear upgrade pear●phpフレームワーク ethna ethna をインストール
$ sudo pear channel-discover pear.ethna.jp $ sudo pear install -a ethna/ethnaethna コマンド確認
$ ethna -v Ethna 2.5.0 (using PHP 5.3.3)
●GDライブラリ
phpで画像の拡大・縮小をするためインストール
$ sudo yum list installed | grep php-gd $ yum info php-gd $ sudo yum -y install php-gd