26

Admin url is showing 404 error after installing magento 2 on wamp server and frontend design is all messy and css is not linked to it.Error visuals are shown below.

Frontend error:

enter image description here

14 Answers 14

58

First of all, apply proper permissions, enable apache rewrite_module and refresh apache server.

chmod -R 777 /var/www/html/MAGENTO_2_ROOT_DIRECTORY/

sudo a2enmod rewrite

sudo service apache2 restart

For messy frontend, run following command from Magento root:

php bin/magento setup:static-content:deploy

Now clear var directory except .htaccess file and check admin. If you get 404 page, there may be an issue of Symlink. Fot this, Edit apache config file

sudo gedit /etc/apache2/apache2.conf

and replace this code :

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride none
Require all granted

with

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

Note: changed AllowOverride none to AllowOverride All

Now restart apache sudo service apache2 restart and check admin. This should fix admin 404 issue.

Also make sure, you don't leave /app/etc/ directory writeable

  • Great, Thanks.. – saravanavelu Jun 24 '16 at 9:39
  • 1
    This worked for me, only I didn't change the permissions to 777 for everything. Make sure you don't leave /app/etc/ writeable – David Wilkins Jun 27 '16 at 13:05
  • @DavidWilkins: Glad that helps, I appreciate your point. Updated my answer – Anil Suthar Jun 27 '16 at 13:12
  • 1
    Thanks, This worked! I made a mistake first and change the wrong AllowOverride. Just make sure its the one under <Directory /var/www/> – marshy101 Jul 5 '16 at 1:51
  • Worked like a charm. :) – dhruvvyas90 Jul 11 '16 at 10:38
13

For those who are using wamp server on windows localhost then,

you can try this:

C:\wamp\bin\php\php5.5.12>php.exe C:\wamp\www\<Magento root directory>\bin\magento setup:static-content:deploy

in your CLI.

7

Make sure you enabled server rewrites: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache.html#apache-help-rewrite

4

SOLUTION # 1 (IF YOU WANT TO EDIT XML FILE)

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 clear / delete caches and sessions of Magento 2. Go to following paths and delete everything:

ROOT > var > cache > *DELETE ALL*
ROOT > var > page_cache > *DELETE ALL*
ROOT > var > session > *DELETE ALL*

When Magento 2 is not in production mode, it will try to create symlinks for some static resources on local server. We have to change that behavior of Magento 2 by going to edit ROOT > app > etc > di.xml file. Open up di.xml in your favorite code editor, find the virtualType name="developerMaterialization" section. In that section below, you will find an item <item name="view_preprocessed" xsi:type="object"> which needs to be modified. You can modify it by changing the following content:

Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink

To:

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Now last step, also delete old files generated in ROOT > pub > static > DELETE ALL EXCEPT .HTACCESS

I personally tried it on my localhost using MAMP, EasyPHP DevServer, Xampp and Wampp and successfully installed and using Magento 2. For further you can check out this link: Magento 2 CSS and JavaScript not loading from correct folder

SOLUTION # 2

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.

  • Answer has been edited. – Fayyaz Khattak Jan 18 '16 at 16:05
  • #1 doesn't work for me, Magento 2.1.0. It seems to work if I add index.php segment to URL – Codium Aug 19 '16 at 8:52
  • #2 also not working :( – Codium Aug 19 '16 at 9:10
  • 1
    @drupality check this article and see if you are missing something else: magenticians.com/fix-broken-magento-2-installation – Fayyaz Khattak Aug 19 '16 at 10:26
  • read that, still no luck, something is wrong with newest Magento version. Major pain in the ass – Codium Aug 19 '16 at 11:14
4

open the terminal and navigate to magento web root

 $ cd /var/www/html/magento2 
Step 1.

$ php bin/magento setup:static-content:deploy

Step 2.

$ php bin/magento indexer:reindex

Step 3.

make sure apache “rewrite_module” is enable and then restart the server

$ sudo a2enmod rewrite && sudo service apache2 restart

Step 4.

$ chown -R www-data:www-data /var/www/html/magento2 

Step 5.

 $ chmod -R 777 /var/www/html/magento2/

Step 6.

delete cache folder under var/cache

http://gotechnies.com/css-javascript-files-loading-magento-2-installation/

4

Fixed the same issue faced.

as mentioned above run the command php bin/magento setup:static-content:deploy in your Magento 2 installation directory through terminal and give permission.

For admin side this is the error (404) because:

<Directory "/var/www/html">
    AllowOverride  all
</Directory>` 

was not present in the end of file /etc/apache2/sites-available/000-default.conf before </VirtualHost>. Also make sure that mod_rewrite is enable by entering command:

a2enmod rewrite

Added that line and restarted apache2. Can now access the admin. hope it helps.

  • How can I do this in live hosting ? I did it in my localhost. – abu abu Oct 17 '18 at 13:12
3

I installed magento2 (on xampp win7) with composer:

1.git clone https://github.com/magento/magento2/tree/master
2.cd magento2
3.git checkout master
4.composer install
5.php bin/magento sampledata:deploy
6.composer update

then i installed magento2 with web installer and got 404 error (page not found) on both front-end back-end pages. then i opened magento2\app\etc\di.xml and removed this line

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>

also i removed env.php and did web installation once again after that front-end and back-end works fine :)

3

run

bin\magento setup:static-content:deploy
  • don't forget permission too. For me, I run after that: chmod -R 777 * – redochka Jan 3 '16 at 20:14
3

For UBANTU OS magento Frontend to work you just need to go to your magento directory and write this command sudo bin/magento setup:static-content:deploy

3
  1. Remove all files from pub->static folder and fire upgrade command and deploy command so that once again folder and files will be seen in pub->static folder then open admin panel or front-end. This works for me.

  2. If still you don't get then delete all files and folder from var->generation folder and once again fire PHP upgrade and deploy command and check whether admin and front-end is visible properly.

2

You move to directory install magento2. After, you using command in terminal: bin/magento setup:static-content:deploy and set permissions for pub, var folder have 770 permissions

2

Just Open the

MAGENTO_ROOT/app/etc/di.xml

and replace below code form line number 574

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>

TO

<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>

1

Please check once you enabled server rewrites: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache.html#apache-help-rewrite

1

Simplest solution form admin url is

in core config table change value for web/seo/use_rewrites to 0 ( 1 to 0 ) and all cache folder form var

Second neet to disable versioning form admin

How to disable static-files versioning:

If you do not want to use static files versioning you can disable this feature in the Magento admin area:

config

It is possible to change this setting for default scope using the following MySQL query:

INSERT INTO 'core_config_data' ('path', 'value') 
    VALUES ('dev/static/sign', 0) 
    ON DUPLICATE KEY UPDATE value = 0;

Then execute next command to clear a configuration cache:

bin/magento cache:clean config

protected by Fabian Schmengler May 19 '16 at 9:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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