I have installed Magento 2.2.5 on my server using Cpanel. The problem I am facing is my CSS is not working properly. The Url of my site is http://emcd.tk/. I've looked on so many solutions but didn't find any proper one. I also attached the picture showing errors.
Things I've tried so far:
- Giviving permission for var & pub folders.
- php bin/magento setup:static-content:deploy
- Do reindex php bin/magento indexer:reindex
- Clearing cache using commands [php bin/magento cache:clean] and [php bin/magento cache:flush]
The reason of doing this if you take the source code and check, the CSS & JS file path may wrong. So that the style won’t render in a browser even I tried to make it correct but didn't work properly.
I would appreciate any kind of help. Thank you
-
Are you able to access admin properly ?Pawan– Pawan2018年07月29日 12:07:43 +00:00Commented Jul 29, 2018 at 12:07
-
yes i can and i can also able to login in it but without css just like my hompage.Waqas– Waqas2018年07月29日 14:21:36 +00:00Commented Jul 29, 2018 at 14:21
8 Answers 8
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
and check memory-limits (1024M) in php configuration
Add code /etc/apache2/apache2.conf :
-
I cannot directly edit the .conf file as it will be overwritten by cPanel update or account level modification.Waqas– Waqas2018年07月30日 10:07:37 +00:00Commented Jul 30, 2018 at 10:07
-
try to edit file this way askubuntu.com/questions/890672/…Vamsi– Vamsi2018年07月30日 10:21:30 +00:00Commented Jul 30, 2018 at 10:21
-
thank you its works. I was faced issue duringh access magento via Ip address. So i tried your solutionHarsh Patel– Harsh Patel2023年01月18日 06:55:56 +00:00Commented Jan 18, 2023 at 6:55
-
can you post another way for access magento via ip address in ubuntu apache server?Harsh Patel– Harsh Patel2023年01月18日 06:59:01 +00:00Commented Jan 18, 2023 at 6:59
It has happened to me several times. This must be some kind of installation/compilation or deployment.
Try and run this command:
rm -rf pub/static/*; php bin/magento setup:upgrade;
php bin/magento setup:di:compile; php bin/magento setup:static-content:deploy;
If it doesn't work after this, you should try re-installing.
-
Thanks much appreciate, i tried as u describe but didn't change anything even i also re-install but still sameWaqas– Waqas2018年07月30日 09:27:37 +00:00Commented Jul 30, 2018 at 9:27
-
Can you try applying another theme? As far as I see you have now magento Luma, can you try magento Blank?Raül– Raül2018年07月30日 09:31:47 +00:00Commented Jul 30, 2018 at 9:31
1) Fire below query
`INSERT INTO `core_config_data`(`path`, `value`) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE `value`=0`
- sudo php bin/magento setup:static-content:deploy -f
- sudo chmod 777 -R var/ pub/ generated.
- Clear your browser and Magento cache and check it.
I think You are missing .htaccess file in your pub/static folder
download below file
https://github.com/magento/magento2/blob/2.2.5/pub/static/.htaccess
and put this file in your pub/static folder and hard refresh your browser
-
Thanks. I've tried but didn't workWaqas– Waqas2018年08月17日 14:59:02 +00:00Commented Aug 17, 2018 at 14:59
If you are using Linux OS Please run below command:
s1. sudo a2enmod ssl
s2. sudo a2ensite default-ssl
s3. sudo a2enmod rewrite
s4. sudo service apache2 restart
We have also faced the same issue in order to resolve this follow the below steps:
- navigate to root directory of you magento2 installation
- Remove existing static content:
rm -R pub/static/* - Run:
php bin/magento setup:upgrade; - Run:
php bin/magento setup:di:compile; - Then deploy static files content forcefully with this command:
php bin/magento setup:static-content:deploy -f - Do reindex
php bin/magento indexer:reindex - Once you do this make sure to give all the files permission to 755 with
sudo chmod 755 . -R - Then give permission to web user with this command
sudo chown www-data:www-data . -R
Hope if works for you
-
Thank you for replying I've tried it so many times but situation is still sameWaqas– Waqas2018年08月17日 15:01:08 +00:00Commented Aug 17, 2018 at 15:01
New apache version has change in some way. If your apache version is 2.4 then you have to go to /etc/apache2/. There will be a file named apache2.conf. You have to edit that one(you should have root permission). Change directory text like this
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Now restart apache.
sudo service apache2 reload
Hope it works.
The issues is resolved. After checking apache error logs, it was throwing the following error:
Invalid command '<IfVersion', perhaps misspelled or defined by a module not included in the server configuration.
So after installing mod_version into apache, the site is no longer throwing the error and working fine now.
Note: Special thanks to Cpanel for helping.