0

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.

enter image description here

Things I've tried so far:

  1. Giviving permission for var & pub folders.
  2. php bin/magento setup:static-content:deploy
  3. Do reindex php bin/magento indexer:reindex
  4. 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

asked Jul 29, 2018 at 9:42
2
  • Are you able to access admin properly ? Commented 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. Commented Jul 29, 2018 at 14:21

8 Answers 8

1
<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 :

answered Jul 30, 2018 at 8:19
4
  • I cannot directly edit the .conf file as it will be overwritten by cPanel update or account level modification. Commented Jul 30, 2018 at 10:07
  • try to edit file this way askubuntu.com/questions/890672/… Commented Jul 30, 2018 at 10:21
  • thank you its works. I was faced issue duringh access magento via Ip address. So i tried your solution Commented Jan 18, 2023 at 6:55
  • can you post another way for access magento via ip address in ubuntu apache server? Commented Jan 18, 2023 at 6:59
0

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.

answered Jul 30, 2018 at 7:17
2
  • Thanks much appreciate, i tried as u describe but didn't change anything even i also re-install but still same Commented 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? Commented Jul 30, 2018 at 9:31
0

1) Fire below query

`INSERT INTO `core_config_data`(`path`, `value`) VALUES ('dev/static/sign', 0) ON DUPLICATE KEY UPDATE `value`=0`
  1. sudo php bin/magento setup:static-content:deploy -f
  2. sudo chmod 777 -R var/ pub/ generated.
  3. Clear your browser and Magento cache and check it.
Murtuza Zabuawala
14.8k10 gold badges47 silver badges76 bronze badges
answered Jul 30, 2018 at 8:07
3
  • didnt work for me .. Commented Jul 30, 2018 at 13:15
  • Please check if there is .htaccess file under pub/static folder. Commented Jul 31, 2018 at 11:11
  • yes there is .haccess file under pub/static folder. Commented Aug 17, 2018 at 14:58
0

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

answered Jul 30, 2018 at 8:12
1
  • Thanks. I've tried but didn't work Commented Aug 17, 2018 at 14:59
0

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

answered Jul 30, 2018 at 10:56
0

We have also faced the same issue in order to resolve this follow the below steps:

  1. navigate to root directory of you magento2 installation
  2. Remove existing static content: rm -R pub/static/*
  3. Run: php bin/magento setup:upgrade;
  4. Run: php bin/magento setup:di:compile;
  5. Then deploy static files content forcefully with this command: php bin/magento setup:static-content:deploy -f
  6. Do reindex php bin/magento indexer:reindex
  7. Once you do this make sure to give all the files permission to 755 with sudo chmod 755 . -R
  8. Then give permission to web user with this command sudo chown www-data:www-data . -R

Hope if works for you

answered Jul 30, 2018 at 10:53
1
  • Thank you for replying I've tried it so many times but situation is still same Commented Aug 17, 2018 at 15:01
0

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.

answered Jul 31, 2018 at 11:34
0

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.

answered Sep 28, 2018 at 12:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.