Posted on

Magento 2 404 on all pages/files (except homepage)

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:

[email protected]:/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.

Leave a Reply

Your email address will not be published. Required fields are marked *