Home > Dịch vụ VPS > Hệ điều hành Centos > CÀI ĐẶT APACHE 2 VỚI PHP5 VÀ MYSQL TRÊN CENTOS 6.3

CÀI ĐẶT APACHE 2 VỚI PHP5 VÀ MYSQL TRÊN CENTOS 6.3

1. Ghi chú:

Bài viết này tôi sử dụng hostname tên là: server1.example.com với địa chỉ IP là 192.168.0.100.

2. Cài đặt MySQL 5

Cài đặt MySQL ta sử dụng câu lệnh bên dưới:

Để MySQL có thể tự khởi động cùng hệ thống:

Set mật khẩu root:

Thông tin trên màn hình hiển thị như bên dưới:

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] <– ENTER
New password: <– yourrootsqlpassword
Re-enter new password: <– yourrootsqlpassword
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] <– ENTER
… Success!

Normally, root should only be allowed to connect from ’localhost’.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <– ENTER
… Success!

By default, MySQL comes with a database named ’test’ that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <– ENTER
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <– ENTER
… Success!

Cleaning up…

All done!  If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

3. Cài đặt Apache 2

Set để dịch vụ tự khởi động cùng hệ thống:

Khởi động dịch vụ:

Vào trình duyệt gõ vào: http://192.168.1.100 Xuất hiện như hình bên dưới:

Cài đặt apache 2 với php5 và MySQL trên CentOS 6.3(LAMP)

Đường dẫn mặc định chứa Source tại: /var/www/html, và file cấu hình được lưu tại/etc/httpd/conf/httpd.conf. Và các file chứa các cấu hình mở rộng được lưu tại: /etc/httpd/conf.d/.

4. Cài đặt PHP5

Bạn phải khởi động lại dịch vụ apache khi cài xong php

5. Kiểm tra cài đặt PHP

Bạn có thể kiểm tra thông tin cài đặt PHP bằng cách. Tạo 1 tập tin nhứ sau:

với nội dung:

Bây giờ, bạn vào trình duyệt gõ: http://192.168.0.100/info.php
Cài đặt apache 2 với php5 và MySQL trên CentOS 6.3(LAMP)

6. Để MySQL được hỗ trợ trong PHP5

Cài đặt các gói sau:

Cài đặt APC:

Và bây giờ khởi động lại apache để nhận cấu hình:

Vào trình duyệt gõ: http://192.168.0.100/info.php

Cài đặt apache 2 với php5 và MySQL trên CentOS 6.3(LAMP)