在localhost上安装Magento后
Magento无法加载css,javascript(静态文件)
经过一些研究,我知道我必须运行php bin/magento setup:static-content:deploy
,所以我做了
cd /var/www/html/magento
sudo php bin/magento setup:static-content:deploy
该工具部署了大量静态文件
$:/var/www/html/magento$ sudo php bin/magento setup:static-content:deploy
Requested languages: en_US
Requested areas: frontend, adminhtml
Requested themes: Magento/blank, Magento/luma, Magento/backend
=== frontend -> Magento/blank -> en_US ===
=== frontend -> Magento/luma -> en_US ===
=== adminhtml -> Magento/backend -> en_US ===
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 2136 files; errors: 0
---
........................................................
Successful: 2061 files; errors: 0
---
............................................................................................................................................................................................................................................
Successful: 2012 files; errors: 0
---
=== Minify templates ===
Successful: 869 files modified
---
New version of deployed files: 1494363632
但是加载静态资源仍然失败
Failed to load resource: the server responded with a status of 404 (Not Found) /magento/pub/static/version1494362497/frontend/Magento/luma/pt_BR/css/print.css
答案 0 :(得分:1)
此magento设置为使用pt_BR
作为语言,运行' sudo php bin / magento setup:static-content:deploy'将静态资源部署为默认语言(en_US)
该工具需要额外的参数来指定此
sudo php bin/magento setup:static-content:deploy pt_BR
输出:
Requested languages: pt_BR
Requested areas: frontend, adminhtml
Requested themes: Magento/blank, Magento/luma, Magento/backend
=== frontend -> Magento/blank -> pt_BR ===
=== frontend -> Magento/luma -> pt_BR ===
=== adminhtml -> Magento/backend -> pt_BR ===
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Successful: 2012 files; errors: 0
---
.......................................................................................................................................................................................................................................................................................................................................................
Successful: 2061 files; errors: 0
---
..................................................................................................................................................................................................................................................
Successful: 2136 files; errors: 0
---
=== Minify templates ===
Successful: 869 files modified
---
New version of deployed files: 1494363897