Hướng dẫn cài đặt Apache, Mysql, phpMyadmin trên VPS

Bước Mô tả các bước Lệnh command Chú ý
1 Cài Apache sudo apt-get install apache2
Enable mod rewrite a2enmod rewrite
Add dòng này vào file vhost:
/etc/apache2/site-enable/000.domain.com.conf
ServerAlias www.domain.com
<Directory “/var/www/ten thu muc”>
AllowOverride All
</Directory>
restart apache sudo service apache2 restart
2 Cài php sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
Cài x-cache sudo apt-get install php5-xcache
restart apache sudo service apache2 restart
3 Cài MySQL sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
kích hoạt mysql_install_db
4 Cài đặt phpMyadmin
Bật module mcrypt php5enmod mcrypt
cài đặt phpMyAdmin apt-get install phpMyAdmin Chọn apache2 bằng nút SpaceBar và Enter
Xong tới configuring chọn Yes nhấn Enter
Nhập Pass 3 lần cho phpmyadmin rồi Enter
Chèn “Include /etc/phpmyadmin/apache.conf” vào cuối file apache2.conf nano /etc/apache2/apache2.conf Include /etc/phpmyadmin/apache.confSave bằng Ctrl + O -> Enter -> Ctrl + X để thoát
restart apache service apache2 restart
Có thể khởi động phpmyadmin bằng link http://domain/phpmyadmin – http://IP/phpmyadmin
5 Phân quyền thư mục tập tin cho apache và php chown -R www-data:www-data /var/www/tenthumuc Để cài thêm plugin cho website cho database co quyen ghi
chmod -R 777 /var/www/tenthumuc Để chỉnh sửa file trên host Thu muc
6 Nén tập tin
Chuyển thư mục để file nén cd /var/www/
nén thư mục thành tập tin tar -czvf tenfile.tar.gz /var/www/tenthumuc như vầy là khi giải nén sẽ có var/www/tenthumuc
Chuyển tđến thư mục cần nén cd /var/www/anchor
Giải nén thư mục tar -zxvf tenfile.tar.gz tar xopf foo.tar
Xóa tập tin hoặc thư mục rm -rf tenfile , rm -rf tenthumuc/*
7 Sửa dung lượng upload trên phpmyadmin
Mở file php.ini nano /etc/php5/apache2/php.ini
Tìm dòng upload_max_filesize (Ctrl + W -> gõ upload_max_filesize) sửa dung lượng lại -> Ctrl + X -> gõ Y (Yes) -> Enter
Tìm dòng post_max_size (Ctrl + W -> gõ post_max_size) sửa dung lượng lại -> Ctrl + X -> gõ Y (Yes) -> Enter
restart apache service apache2 restart
8 Cài htop apt-get install htop
9 Cài Swap
2GB là 2048k sudo dd if=/dev/zero of=/swapfile bs=1024 count=2048k 4096
sudo mkswap /swapfile
Enable file swap đã tạo sudo swapon /swapfile
Xem swap swapon -s
10 Resize Swap
Tắt Swap sudo swapoff /swapfile
4GB là 4100k sudo dd if=/dev/zero of=/swapfile bs=1024 count=4100k
Enable file swap đã tạo sudo swapon /swapfile
11 Install zip unzip apt-get install zip unzip
Nén rar -r tenfile.rar tenthumuc
Giải nén unzip tenfile.rar
12 sudo nano /etc/php5/apache2/php.ini Ctrl + W -> gõ “short_open_tag” ->sửa thành short_open_tag=On -> ctrl + X -> Enter
restart apache service apache2 restart

Leave a Reply