H??ng d?n cài ??t LAMP (APACHE-PHP-MYSQL) và t?o ...
-
Upload
khangminh22 -
Category
Documents
-
view
3 -
download
0
Transcript of H??ng d?n cài ??t LAMP (APACHE-PHP-MYSQL) và t?o ...
H??ng d?n cài ??t LAMP (APACHE-PHP-MYSQL) vàt?o VirtualHost trên Debian 8 admin Sun, Apr 14, 2019 Chứng Chỉ Số SSL Certificates 0 1166
LAMP là m?t nhóm các ph?n m?m mã ngu?n m? ???c s? d?ng ?? ch?y các máych? web, LAMP vi?t t?t là vi?t t?t c?a Linux, Apache, MySQL, và PHP
Debian là m?t h? ?i?u hành máy tính, là b?n phân ph?i mi?n phí ???c pháttri?n t? s? c?ng tác c?a các tình nguy?n viên trên kh?p th? gi?i. Debian ???c xâyd?ng d?a trên n?n t?ng linux v?i nhi?u công c? c? b?n c?a h? ?i?u hành
Sau ?ây tôi s? h??ng d?n các b?n làm th? nào ?? có th? cài ??t LAMP trênDebian
Tr??c khi b?t ??u cài ??t hay c?p nh?t h? th?ng c?a b?n
# apt-get update -y
B??c 1: Cài ??t apache
?? cài ??t Apache, chúng ta s? gõ l?nh sau
# apt-get install apache2 -y
Sau khi cài ??t xong, các b?n có th? ki?m tra b?ng cách truy c?p ??ach? http://<??a ch? ip VPS>/ c?a b?n trên trình duy?t
B??c 2: Cài ??t php
?? cài ??t PHP ta gõ các l?nh sau, ta nên cài ??t php 5 tr? lên
# apt-get install php5 php-pear php5-mysql -y
Kh?i ??ng l?i apache
# service apache2 restart
?? ki?m tra xem PHP trên server c?a b?n, chúng ta s? t?o 1 file info.php
# nano /var/www/html/info.php
Thêm vào dòng sau
<? Php phpinfo (); ?>
Sau ?ó truy c?p vào trình duy?t theo ???ng d?n http://<??a ch? ipVPS>/info.php và xem k?t qu? nh? sau
B??c 3: Cài ??t Mysql
MySQL là m?t h? th?ng qu?n lý c? s? d? li?u r?ng rãi tri?n khai s? d?ng cho cáct? ch?c và l?y d? li?u.
?? cài ??t Mysql, ta gõ l?nh sau
# apt-get install mysql-server -y
Trong khi cài ??t, MySQL s? yêu c?u b?n thi?t l?p m?t m?t kh?u ch?. N?u b?n b?l? c? h?i ?? thi?t l?p m?t kh?u trong khi các ch??ng trình ???c cài ??t, nó là r?t d?dàng ?? thi?t l?p m?t kh?u sau ?ó t? bên trong MySQL.
Nh?p l?i m?t kh?u
Cu?i cùng ch?y l?nh thi?t l?p b?o v? cho Mysql
# mysql_secure_installation
Nó s? hi?n ra danh sách sau
Enter current password for root (enter for none): <-- ?n enter Set root password? [Y/n] <-- ?n "y" ?? nh?p m?t kh?u Mariadb New password: <-- nh?p m?t kh?u Mariadb m?i Re-enter new password: <-- nh?p l?i m?t kh?u Mariadb m?i Remove anonymous users? [Y/n] <-- ?n "y" Disallow root login remotely? [Y/n] <-- ?n "y" Reload privilege tables now? [Y/n] <-- ?n "y"
??ng nh?p vào MySQL
# mysql -u root -p
B??c 4: T?o VirtualHost
T?o 1 th? m?c ?? ch?a các code web
# mkdir -p /var/www/maxserver.com/public_html
T?o 1 th? m?c ch?a các log c?a web ?ó
# mkdir /var/www/maxserver.com/log/
Phân quy?n cho th? m?c
# chmod -R 755 /var/www/
C?u trúc th? m?c c?a apache2
/etc/apache2/sites-available/ :Th? m?c ch?a các file c?u hình VirtualHost
/etc/apache2/sites-enabled/ : N?u mu?n cho domain ?c c?u hình trong th?m?c /etc/apache2/sites-available/ thì ph?i enabled file c?u hình ?ó lên b?ng cácht?o liên k?t ??n th? m?c này
/etc/apache2/sites-available/000-default.conf : file c?u hình VirtualHost m?c??nh c?a h? th?ng ,d?a vào file này b?n c?u hình nhi?u domain khác
/etc/apache2/sites-available/default-ssl.conf : ?ây c?ng là file c?u hình m?c??nh c?a h? th?ng ,d?a vào file này ?? c?u hình ssl
Ví d? ta t?o file c?u hình cho domain paste.vn
# nano /etc/apache2/sites-available/maxserver.com.conf
v?i n?i cung nh? sau :
<VirtualHost *:80> ServerName maxserver.com ServerAlias www.maxserver.com ServerAdmin [email protected] DocumentRoot /var/www/maxserver.com/public_html ErrorLog /var/www/maxserver.com/log/error.log CustomLog /var/www/maxserver.com/log/access.log combined
<Directory /var/www/maxserver.com/public_html> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost>
Bây gi? ta s? enabled file paste.vn.conf b?ng l?nh sau
# a2ensite maxserver.com
S? cho k?t qu? nhu sau ;
Enabling site maxserver.com To activate the new configuration, you need to run: service apache2 reload
Kh?i ??ng l?i d?ch v? apache2
# service apache2 restart
Ta t?o th? 1 file ?? xem k?t qu?
# nano /var/www/maxserver.com/public_html/index.html
Có n?i dung nh? sau
<html>
<head> <title>maxserver.com</title> </head> <body> <h1>Chuc mot ngay tot lanh!</h1> </body> </html>
Ta truy c?p domain ?? xem k?t qu?
??n ?ây chúng ta ?ã k?t thúc bài h??ng d?n cài ??t LAMP cho Debian 8, chúccác b?n thành công
Online URL:https://huongdan.maxserver.com/article/hướng-dẫn-cài-đặt-lamp-apache-php-mysql-và-tạo-virtualhost-trên-debian-8-95.html
Powered by TCPDF (www.tcpdf.org)