Magento初探

magento是一款專業開源的電子網站系統.我在09年6月份初次接觸,14年12月份再次用到,於是更新了一下之前的筆記,發到博客跟大家分享.


Intro

Magento官方網站

Magento維基介紹

 

參考資源

1Magento Designers Guide

2Magento Forum(Chinese)

3專注magento開發的技術博客inchoo

4、《Magento: Beginner's Guide

5、《Inchoo's Magento Posts

6Magento User Guide

7Magento中文項目組


GetStarted

Installing Magento

step1下載magento並解壓

下載社區版FullRelease壓縮包.例如當前我下的最新版本magento-1.9.1.0.zip.

 

step2安裝環境

httpserver:apache http server

配置支持php

數據庫:mysql

數據庫管理工具:phpmysqlAdmin

具體安裝步驟見安裝配置

 

step3安裝magento

mysql創建數據庫magento

magento上傳至web server並訪問,進入magento的安裝嚮導

 

Using Magento

假設192.168.1.66:2906是你假設的服務器所在地址.

Frontend

http://192.168.1.66:2906/magento/index.php/

 

Backend

http://192.168.1.66:2906/magento/index.php/admin/

 

注意:本地使用127.0.0.1取代localhost,否則登錄不上去(安全設置)

 

Configuring Magento

漢化magento,詳情見Magento漢化


安裝配置

@@   作者:天涯

 

@@   時間:07-09-10

 

@@   目的:供女友參考學習用

 

@@   注意:安裝的版本,和解壓的路徑

 

 

 

 

一. windows  使用配置總結(此教程的講解一定要注意版本,不同的版本一下會告訴有不同的配置)路徑也要十分注意

 

 

1)apache的安裝詳解:安裝路徑爲(D:\tianya\www\Apache)      注意:安裝路徑中儘量不要有空格和中文。

 

    1.

下載http://apache.mirror.phpchina.com/httpd/binaries/win32/

       下載apache_2.2.4-win32-x86-openssl-0.9.8d.msi 進行安裝

    2. 

注意默認端口是80

安裝成功後啓動apache訪問http://localhost

    3.

apache的配置文件\conf\httpd.conf

        apache的默認的項目存放目錄\htdocs\

 

2)apache的一些常用配置(http.conf)        

 

    1。

關鍵字“DocumentRoot”(也就是網站根目錄).注意:“\”在Apache裏要改成“/”

注:sld 2009-7-11新版沒有這個問題,確認有沒有這個問題,可以直接訪問http://localhost 如果顯示It works,則沒有這個問題

 

    2。

DirectoryIndex(目錄索引,也就是在僅指定目錄的情況下,默認顯示的文件名)可以添加很多,系統會根據從左至右的順序來優先顯示,

以單個半角空格隔開。例如:

    (

<IfModuledir_module>

   DirectoryIndex index.php index.html //index.htm. . . , 其它默認的文件名

</IfModule>

      )   

 

2)php的安裝、以module方式,將php與apache結合使你的網站服務器支持php服務器腳本程序

 

     1.  下載php5.zip解壓

    

     2. 

php5目錄下的文件php.ini-recommended改名爲php.ini並作如下改動:(php.ini這個文件可以放在C:\WINDOWS下面,也可以不用放在系統下面)

 

    (1)找到user_dir=。它是服務器的根目錄,改爲:

 user_dir = "C:\Program Files\ApacheSoftware Foundation\Apache2.2\htdocs"                        ##指定php項目所放路徑

 doc_root = "C:\Program Files\ApacheSoftware Foundation\Apache2.2\htdocs" 

    (2)找到extension_dir=./改爲:

extension_dir =C:\Program Files\PHP\ext                                                                                              ##指定一些其它的模塊的dll存放路徑

 

 

     3.

 

對httpd.conf進行配置添加如下內容:

#對 PHP 5 用這兩行:

LoadModulephp5_module "D:/tianya/www/php/php5apache2_2.dll"     ##這點值得注意一點,(這是php5+apache2.2以上的版本的配製方法)

##LoadModulephp5_module "D:/tianya/www/php/php5apache2.dll"     ##這點值得注意一點,(這是php5+apache2.0以上的版本的配製方法)

