Ngay trong bản thân hệ điều hành CentOS đã có sẵn bộ server Apache, PHP, MySQL rồi, có điều các bộ cài đặt này theo 1 version chuẩn sẵn có.
1. Cài đặt apache và PHP
Cài apache và PHP (đây là PHP 4; CentOS chưa đưa ra PHP 5):
yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel
sau đó edit /etc/httpd/conf/httpd.conf:
vi /etc/httpd/conf/httpd.conf
và chuyển DirectoryIndex tới
DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl
Cấu hình nó khởi dộng ban đầu nào (khi linux khởi động – nó start luôn):
chkconfig --levels 235 httpd on
Start Apache:
/etc/init.d/httpd start
2. Cài đặt Mysql
Để cài MySQL, chạy lệnh:
yum install mysql mysql-devel mysql-server
nó hỏi gì thì yes -> nó sẽ tìm và download thằng mysql về và cài đặt.
(note: theo những ng có kinh nghiệm về CentOS server – thì MYSQL đuợc cài đặt sẵn ở đây có một chút lỗi khi ta restart. Để sửa lỗi ta dùng vi edit file này
vi /etc/init.d/mysqld
restart(){
stop
start
}
Ta thêm 1 dòng sleep 3 vào giữa stop và start. )
Sau đó cho MySQL tự động bắt đầu khi khởi dộng linux (boot linux):
Và start
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
check thử xem chạy chưa nèo
netstat -tap
(hoặc áp dụng thử lệnh grep để tìm kiếm)
netstat –tap | grep my
Note: nếu nó ko chạy thì ta phải làm thêm 1 bước nữa
vi /etc/my.cnf
#skip-networking
/etc/init.d/mysqld restart
Đặt password root:
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
3. BONUS: hướng dẫn cấu hình ISPConfig (disable PHP Globally).
ISPConfig được sử dụng đối với nhiều site cấu hình khác nhau chạy trên cùng một server.
Ví dụ bạn tạo 1 alias của img.sannhac.com tại server này, như vậy mặc định của nó là … cũng chạy PHP luôn. Điều này rất nguy hiểm nếu quá trình upload check không kỹ type extensions. Chính vì thế, Apache có nhiều option – site sẽ không đc chạy PHP chẳng hạn – là do cấu hình của ISPConfig ^_^
Đầu tiên
vi /etc/httpd/conf.d/php.conf
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php4_module modules/libphp4.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
#AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
Sau đó Restart Apache:
/etc/init.d/httpd restart
Không có nhận xét nào:
Đăng nhận xét