有时候在后台启用Allow symlinks后,每次更新内容还得去生成静态内容。对于调试过程非常不便。请检查以下几处看是否有问题
1。
App/etc/config.php 文件中的allow_symlinks是否被正确设置
2。数据库是是否有正确的值被设定
此处的查询语句为
SELECT * FROM `core_config_data` WHERE `path` LIKE '%allow_symlink%'
如果没有,要自己执行插入
INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`, `updated_at`) VALUES (NULL, 'default', '0', 'dev/template/allow_symlink', '1', CURRENT_TIMESTAMP);
老版本无更新时间
INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', '0', 'dev/template/allow_symlink', '1');
如无或是参数不对,请执行
bin/magento config:set dev/template/allow_symlink 0
3。 php参数禁用函数是否含有 Symlink 有的话禁用列表移除此
打开app/etc/di.xml
大约740行 保持不变,有些文章瞎说挺厉害。但是这里不应该修改
<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
<arguments>
<argument name="strategiesList" xsi:type="array">
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
<item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
</argument>
</arguments>
</virtualType>
修改站点conf配置文件
<Directory "your/path/here">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
修改 pub/static下的静态规则
<IfModule mod_rewrite.c>
RewriteEngine On
## you can put here your pub/static folder path relative to web root
#RewriteBase /magento/pub/static/
# Remove signature of the static files that is used to overcome the browser cache
RewriteRule ^version.+?/(.+)$ $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* ../static.php?resource=$0 [L]
# Detects if moxieplayer request with uri params and redirects to uri without params
<Files moxieplayer.swf>
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)$ %{REQUEST_URI}? [R=301,L]
</Files>
</IfModule>
移除伪静态规则中的ifversion语句
修改以下位置文件内容
\vendor\magento\framework\App\StaticResource.php
在2.4.5版本或是以前版本中,此文件位于:
\lib\internal\Magento\Framework\App\StaticResource.php
从
public function launch(){ ***** if (!($this->isThemeAllowed($params['area'] . DIRECTORY_SEPARATOR . $params['theme']) ******** }
到
public function launch(){ ***** // if (!($this->isThemeAllowed($params['area'] . DIRECTORY_SEPARATOR . $params['theme']))) if (!($this->isThemeAllowed($params['area'] . "/" . $params['theme']))) ******** }
有的windows机无法正确识别这里的符号。
M2.3及一些老版本:
打开php symlink
后台打开symlink
bin/magento config:set dev/template/allow_symlink 1