##LoadModulephp5_module "D:/tianya/www/php/php5apache.dll"      ##這點值得注意一點,(這是php5+apache1.3以上的版本的配製方法)

AddType application/x-httpd-php .php                                          ##則.php文件也可以執行php程序了

AddTypeapplication/x-httpd-php .html                           ##則.htm文件也可以執行php程序了(自已多試一下就會明白這個擴展名的含義)

PHPIniDir"D:/tianya/www/php/"                                  ##是指明php的配置文件php.ini的位置

 

或者拷貝以下到httpd.conf

#BEGINPHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

ScriptAlias/php/ "D:/PHP5/"

PHPIniDir"E:/php5/"

AddTypeapplication/x-httpd-php .php

AddTypeapplication/x-httpd-php .html

Actionapplication/x-httpd-php "D:/PHP5/php-cgi.exe"

LoadModulephp5_module D:/PHP5/php5apache2_2.dll

 

#ENDPHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL

   以上完成了php+apache的配置此時,apahce已經支持php解析了,可以重起apache服務器放一個簡單的腳本試一下。

 

3)配置php可以用mysql作爲連接數據庫

 

    1。

更改php.ini文件

把“;extension=php_mysql.dll”前的“;”去掉,加載mysql模塊

extension=php_mysqli.dll

 

    2。 

到此地步php現在就可以作爲變成來用就配置完成了。此時就可以連接mysql數據庫。

 

 

 

4) php+mysqlAdmin+apache的配置實現phpmysqlAdmin的功能        (注意和第3步的區別)此時只是作爲使用mysql的一種工具

 

 

    1。

下載

http://sourceforge.net/project/downloading.php?group_id=23067&use_mirror=jaist&filename=phpMyAdmin-2.11.0-all-languages.zip&52587229

下載phpMyAdmin-2.11.0-all-languages.zip

 

     2.

 將其解壓到如下目錄

 D:\tianya\www\Apache\htdocs\phpMyAdmin

    

     3。

然後配置D:\tianya\www\Apache\htdocs\phpMyAdmin\config.sample.inc.php此文件

 

將其重命名爲config.inc.php

然後找到$cfg['blowfish_secret']= '';填入數據庫的密碼將其變爲$cfg['blowfish_secret'] = 'tianya';

然後保存,其他的都不用動。重起apache

 

訪問http://127.0.0.1/phpMyAdmin/index.php然後選折簡體中文,填入用戶名密碼就能登陸成功了

 

  

     4。值得注意的地方:

 

要確保

更改php.ini文件

把“;extension=php_mysql.dll”前的“;”去掉,加載mysql模塊

 

 

 

 

 

總結:      

以上就能使apache支持php並且有phpMyadmin的功能。如果上面有不懂得專業術語,查或者看隨帶的一個doc文檔,隨帶的那些只供參考,他們有很多說的都不對。

 

在安裝和配置的時候要多多用心會發現不少東西的。例如:http://127.0.0.1能訪問apache,但http://www.tianya.org.net也能訪問apache,因爲www.tianya.org.net是你在安裝的時候選擇的域名。(這是一種虛擬域名的配置方法)。

 

----------------以上是我根據國際網站http://www.php.net/manual/zh/index.php加上自己的實踐總結得出的以上結論----------------------

--------------------技術支持:天涯---------------------------------------------------

--------------------要依上面我寫的爲標準要不將會走很多彎路的。-----------------------------------------

 

 

集成方案

XAMPP及WAMP

http://www.magentoo.com/node/29


常見問題一覽

1、運行mysql測試文件testdb

錯誤提示Call  to undefined  function  'mysql_connect()'… 失敗

 

問題原因:PHP+MYSQL環境沒配置好, php5 的默認 mysql 是關閉的

解決方案:將php_mysql.dll和libmysql.dll文件拷貝至C:\Windows\System32中(我漏了libmysql.dll)

找到php.ini中的;extension=php_mysql,去掉前面的";" 重啓服務器

源文檔 <http://tech.ddvip.com/2007-08/118788865032825.html>

 

2、安裝magento需要php擴展

window下安裝php_curl支持

a.找到php.ini.修改extension=php_curl.dll把前面的分號去掉。

