Chủ đề nóng: Giáo án Điện tử • Sách giáo khoa • Học tiếng Anh • Bài giảng trực tuyến • Công lý: Việc đúng nên làm • Món ăn bài thuốc • Chăm sóc bà bầu • Môi trường • Tiết kiệm điện
Cài đặt Apache 2, PHP 5, MySQL 5 trên Windows 7 64-bit
Bài từ Tủ sách Khoa học VLOS
Hướng dẫn dưới đây được tác giả thực hiện thành công trên Laptop Lenovo G460 với hệ điều hành Windows 7 Ultimate 64 bit.
|
Bộ cài
- Apache 2.2.17:
httpd-2.2.17-win32-x86-no_ssl.msi(download) - Php 5.2.17:
php-5.2.17-Win32-VC6-x86.zip(download) - MySQL 5.1.56:
mysql-5.1.56-winx64.msi(download) - phpMyAdmin 3.3.9.2:
phpMyAdmin-3.3.9.2-english.7z(download)
Đường dẫn cài đặt
-C:/ |-AMP |-apache |-php |-mysql |-temp -E:/ |-www |-phpMyAdmin |-index.html |-index.php
Cài đặt và cấu hình
1) Cài đặt Apache theo đường dẫn trên
2) Cấu hình Apache, dùng trình soạn thảo văn bản mở file c:\amp\apache\conf\httpd.conf
- Thay
DocummentRoot "c:\apache\htdocs"thànhDocumentRoot "e:/www" - Thay
<Directory "c:\apache\htdocs">thành<Directory "e:/www"> - Trong tag
<Directory "e:/www">thayAllowOverride NonethànhAllowOverride All - Thay
DirectoryIndex index.htmlthànhDirectoryIndex index.html index.php
3) Khởi động lại Apache
4) Kiểm tra kết quả cài đặt
- Soạn một file:
e:\www\index.html - Truy cập vào địa chỉ:
http://localhost
5) Cài đặt PHP theo đường dẫn trên
6) Cấu hình Apache cho PHP:
- Mở file
c:\amp\apache\conf\httpd.conf - Bổ sung vào cuối file đoạn mã:
AddType application/x-httpd-php .php
LoadModule php5_module "c:/amp/php/php5apache2_2.dll"
PHPIniDir "c:/amp/php"
7) Cấu hình PHP:
- Mở thư mục
e:\amp\php - Đổi tên file
php.ini-recommendedhoặc filephp.ini-developmentthànhphp.ini - Mở file
php.ini - Copy đoạn mã sau vào cuối file
php.ini:
doc_root = "e:\www" ; MUST BE THE SAME AS IN Httpd.conf session.save_path = "c:/amp/temp" ; DIRECTORY MUST EXIST extension_dir = "c:\amp\php\ext" ; FOR PHP 5 ONLY
8) Khởi động lại máy
9) Kiểm tra kết quả cài đặt và cấu hình cho PHP
- Soạn một file
e:\www\index.phpvới mã<?php phpinfo(); ?> - Truy cập
http://localhost/index.php
10) Cài đặt MySQL
- Chọn thư mục
Program Fileslà thư mụcc:\amp\mysql - Chọn thư mục
ProgramDatatheo mặc định của chương trình - Mọi bước tiếp theo đều theo mặc địch, chỉ cần "Next". Khi chương trình hỏi có cấu hình MySQL bây giờ không, hãy bỏ qua tùy chọn này và kết thúc cài đặt
11) Cấu hình MySQL và PHP cho MySQL
- Vào thư mục
C:\AMP\mysql\bin, nhấp chuột phải vào fileMySQLInstanceConfig.exe, chọn "Run as Administrator" - Tiếp tục "Next and Next" đến khi chọn bảng ngôn ngữ thì chọn "Utf-8" sau đó "Next" cho đến hết.
- Mở file
c:\amp\php\php.ini - Sửa
;extension=php_mbstring.dllthànhextension=php_mbstring.dll - Sửa
;extension=php_mysql.dllthànhextension=php_mysql.dll - Sửa
;extension=php_mysqli.dllthànhextension=php_mysqli.dll
12) Khởi động lại máy
13) Kiểm tra kết quả cài đặt MySQL
- Mở file
e:\www\index.php - Bổ sung thêm đoạn file:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
- Truy cập
http://localhost/index.php
14) Giải nén và đổi lại tên file phpMyAdmin vào thư mục e:\www
15) Cấu hình phpMyAdmin
- Đổi tên file
e:\www\phpMyAdmin\config.sample.inc.phpthànhconfig.inc.php - Mở file
config.inc.php - Sửa
$cfg['blowfish_secret'] = ; /* YOU MUST FILL...thành$cfg['blowfish_secret'] = 'go_mot_day_ki_tu_vao_day'; /* YOU MUST FILL...
16) Kiểm tra
- Truy cập vào
http://localhost/phpmyadminvà gõ username và pass của MySQL.
Quá trình cài đặt đến đây kết thúc.
Chúc BẠN may mắn!
Gỡ bỏ và cài lại MySQL
- Gỡ bỏ chương trình (Control Panel --> ...)
- Xóa hai thư mục sau:
c:\amp\mysqlvàc:\ProgramData\MySQL - Bắt đầu lại quá trình cài đặt MySQL nếu muốn.
Xem thêm
Tham khảo
- Install PHP on Windows 7
- Install Apache on Windows 7 - how to
- How to install MySQL on Windows 7
- Install phpMyAdmin on Windows 7 - How to instructions
- Install Apache HTTP Server + PHP5 on Windows 7 (64bit)
- Tutorial : Installing Apache 2.2.11, PHP 5.3, MySQL 5.1.36 & PhpMyAdmin 3.2 in Windows 7/Vista/XP
- Can't install mysql 5.1 on a windows machine because the last install left artifacts.
- Configuring PHP with MySQL for Apache 2 or IIS in Windows

