## 安裝magento:
可以參考 :[http://www.hmoore.net/zouhongzhao/magento2-in-action/628424](http://www.hmoore.net/zouhongzhao/magento2-in-action/628424)
*****
## 配置paypal :
不需要安裝插件,直接利用magento后臺配置,要申請paypal商業賬號,創建商業賬號sandbox(us), 得到 商家用戶和客戶用戶 來測試支付和收入。

參考資料:
1,國外資料
[https://www.mageplaza.com/kb/how-to-configure-paypal-express-checkout-payment-method-magento-2.html](https://www.mageplaza.com/kb/how-to-configure-paypal-express-checkout-payment-method-magento-2.html)
2,國內資料
[http://www.hmoore.net/zouhongzhao/magento2-in-action/699199](http://www.hmoore.net/zouhongzhao/magento2-in-action/699199)
*****
## 配置 stripe 信用卡支付 (選):
https://stripe.com/docs/plugins/magento-2
[Installing the Magento 2 Module | Stripe Documentation](https://stripe.com/docs/plugins/magento-2/install#manual)

配置好,可以測試:

支付成功,stripe配置是相對容易:

*****
## 安裝mageplaza方的插件,
記得安裝 core:
https://github.com/mageplaza/module-core
如果國內環境出現問題,解決方案:

參考:[https://github.com/mageplaza/module-core/issues/26](https://github.com/mageplaza/module-core/issues/26)
```
// 修改這里的代碼則可以:
**if($params\['extension'\] == 'Mageplaza\_Blog'){**
**????$result\['success'\] = true;**
**????$result\['key'\] = 'BLOG-XXXXXXXXXXXXXXXX';** //解決驗證問題,key在mageplaza后臺訂單有
**}**
```
*****
## https的配置 :
參考:[http://www.hmoore.net/zouhongzhao/magento2-in-action/647798](http://www.hmoore.net/zouhongzhao/magento2-in-action/647798)
*****
*****
## SMTP郵件功能
magento需要配置smtp才能發郵件,例如Amazon云的郵件服務,mailgun等
需安裝插件: [https://www.mageplaza.com/magento-2-smtp/](https://www.mageplaza.com/magento-2-smtp/)

郵件發信地址配置好:

測試發信成功:

*****
## 后臺配置全部檢查一次:(重要)

*****
# 開發前準備:
**1. 開啟調試功能 debug**
1.1 ,切換到 develop模式
~~~
php bin/magento deploy:mode:set developer
~~~
1.2,前端頁面提示 layout+container:

*****
1.3,debug后臺模塊位置:
https://bbs.mallol.cn/question/m2-open-foreground-template-debugging-path/
*****
**2. 怎樣查看Log:**
參考:2.1,http://www.hmoore.net/zouhongzhao/magento2-in-action/681201
2.2,https://devdocs.magento.com/guides/v2.3/config-guide/log/custom-logger-handler.html
```
~~~
查看log,debug的地方:
主要看debug.log/exception.log
如果還沒有可靠的信息的話,就看apache/nginx里配置的error log。
~~~
```
**3,基本知識學習:**
http://www.hmoore.net/zouhongzhao/magento2-in-action (國內)
https://www.mageplaza.com/ (國外)
**4, restful api的使用:**
[REST API reference | Adobe Commerce Developer Guide (magento.com)](https://devdocs.magento.com/redoc/2.3/)
參考: http://www.hmoore.net/zouhongzhao/magento2-in-action/861578
~~~
//通過rest/V1/integration/admin/token登錄后臺生成token
$userData = array("username" => "zou", "password" => "zou用戶的密碼");
$ch = curl_init("http://magento2demo.texiaoyao.cn/rest/V1/integration/admin/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$ch = curl_init("http://magento2demo.texiaoyao.cn/rest/V1/customers/1");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
var_dump($result);
~~~
返回結果:
~~~
string(641) "{"id":1,"group_id":1,"default_shipping":"1","created_at":"2018-06-11 01:09:31","updated_at":"2018-11-30 05:01:44","created_in":"Default Store View","email":"zouhongzhao@126.com","firstname":"zou","lastname":"hongzhao","store_id":1,"website_id":1,"addresses":[{"id":1,"customer_id":1,"region":{"region_code":"\u6e56\u5317","region":"\u6e56\u5317","region_id":0},"region_id":0,"country_id":"CN","street":["\u9ad8\u65b0\u5927\u9053"],"telephone":"1510232345","postcode":"430000","city":"\u6b66\u6c49","firstname":"zou","lastname":"hongzhao","default_shipping":true}],"disable_auto_group_change":0,"extension_attributes":{"is_subscribed":false}}"
~~~
*****
## 萬能命令,修復問題:
~~~
php bin/magento maintenance:enable
rm -rf var/di/* && rm -rf var/generation/* && rm -rf var/cache/* && rm -rf var/page_cache/* && rm -rf var/view_preprocessed/* && rm -rf pub/static/* && rm -rf generated/* && mkdir var/di
php bin/magento setup:upgrade && php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f && php bin/magento indexer:reindex && php bin/magento maintenance:disable && php bin/magento cache:clean && php bin/magento cache:flush
~~~
## 服務器配置:
建議:4核16g =》同時250人/min =》達到基本要求