Home » Categories » VPS » VPS Linux |
Hướng dẫn cài đặt LAMP (Linux, Apache, MySQL, PHP) trên CentOS 6 |
Article Number: 7 | Rating: Unrated | Last Updated: Fri, Feb 26, 2016 at 10:06 PM
|
Do đã xuất hiện từ lâu nên LAMP (viết tắt của Linux, Apache, MySQL, và PHP) được dùng rất phổ biến trên thế giới. Các bước cài đặt LAMP trên CentOSĐầu tiên bạn cần chuẩn bị một server CentOS mới tinh chưa cài gì cả, ở đây mình dùng CentOS 6.4 64bit. Trước khi thao tác bạn cần phải đổi lại hostname và chỉnh sửa file host. 1. Cài đặt Apacheyum install httpd Đường dẫn file cấu hình Apache: /etc/httpd/conf/httpd.conf Khởi động Apache service httpd start Test thử bằng cách truy cập vào http://<youraddress> bạn sẽ thấy thông báo “Apache 2 Test Page” Lưu ý: bạn có thể cần phải stop iptables nhé service iptables stop kết quả:
Cấu hình Apache Virtual Hosts – Tạo một file cấu hình ở thư mục Nội dung file NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin webmaster@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html/ ErrorLog /var/www/example.com/logs/error.log CustomLog /var/www/example.com/logs/access.log combined </VirtualHost> – Tạo thư mục cho website mkdir -p /var/www/example.com/public_html mkdir /var/www/example.com/logs – Nếu muốn thêm website, bạn chỉ cần tạo thêm một file .conf khác và reload lại Apache với lệnh: 2. Cài đặt MySQLyum install mysql-server service mysqld start Tiến hành cài đặt MySQL bằng lệnh /usr/bin/mysql_secure_installation Do mới cài đặt nên nếu bị hỏi password bạn nhấn Enter Enter current password for root (enter for none): OK, successfully used password, moving on... Sau đó cần đặt root password bằng cách chọn y Tiếp theo bạn sẽ phải trả lời một loạt các câu hỏi, tốt nhất cứ chọn y 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] y ... 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] y ... 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] y - 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] y ... 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 PHPyum install php php-mysql PHP Modules PHP có rất nhiều thư viện module khác nhau, bạn có thể xem bằng cách gõ lệnh sau yum search php- php-bcmath.x86_64 : A module for PHP applications for using the bcmath library php-cli.x86_64 : Command-line interface for PHP php-common.x86_64 : Common files for PHP php-dba.x86_64 : A database abstraction layer module for PHP applications php-devel.x86_64 : Files needed for building PHP extensions php-embedded.x86_64 : PHP library for embedding in applications php-enchant.x86_64 : Human Language and Character Encoding Support php-gd.x86_64 : A module for PHP applications for using the gd graphics library php-imap.x86_64 : A module for PHP applications that use IMAP Để cài module nào dùng lệnh sau yum install name of the module 4. Tự động chạy service khi rebootchkconfig httpd on chkconfig mysqld on Restart Apache service httpd restart OK vậy là quá trình cài đặt LAMP trên CentOS vậy là xong. Xem thêm: |
Attachments
There are no attachments for this article.
|
Comments There are no comments for this article. Be the first to post a comment. |
Cài đặt EPEL và REMI Repo trên CentOS 7/6/5
Xem 1206 - Đăng ngày Sat, Feb 27, 2016
How to Back Up and Restore a MySQL Database
Xem 748 - Đăng ngày Tue, Mar 1, 2016
Cài đặt FTP Server đơn giản trên CentOS với ProFTPD
Xem 2752 - Đăng ngày Sat, Feb 27, 2016
Thay đổi Timezone trên CentOS
Xem 605 - Đăng ngày Fri, Feb 26, 2016
Thay đổi Timezone trên Ubuntu
Xem 874 - Đăng ngày Fri, Feb 26, 2016
Cài đặt và bảo mật phpMyAdmin trên CentOS
Xem 1495 - Đăng ngày Fri, Feb 26, 2016
Cập nhật phiên bản PHP 5.3.X lên 5.4.X hoặc 5.5.X trên CENTOS
Xem 3790 - Đăng ngày Wed, Mar 2, 2016
Hướng dẫn kết nối sFTP bằng FileZilla
Xem 2912 - Đăng ngày Sat, Feb 27, 2016
Hướng dẫn Tạo DKIM tên miền trên Zimbra Mail Server
Xem 870 - Đăng ngày Fri, Apr 17, 2020
Thay đổi Timezone trên CentOS theo đúng múi giờ Việt Nam
Xem 797 - Đăng ngày Thu, Aug 11, 2016
|