2

I have just installed Magento to my webserver and deployed static files. However, when I access the site it is shown without any styling, and I get a lot of 404 errors for the static files:

/pub/static/frontend/Magento/luma/da_DK/mage/calendar.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/requirejs/require.js Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/css/styles-m.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/mage/requirejs/mixins.js Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/css/styles-l.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/_requirejs/frontend/Magento/luma/da_DK/requirejs-config.js Failed to load resource: the server responded with a status of 404 (Not Found) styles-m.css:24 Uncaught ReferenceError: require is not defined styles-m.css:26 Uncaught ReferenceError: require is not defined /pub/static/frontend/Magento/luma/da_DK/images/logo.svg Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/css/print.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/mage/requirejs/mixins.js Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/_requirejs/frontend/Magento/luma/da_DK/requirejs-config.js Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/requirejs/require.js Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/css/print.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/mage/calendar.css Failed to load resource: the server responded with a status of 404 (Not Found) /pub/static/frontend/Magento/luma/da_DK/css/styles-l.css Failed to load resource: the server responded with a status of 404 (Not Found)

When accessing the FTP I have verified that most of the files are there, however some of them are looking a little weird:

does require.js look like a shortcut?

enter image description here

Apache rewrites are turned on, and the presence of the following line in .htacess should be enoug to enable it, I belive? (CentOS/WHM)

RewriteEngine on

Any suggestions to what might be going on?

1
  • It sounds like you may have deleted the .htaccess file that lives inside of pub/static dir Commented Jan 7, 2018 at 15:45

3 Answers 3

1

Using your SSH terminal go to folder /pub/static/ and run the following command to set folder and files permissions:

find . -type d -exec chmod 777 {} \; && find . -type f -exec chmod 644 {} \;

Note that this command is for linux.

0

to me you just have some weird cPanel/Apache configuration, plus to this you have incorrect permissions. this is the only problem... remember that now default magento installation will ALWAYS work out of the box. also it looks like your ftp program incorrectly uploaded some files. do not upload files from your computer, upload zip archive to your server and unzip it to your web directory, apply proper permissions and set correct owner. this is required and very important, because the default cPanel installation usually creates suPHP setup which is very strict to UID/GID.

remove all cache and static files (dont worry about .htaccess cause it has .<-DOT it will not be removed even if you run rm -rf * in that directory. usuallly :)
when you deploy static files also use proper user/owner:

su <FILES_OWNER_NAME> -s /bin/bash -c "bin/magento setup:static-content:deploy"

also to be safe, files permission must be 644 and the folder permission must be 755.

6
  • Thanks! I am currently in the process of chmodding pub/static 755 recursively to all subdirectories, and slowly things are beginning to work on the page, even though the process isn't done yet. Will anything bad happen by having these files 755? Commented Jan 15, 2016 at 9:11
  • I might try your suggestion instead - it seems more right than recursively forcing permissions. How do I figure out who the owner should be? Commented Jan 15, 2016 at 9:14
  • Could it just be root? Commented Jan 15, 2016 at 9:20
  • no :) see your server config or parent folder like /home/USER_NAME/ or in WHM "List Accounts".
    – MagenX
    Commented Jan 15, 2016 at 9:23
  • Thanks. My WHM user for this installation is called magento. However, when I run the following command from SSH: su magento -s /bin/bash -c "bin/magento setup:static-content:deploy" I get an bash: bin/magento permission denied. Is it because im logged in to ssh as root and not magento? Commented Jan 15, 2016 at 9:31
0

Install Composer. Now I would like you to download Magento 2 zip from magentocommerce.com/download, create new db in phpmyadmin, extract zip in htdocs folder. Install Magento 2 but do not use localhost use 127.0.0.1 in store URL and admin URL. After successful installation DO NOT run magento.

Now we are going to verify Composer installation, Deploy static content, clear / flush Magento cache and reindex the Magento 2 blocks. To perform all above actions, press WINDOWS KEY + R to open RUN dialog and type “cmd” to open Command Prompt.

Type “cd PATH_TO_YOUR_MAGENTO2_FILES” to enter in Magento 2 ROOT directory.

Now to verify Composer installation in above directory, type “composer install”.

If you get any error in this step, please check your Composer installation

In this step, we are setting up static content to deploy on our Magento store. To perform this, type “php bin/magento setup:static-content:deploy”.

If you get any error, check your PHP.EXE and PHP.INI Environment Variable

Clear / Flush Magento cache by typing “php bin/magento cache:flush” in CMD.

And finally, to Reindex Magento Static Blocks type “php bin/magento indexer:reindex”.

You are done with successful installation of Magento 2.

11
  • Thank you for your suggestion. Can you elaborate why this would work? Commented Jan 15, 2016 at 6:59
  • I already mentioned it, When magento 2 is not is production mode, it will create symlinks for external resources like js css img files on local or external servers. By modifying its behavior, will leave you with perfect magento 2 running store. Commented Jan 15, 2016 at 7:02
  • See this as well: magento.stackexchange.com/questions/97209/… Commented Jan 15, 2016 at 7:03
  • Thanks. I will try it out and then return if it doesn't work. Might take some time though - I haven't been able to get the installer running by cloning git or unpacking files directly on server, so I need to unpack on my computer and upload the 50 thousand files one at the time.. Commented Jan 15, 2016 at 7:03
  • Why you are uploading 50k files? Just upload zip as it is you are going to download from magentocommerce and then extract it on your server. Do not unpack it on your computer. Commented Jan 15, 2016 at 7:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.