一次magento2.2网站打不开的解决过程
1.1apache找不到目录
在域名根目录下找不到项目目录:
问题出在根目录的.htaccess文件中
1.2现在网站能打开,提示Magento\Framework\EscapeHelper does no’t exites
在magento2.2中Escape 全部换成了EscapeHelper
所以我们只要把文件\vendor\magento\framework\Escaper.php
复制一份 并更名为EscapeHelper.php即可
\vendor\magento\framework\EscapeHelper.php
1.3网站能打开了,出现css全都是500错误
检查两个pub下的.htaccess文件与pub/static文件是否正常
参考:
https://community.magento.com/t5/Installing-Magento-2-x/CSS-and-JS-files-not-loaded-after-installation-Wamp64/m-p/95964#M4190
更改三个.htaccess文件,分别为根目录,pub,pub/media
Options +FollowSymLinks => Options +SymLinksIfOwnerMatch
!!! http.conf配置开启mod_version
后台没有样式
执行下面的SQL
INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES (NULL, 'default', '0', 'dev/static/sign', '0')
前台没有样式,打不开
nginx服务器添加以下配置
autoindex off;
# disable_symlinks on;
charset off;
#charset utf-8;
location /setup {
try_files $uri $uri/ @setup;
}
location @setup {
rewrite /setup /setup/index.php;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /pub {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# Tell client that this pre-flight info is valid for 20 days
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
try_files $uri @static;
}
location @static {
rewrite ^/pub/static/(version\d*/)?(.*)$ /pub/static.php?resource=$2 last;
}
location /pub/media {
try_files $uri/ @mediahandler;
}
location @mediahandler {
rewrite / /get.php;
}
location /pub/media/customer {
deny all;
}
location /pub/media/downloadable {
deny all;
}
location ~ /pub/media/theme_customization/.*\.xml$ {
deny all;
}
location ~ /pub/errors/.*\.(xml|phtml)$ {
deny all;
}
location /sitemap.xml {
alias /www/wwwroot/likeledera.com/sitemaps/sitemap.xml;
}
location /robots.txt {
alias /www/wwwroot/likeledera.com/robots.txt;
}
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss
image/svg+xml;
gzip_vary on;
#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}
根目录需要配置composer.json 添加
"use-include-path": true
"disable-tls": true