b.libeay32.dllssleay32.dll 複製到 %windir%/system32下。

重啓php的服務

無法載入 mcrypt 擴展

a、在php.ini配置中,將php_mcrypt.dll前的;去掉。

b、從php5中複製libmcrypt.dll到dlls目錄和system32目錄下。[dlls目錄不用也可]

重啓php的服務

 

 

3Magento Install Problem+ Solution sales_flat_quote already exists

Tuesday, March 10th,2009

Trying to do a cleaninstall of Magento 1.2.1.2 I kept hitting this SQL error.

Base table or view already exists: 1050 Table'sales_flat_quote' already exists

In the end I opted tomanually edit the related install file and add DELETE IF EXISTS statementsbefore each CREATE TABLE statement.

The file in questionis located here:

/app/code/core/Mage/Sales/sql/sales_setup

and the problem fileis

mysql4-install-0.9.0.php

The solution is toedit the file and add DROP TABLE IF EXISTS statements before each CREATE TABLEstatement

eg

PLAIN TEXT

PHP:

  1. DROP TABLE IF EXISTS  `{$installer->getTable('sales_flat_quote')}`;
  1.  
  1. CREATE TABLE `{$installer->getTable('sales_flat_quote')}`(.....

I have created anissue on their bug trackerhere.

 

源文檔 <http://www.edmondscommerce.co.uk/blog/category/magento/>

 

原因:在magento使用之前需要先安裝數據庫

 

4數據庫不存在

原因:MySQLAdminimport數據庫量過於巨大,timeout導致部分數據庫沒有載入。

解決方案:使用EMS sqlmanager for mysql的管理工具

or

php默認執行時間30s,timeout之後放棄數據庫導入導致數據庫導入失敗,php配置文件中設置

max_execution_time =300

 

5 php模塊配置不完全

需要curlgd擴展

php配置文件

extension=php_curl.dll

extension=php_gd2.dll

extension=php_pdo_mysql.dll


Magento漢化

1,漢化包下載

http://code.google.com/p/magento-cn/downloads/list @deprecated 最新版本1.2.1.2

http://www.magentocommerce.com/boards/viewthread/777/需要自己編輯

 

2,解壓後copy得到 app文件夾,在漢化包app文件夾查找到zh_ch文件夾。有三個zh_ch文件夾,分別把它們copy到相應的目錄下。

 

3.後臺登錄操作

A,System ->Manage Stores -> Create Store,創建店鋪

B, Configuration > general

語言選擇中文(中國)

Saveconfig 


Top 3mistakes by Magento beginners

First ofall, let me inform you that this article is for those of you who are juststarting with Magento. If you are a Magento expert, you will probably knowthis.  Consider it just a reminder for those who use Magento for firsttime. There are three common mistakes that most people do when they try to useMagento for first time, so read this article and you won’t be one of them.:)

  1. First mistake is downloading Magento’s full release and trying to upload it using ftp. Much easier solution is usingMagento downloader method and you won’t lose upgrade capability.
  1. More experienced PHP developers will first readMagento Designers Guide before they try to style Magento, but others won’t and that’s the mistake number two.Since Magento has great theme fallback system there is really no need to touch default theme. Although easiest way to make new theme for new Magento is top copy the whole theme to a new folder, don’t do that. Copy only the files you will need: from /design/frontend/default/default/ directory to /design/frontend/default/YOUR_NEW_THEME directory. Do the same thing with /skin/frontend/default/default/ Congratulations, you have your own theme just like that. All that left is to apply new theme (System->Configuration->Design) and you are ready to do with your theme files whatever you want.
  1. Third mistake is modifying Magento core files. What files are core ones? All what is in app/code/core folder. If you have a need to modify some of those ones, you just need to duplicate that file in the same directory path to app/code/local. For example, if you need to modify the file
    app/code/core/Mage/Checkout/Block/Success.php
    copy it to
    app/code/local/Mage/Checkout/Block/Success.php
    and leave the core file intact. This way your Magento will be more bullet-proof to future updates.

I hopethis article can help all new Magento developers.

 

源文檔<http://inchoo.net/ecommerce/magento/top-3-mistakes-by-magento-beginners/




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章