2

I setup a Ubuntu server with the LAMP at my home network for testing. I downloaded Magento-CE-2.2.0-2017-09-25-08-19-44.zip and extracted it into /var/www/html and started the installation process. The check was OK, I created the database, the hostname is set to 192.168.5.61, installation seemed to be OK.

But when I clicked the "Launch Magento Admin" at success page, it threw 404. So I visited 192.168.5.61 and the homepage showed, but it was only blank HTML - no styles or other things. I checked the page source code, the styles are linked there

<link  rel="stylesheet" type="text/css"  media="all" href="http://192.168.5.61/pub/static/version1506716871/frontend/Magento/luma/en_US/mage/calendar.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://192.168.5.61/pub/static/version1506716871/frontend/Magento/luma/en_US/css/styles-m.css" />
<link  rel="stylesheet" type="text/css"  media="screen and (min-width: 768px)" href="http://192.168.5.61/pub/static/version1506716871/frontend/Magento/luma/en_US/css/styles-l.css" />
<link  rel="stylesheet" type="text/css"  media="print"     href="http://192.168.5.61/pub/static/version1506716871/frontend/Magento/luma/en_US/css/print.css" />

But when I want to view the file, I got 404. First I thought the .htaccess is missing/ignored, but .htaccess in Magento root has 322 lines and adding random characters to it causes an internal server error, so the .htaccess is working.

Next thing I checked was the /pub/static directory, where all the styles are linked to. But it seems to be a bit empty:

adam@ubuntu:/var/www/html$ tree pub/static
pub/static
├── deployed_version.txt
└── frontend
    └── Magento
        └── luma
            └── en_US
                └── requirejs-config.js

What I did wrong? How to fix it? Still didn't do any work, so deleting everything and starting over is acceptable, but tried 2 times and still the same result.

//EDIT: Rafael Corrêa Gomes provided an answer on how to recreate the missing files. However, the problem is with permissions settings, as the installer has no permissions to modify the files it creates during installation. My problem is caused by Apache and permission, so it's a bit off-topic for this forums, as it has nothing to do with Magento.

  • Just to make sure, you deployed the static-content? Also is the server running on the same machine you try to access the magento site on? – AngelsDustz Sep 29 '17 at 20:49
  • @AngelsDustz How to deploy it? I don't remember doing so when I installed magento 2.1 in XAMPP. – Adam Ježek Sep 29 '17 at 20:53
  • When you freshly install a Magento 2 install, you have to run bin/magento setup:static-content:deploy if I remember correctly, you have to run said command from your Magento 2 root folder. – AngelsDustz Sep 29 '17 at 20:55
  • @AngelsDustz had to add -f to make it force (it said that deployment is not required in default mode), the /pub/static directory is now full, but the 404 is still there. If I remove the /versionXXXXXXXXXX/ from the .css path it is here, but homepage is still blank HTML and admin is still 404. Flushing cache had no effect. – Adam Ježek Sep 29 '17 at 21:00
  • I saw your edit in your question. I still think it is relevant in this forum since M2 developers always face such permission errors. For M2, CLI is also an essential part and that again increases the chance of this kind of error happening. So my point is, it is still relevant and you can see numerous question similar to this in this forum. Thanks for your question. Refer my answer below to go to the official doc. regarding the topic. – Rajeev K Tomy Oct 1 '17 at 3:18
4

Seems like your URL_Rewrite isn't enabled.

Try using these commands in your folder /var/www/html:

alias mage="php -d memory_limit=-1 -f bin/magento";

chmod -R 775 pub/static/ var/ pub/media/ &&
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/tmp/ var/generation/ pub/static/frontend/;
composer install && composer update -vvvv;
mage deploy:mode:set developer;
mage config:set web/seo/use_rewrites 0;
mage setup:upgrade &&
mage cache:flush &&
mage indexer:reindex;
mage setup:static-content:deploy -f
chmod -R 775 pub/static/ pub/media/ var/

You can use just these commands if the issue is the folders permission:

find app/code pub/static app/etc var/generation var/di var/view_preprocessed vendor \( -type f -or -type d \) -exec chmod u-w {} \;
chmod o-rwx app/etc/env.php;
chmod u+x bin/magento
  • composer requires login: Invalid credentials for 'https://repo.magento.com/packages.json', aborting., When I visit reop.magento.com in my browser, I am able to use my credentials to login, but they are denied in command line. Tried using both email or username as username. – Adam Ježek Sep 29 '17 at 21:21
  • @AdamJežek go to your magento account and create access key marketplace.magento.com/customer/accessKeys After this you can use Public Key and login and Private Key as password – Pavel Novitsky Sep 29 '17 at 21:32
  • It seems you code creates files that Magento installer didn't, but I figured out that this is not a Magento problem. For some reason, Magento installer has no write permission on the files it creates, so it fails. Have been messing with permission for last few hours, but it's off-topic for this forum. This is more superuser.com question, as something is f*cked up with apache. – Adam Ježek Sep 30 '17 at 12:32
4

If you use Enterprise edition (Magento Commerce), maybe staging module data is screwed up. Try to remove staging row from the flag table.

  • Excellent, Working for me. Can you give some information for flag table? – Jimit Bhavsar Aug 6 '18 at 12:42
  • @Jimit what do you mean? – Roman Snitko Aug 7 '18 at 13:18
  • This worked for me aswell @RomanSnitko – Loxzibit Aug 29 '18 at 11:27
2

It sounds like ownership or file access permission issue. While we run some commands or load a page, Magento generates some files into some particular directories and you need to make sure the ownership and permission of these directories as exactly described in the official documentation page.

1

There are two reasons: 1: permission and owner 2. .htaccess rewrite rules http://devdocs.magento.com/guides/v2.1/install-gde/prereq/file-sys-perms-over.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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