Thứ Tư, 21 tháng 5, 2014

// // 2 comments

Cấu đặt Virtual Host và Magento trên Debian 7

Phân quyền:
#Phân quyền 755 cho tất cả các folder trong  /home/thehai/
root@wisehome:~# find /home/thehai/ -type d -exec chmod 755 {} +
#Phân quyền 644 cho tất cả các file trong  /home/thehai/
root@wisehome:~# find /home/thehai/ -type f -exec chmod 644 {} +
Tạo Virtual Host - MAGENTO-TEST.COM:
B1: Tạo thư mục lưu trữ website mới:
# mkdir -p /home/thehai/magento-test.com/public_html
B2: Cấp quyền sở hữu thư mục này cho người dùng:
# chown -R $USER:$USER /home/thehai/magento-test.com/public_html/
Phân quyền để đảm bảo tất cả mọi người có thể đọc được các tập tin mới (có thể xem chú thích phía trên cùng)
# chmod -R 755 /var/www/
B3: Tạo 1 file đơn giản để test:
# nano /home/thehai/magento-test.com/public_html/index.html
B4: Tạo file Virtual Host từ file mẫu sẵn có:
# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/magento-test.com
B5: Cấu hình và khởi động Virtual Host này:
- Cấu hình:
root@wisehome:~# cat /etc/apache2/sites-available/magento-test.com
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName magento-test.com
        ServerAlias www.magento-test.com
        DocumentRoot /home/thehai/magento-test.com/public_html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- Kích hoạt Virtual Host:
# a2ensite magento-test.com
B6: Khởi động lại Apache:
# service apache2 restart
Test trên trình duyệt:
(sửa file host trỏ về IP Server)

Cài đặt và cấu hình Magento:
Tải Magento và Sample Data:
# wget http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz
# wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
Giải nén magento vào thư mục public_html của virtual host vừa tạo ở trên:
# tar -zxf magento-1.9.0.1.tar.gz
# cp -fr magento/* magento-test.com/public_html/
# cp magento/.htaccess magento-test.com/public_html/
# ls magento-test.com/public_html/
api.php     favicon.ico       install.php      mage               skin
app         get.php           js               media              var
cron.php    includes          lib              php.ini.sample
cron.sh     index.html        LICENSE_AFL.txt  pkginfo
downloader  index.php         LICENSE.html     RELEASE_NOTES.txt
errors      index.php.sample  LICENSE.txt      shell
Tạo database mới cho web này:
Đăng nhập Database bằng user root:
root@wisehome:/home/thehai# mysql -u root -p
Enter password:  <~~ nhập mật khẩu
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.5.37-0+wheezy1 (Debian)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
Giả sử bây giờ mình sẽ tạo một database với thông tin như sau:
Database Name: magento-test
Database User: taikhoan
Database Password: matkhau
#Tạo database
mysql> CREATE DATABASE magentotest;
Query OK, 1 row affected (0.09 sec)
#Tạo user
mysql> CREATE USER taikhoan@localhost;
Query OK, 0 rows affected (0.08 sec)
#Gán mật khẩu cho user này:
mysql> SET PASSWORD FOR taikhoan@localhost= PASSWORD("matkhau");
Query OK, 0 rows affected (0.04 sec)
#Phân quyền cho user vừa tạo với database
mysql> GRANT ALL PRIVILEGES ON magentotest.* TO taikhoan@localhost IDENTIFIED BY 'matkhau';
Query OK, 0 rows affected (0.04 sec)
#Làm mới:
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
#Thoát
mysql> exit
Bye
Import database sample vào data mới vừa tạo:
# mysql -u taikhoan -p -h localhost magentotest < magento_sample_data_for_1.6.1.0.sql
Enter password:
Một số phần mở rộng quan trọng và phân quyền:
chmod 777 để đảm bảo có thể cài đặt đc ok , sau đó có thể chmod lại thành 755 và 644 sau:
# chmod -R 777 magento-test.com/public_html/
Cài đặt một số phần nâng cao cần thiết:
# apt-get install php5-curl
;extension=php_mcrypt.dll
;extension=php_curl.dll------
;extension=php_pdo_mysql.dll
;extension=php_pdo.dll
extension=php_pdo_sqlite.dll
extension=php_soap.dll
Mở trình duyệt và tiến hành cài đặt Magento:

2 nhận xét:

  1. root@thehai:~# chown www-data:www-data /home/haipro/public_html/ -R
    sua loi rewrite

    Trả lờiXóa
  2. root@thehai:~# chown -R haipro:www-data /home/haipro/public_html/

    Trả lờiXóa

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.