My website is in default mode only. After run "setup:upgrade" my web does not load the resources css or js. "Refused to apply style from '' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
Any idea what might be causing this problem?
If you are using Linux then change the mode to developer and then run php bin/magento cache:flush from the document root of the webserver.
If you are using Windows then please follow the below steps:
change the mode to developer
run php bin/magento cache:flush from the project directory
run bin/magento setup:static-content:deploy -f from the project directory
Please let me know how it goes!
Try this
sudo su
cd /var/www/html/magento2
Set permissions to the files as follows
find . -type f -exec chmod 644 {} \;
Set permissions to the directories as follows
find . -type d -exec chmod 755 {} \;
Set permissions to special directories: as follows (these commands solve your file uploading issue)
find ./var -type d -exec chmod 777 {} \;
find ./pub/media -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
Please check the .htaccess file in pub/static/.htaccess. If not then please add it.
thanks!!
Solution -
In file /etc/apache2/apache2.conf Navigate <Directory /var/www/>, Change "AllowOverride None" to "AllowOverride All" 2. Add this at last in env.php located at <MagentoRootDirectory/app/etc>
`'system' => [
'default' => [
'web' => [
'unsecure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
],
'secure' => [
'base_media_url' => '{{secure_base_url}}pub/media/',
'base_static_url' => '{{secure_base_url}}pub/static/'
]
]
]
]`
In etc/di.xml, Search <item name="view_preprocessed" xsi:type="object"> Under that Modify this Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Add this in db INSERT INTO core_config_data (path, value) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE value = 0;
Add this in db UPDATE core_config_data SET value = '0' WHERE core_config_data.path LIKE '%web/seo/use_rewrites%';
Run this command, sudo a2enmod rewrite
Related
I am trying to installed Magento 2.3.4 in CentOS bases server. And getting below error:
Fatal error: Uncaught Zend_Cache_Exception: cache_dir "/var/www/html/mage2/var/page_cache" is not writable in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/var...') #1 /var/www/html/mage2/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/var/www/html/m...') #2 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array) #3 /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true) #4 /var/www/html/mage2/vendor/magento/framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, true, true) #5 /var/www/html/mage2/vendor/magento/framework/Cache/Frontend/Adapter/Zend.php(38): Magento\Framework in /var/www/html/mage2/vendor/magento/zendframework1/library/Zend/Cache.php on line 209
Already I ran below commands:
sudo chmod -R 777 var/ pub/ generated
Seems like file & folder owner|group issue. Then, I created one user and assigned it to apache group and ran below command to change file & folder owner|group
sudo chown -R magento_user:apache * .[^.]*
sudo find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;
sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;
sudo chmod u+x bin/magento
sudo service httpd restart
I installed Magento using CLI with below command and got success message
php bin/magento setup:install --base-url=http://example.com/ --db-host=localhost --db-name=dbname --db-user=dbuser --db-password=dbpass --admin-firstname=Rajiv --admin-lastname=Ranjan --admin-email=rajiv#gmail.com --admin-user=admin --admin-password=admin#123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1
Still I am not getting same 'write permission' error while accessing from browser.
Any help is much appreciated.
After spending too much time, found solution. centos was restricting to write in directories. So I executed below commands and it worked fine.
sudo chcon -R --type httpd_sys_rw_content_t var
sudo chcon -R --type httpd_sys_rw_content_t pub/media
sudo chcon -R --type httpd_sys_rw_content_t pub/static
sudo chcon -R --type httpd_sys_rw_content_t generated
Run cache clean command and then give 777 permission again and check.
php bin/magento cache:clean
sudo chmod -R 777 var
fresh installed Magento 2.2.3 with sample data everything worked fine. until I changed the deploy: mode to the developer. now it is showing a blank page, there is no error only blank screen.
refresh the cache, deleted all cache folders, generated folder and cleared pub/static folder too ( leaving .htaccess ) file. recompiled the code, ran setup upgrade commands but without any solution.
please help.
You can try enabling the developer mode to check the error(s) if any.
Also please try changing the permissions of the file and folder to the following:
from the root directory:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
find ./var -type d -exec chmod 777 {} \;
find ./pub/static -type d -exec chmod 777 {} \;
You should enable exception printing by renaming local.xml.sample to local.xml in pub/errors. Also check exception and system log in var/log
I used centos 6.5
in / path I have a lot of files that started with this name tmp_
I work with a user franco who has a limit permission ( and I can't add permission to this user )
and with FileZilla when I try to delete these files, I have a permission denied message.
so the solution is to delete these files with command in putty tool
because in putty, I can use command like this sudo rm .....
but I did not find the exact command.
I found this kind of command :
rm ./-tmp_
I want only to delete the files which are only in \ path and not in its subdirectories and which started with tmp_
I work with critical system so I want to be sure before execute any command.
To find target files use :
This will just print files on console.
find / -maxdepth 1 -type f -name 'tmp_*'
To remove files (not directories):
find / -maxdepth 1 -type f -name 'tmp_*' -exec rm -f {} \;
Please use -maxdepth attribute if you want to target files to specific depth.
The command "sudo rm -rf /tmp_" is worked if the /tmp_ directory not used for you.
CSS not loading properly in magento2. Getting below error:
NameError: variable #button__shadow-active is undefined
in _buttons.less
Do you use wampserver ?
Go to your wampserver icon and click on it and than
Apache->apache modules->rewrite_module[enable this]
After this start all services and check it ........
Css not loaded properly means static content rendering problem so,
Remove cache,page_cache,view_preprocessed from var table
Give full permissions to var folder
Run static command in magento root folder php bin/magento setup:static-content:deploy
now Roload the site
First Replace .htaccess.sample with .htaccess in root
Add .htaccess in pub/static
https://github.com/emizentech/magento2/blob/master/pub/static/.htaccess
Edit & Replace Apache config file & replace given details below.
sudo vi /etc/apache2/apache2.conf
From
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
From
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
sudo service apache2 restart
rm -rf var/cache/*
rm -rf var/generation/*
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
chmod -R 777 pub var
This will solve your css issues, admin 404 issues , link/url 404 issue , version-xxx issue.
As the error says your less variable is missing and not found.
It means these are possible reasons for your error:
Invalid .less variable declaration.
If you are importing variables from another file - you have an invalid declaration of that file in the XML or you didn't import that file on your less file with #import "custom-variables.less";
There is a typo in your main .less file
Without code, there are only guesses. Please provide us a code so we could check it more precisely. Also, check your .log files there can be some hints.
CSS not loading properly due to static deploy not push the file to pub/static directory.
You have to follow the below steps.
rm -rf var/*
rm -rf pub/static/*
php bin/magento setup:static-content:deploy
chmod -R 7777 var pub/static
Try this,
set permission on /var and /pub folders to 777
ssh using this command
php bin/magento setup:static-content:deploy
I have a Zend Framework application. Almost all of my urls work fine. However, any url that starts with /resources gives me a 403 forbidden error (e.g.: /resources/add, /resources/edit). The strange thing is, when I tested it on my Windows machine via XAMP, everything worked fine. Is there something special about urls starting with /resources that makes Apache2 think it should not allow access?
Your issue seems a permissions problem, nothing related to URLs. Check directories to be 755 and files 644 in the Ubuntu server where you deployed your application.
Run this in the root directory of your application and should get you going:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;