Windows7 64ビットOS環境でPHP、MySQL、Apacheのインストール、基本設定方法

システム要件
Apache(httpd-2.2.19-win64) 、PHP(php-5.3.6-Win32-VC9-x64) 、MySQL(MySQL_5.5.13_winx64)

 1.Apacheのインストール、設定

1.1 解凍
「httpd-2.2.19-win64」を「D:\server」へ解凍

1.2 「スタート」-「すべてのプログラム」-「アクセサリ」-「コマンドプロンプト」
cd /d D:\server\httpd-2.2-x64\bin
httpd -k install

1.3 httpd.confの設定内容を編集
D:\server\httpd-2.2-x64\conf\httpd.conf
編集内容
ServerRoot “D:/server/httpd-2.2-x64"
「#LoadModule vhost_alias_module modules/mod_vhost_alias.so」の後ろに次の内容を追加

LoadModule php5_module “D:/Server/php-5.3.6-Win32-VC9-x64/php5apache2_2.dll"
PHPiniDir “D:/Server/php-5.3.6-Win32-VC9-x64"
AddType application/x-httpd-php .html .htm .php

ルートディレクトリの設定:
DocumentRoot “D:/htdocs"

1.4 httpd -k startでapacheが起動

2.PHPを設定
2.1 「php-5.3.6-Win32-VC9-x64.zip」を「D:\server\php-5.3.6-Win32-VC9-x64」へ解凍
2.2 php.ini-developmentを「php.ini」へリネームする
2,3 .php.iniの修正内容
display_errors = Off
extension_dir = “D:/server/php-5.3.6-Win32-VC9-x64/ext/
「;extension=php_gd2.dll、;extension=php_mysql.dll、;extension=php_mysqli.dll」の「;」を削除
date.timezone= Asia/Tokyo
3.MySQLをインストール
3.1 MySQLのインストールパッケージをダブルクリックして、「Next」をクリック
3.2 “I accept the terms in the License Agreement” 「Custom」を選択
3.3 “Entire feature will be installed on local hard drive"
3.4 Ready to Install the Program
3.5 MySQL Enterprise広告画面
3.6 Wizard Complete -「Launch the MySQL Instance Configuration Wizard」
3.7 Next
3.8 Please select a configuration type:
「Detailed Configuration」を選択
3.9 Please select a server type :
Developer Machine
3.10 Please select a database usage:
Multifuctional Database
3.11 Please select the drive for the InnoDB datafile:
そのまま Next
3.12 Please set the approximate number of concurrent connections to the server:
Decision Support(DSS)/OLAP
3.13 Please select the networking options:
TCP/IP 選択
Enable Strict Mode  選択
3.14 Please select the character set:
UTF8を選択
3.15 Please set the windows options:
Install As Windows Service 選択
Include Bin Directory in Windows PATH 選択
3.16 Please set the security options:
Modify Security Settings 選択
Create An Anonymous Account 選択
3.17  Ready to execute
3.18  「C:\Program Files\MySQL\MySQL Server 5.5\lib\」のlibmysql.dllを「C:\Windows\System32」へコピーする,
それからApacheを再起動してください。
3.19  「D:\htdocs\」直下にinfo_test.phpを作成、中身は<?php phpinfo(); ?> です。
次のURLを入力して設定内容を確認する
http://localhost/info_test.php
3.20  サイトディレクトリ内のindex.phpを変更
<?php

$host=’localhost’;
$user_name=’root’;

$password=’startnews24_pwd’;
$conn=mysql_connect($host,$user_name,$password);
if (!$conn) {
die('データベース接続に失敗した:’.mysql_error());

} echo 'データベース接続に成功した!’;

if (mysql_close($conn))

{  echo '<br/>…<br/>’;

echo 'データベースの接続はすでに閉めました’; }

?>
http://localhostでデータベース接続に成功するかどうかを確認する

 

PHP

Posted by arkgame