Hướng dẫn cài đặt Apache2 với PHP5 và MySQL h
trợ trên nền tảng Mandriva 2010.1 Spring (LAMP)
Trong bài hướng dẫn sau, Quản Trị Mạng sẽ giới thiệu với các
bạn cách cài đặt webserver Apache2 trên hệ thống server
Mandriva 2010.1 Spring với PHP5 (module m
od_php) và MySQL
hỗ trợ. Thuật ngữ LAMP đây là dạng viết tắt của tổ hợp Linux,
Apache, MySQL, PHP.
Lưu ý sơ bộ
Trong hệ thống thử nghiệm này, chúng ta sdụng hostname
server1.example.com với địa chIP: 192.168.0.100. Hãy thay thế các
thông s này cho tương ứng và phù hợp với hệ thống của bạn.
Cài đặt MySQL 5
Trước tiên, chúng ta cần cập nhật cơ sở dữ liệu của các gói cài đặt:
urpmi.update -a
Cài đặt MySQL bằng lệnh sau:
urpmi MySQL MySQL-client
Ở chế độ mặc định, tính năng hỗ trợ mạng không được kích hoạt
trong gói Mandriva 2010.1 Spring MySQL. Chúng ta hoàn toàn có
thể thay đổi được điều này bằng cách chú thích tại dòng lệnh skip-
networking trong file /etc/my.cnf:
vi /etc/my.cnf
[...]
# Don't listen on a TCP/IP port at all. This can be a security
enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or
named pipes.
# Note that using this option without enabling named pipes on
Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
[...]
Sau đó, khởi động MySQL:
/etc/init.d/mysqld start
Kiểm tra lại xem tính năng hỗ trợ mạng đã được kích hoạt chưa bằng
lệnh:
netstat -tap | grep mysql
Kết quả trả về của hệ thống sẽ trông giống như sau:
[root@server1 ~]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 2459/mysqld
[root@server1 ~]#
Tiếp theo, sử dụng lệnh:
mysql_secure_installation
để đặt mật khẩu cho tài khoản root (nếu không bất cứ ai cũng có thể
truy cập vào cơ sở dữ liệu MySQL):
[root@server1 ~]# 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): <-- nhấn ENTER
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] <-- nhấn ENTER
New password: <-- mật khẩu SQL root
Re-enter new password: <-- mật khẩu SQL root
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] <-- nhấ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.