Tải bản đầy đủ (.pdf) (8 trang)

Hướng dẫn cài đặt Apache2 với PHP5 và MySQL hỗ trợ trên nền tảng Mandriva... pps

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (181.79 KB, 8 trang )

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 sử dụng hostname
server1.example.com với địa chỉ IP: 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.

Disallow root login remotely? [Y/n] < nhấ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] < nhấ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] < nhấ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!


[root@server1 ~]#
Cài đặt Apache2

Apache2 đã có sẵn trong gói cài đặt của Mandriva, do vậy hãy sử
dụng lệnh sau:
urpmi apache-mpm-worker
Và khởi động Apache:
/etc/init.d/httpd start
Bây giờ, mở trình duyệt và gõ địa chỉ http://192.168.0.100, nếu thành
công thì bạn sẽ thấy trình duyệt hiển thị như sau:

Thư mục tài liệu mặc định của Apache là /var/www/html trên
Mandriva, còn file cấu hình thì được lưu trữ tại

/etc/httpd/conf/httpd.conf. Các file thiết lập khác được lưu tại thư m
ục
/etc/httpd/conf.d/



×