0

I tried the instructions under Magento 2 Reindexing - One or more indexers are invalid. Make sure your Magento cron job is running

but am still unable to reindex. I ssh'd into my webserver and tried running the command that was suggested from the root, php bin/magento indexer:reindex but it didn't work, so I tried going to the directory "blahblah.com"/shop/bin$ magento indexer:reindex

-bash: magento: command not found (I have a /shop directory where my files are installed)

and I tried magento indexer:status (and some others but am not able to run the commands, keep getting command not found)

I also opened up the file manager, found the magento file, opened it up and searched for indexer but am not finding it either.

Can someone help me to understand how I can reindex the status under the Index Management of my magento site? Thanks.enter image description here

1 Answers1

0

You either run the command as:

php magento indexer:reindex

Or you can make the magento script executable:

chmod +x magento

After making the script excutable you can run the script as:

./magento indexer:reindex

Your magento file should look like the following:

#!/usr/bin/env php
<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

if (PHP_SAPI !== 'cli') {
    echo 'bin/magento must be run as a CLI application';
    exit(1);
}

try {
    require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
    echo 'Autoload error: ' . $e->getMessage();
    exit(1);
}
try {
    $handler = new \Magento\Framework\App\ErrorHandler();
    set_error_handler([$handler, 'handler']);
    $application = new Magento\Framework\Console\Cli('Magento CLI');
    $application->run();
} catch (\Exception $e) {
    while ($e) {
        echo $e->getMessage();
        echo $e->getTraceAsString();
        echo "\n\n";
        $e = $e->getPrevious();
    }
    exit(Magento\Framework\Console\Cli::RETURN_FAILURE);
}
Andrew Noble
  • 828
  • 5
  • 15
  • I changed directory to the bin directory and issued the first command you suggested, php magento indexer:reindex but I received the following reply: Parse error: syntax error, unexpected '[', expecting ')' then tried the second suggestion, chmod +x magento which I believe it took that command and then issued the next command from the same directory ./magento indexer:reindex but received the same error as above.. Not really sure why it's not working thanks for trying.. – Steve Bellinger Feb 11 '17 at 00:56
  • It sounds like when you opened the Magento file in your file manager you accidentally replaced a ) with a [ or deleted something. Are you able to upload your magento file? This new error would only occur if there was an error inside the file – Andrew Noble Feb 11 '17 at 01:10
  • @SteveBellinger first try to run php bin/magento setup:di:compile command and check what error and which file error it gives ? also check your log file – Manthan Dave Feb 11 '17 at 08:58
  • Thanks again for the help!

    @Andrew, it might be a problem with the script I originally ran which was on a hosted server- maybe the files I need aren't uploaded?

    – Steve Bellinger Feb 11 '17 at 14:25
  • Thanks again for the help!

    @Manthan Dave, I tried running the command you suggested, but I walked the path trying to execute the command and here's the results:

    sbellinger@web18:~$ php bin/magento setup:di:compile Could not open input file: bin/magento

    sbellinger@web18:~$ cd www sbellinger@web18:~/www$ php bin/magento setup:di:compile Could not open input file: bin/magento

    sbellinger@web18:~/www$ cd anything.com sbellinger@web18:~/www/anything.com$ php bin/magento setup:di:compile Could not open input file: bin/magento

    – Steve Bellinger Feb 11 '17 at 14:27
  • sbellinger@web18:~/www/anything.com$ cd shop sbellinger@web18:~/www/anything.com/shop$ php bin/magento setup:di:compile Parse error: syntax error, unexpected '[', expecting ')' in /home/www/anything.com/shop/bin/magento on line 21 – Steve Bellinger Feb 11 '17 at 14:28
  • sbellinger@web18:~/www/anything.com/shop$ dir app composer.lock Gruntfile.js.sample LICENSE_AFL.txt php.ini.sample update bin CONTRIBUTING.md index.php LICENSE.txt phpserver var CHANGELOG.md COPYING.txt ISSUE_TEMPLATE.md nginx.conf.sample pub vendor composer.json dev lib package.json.sample setup – Steve Bellinger Feb 11 '17 at 14:28
  • sbellinger@web18:~/www/anything.com/shop$ cd bin sbellinger@web18:~/www/anything.com/shop/bin$ php bin/magento setup:di:compile Could not open input file: bin/magento – Steve Bellinger Feb 11 '17 at 14:28
  • sbellinger@web18:~/www/anything.com/shop/bin$ php magento setup:di:compile Parse error: syntax error, unexpected '[', expecting ')' in /home/www/anything.com/shop/bin/magento on line 21

    sbellinger@web18:~/www/anything.com/shop/bin$ dir magento

    – Steve Bellinger Feb 11 '17 at 14:28
  • sbellinger@web18:~/www/anything.com/shop/bin$ php magento setup:di:compile Parse error: syntax error, unexpected '[', expecting ')' in /home/www/anything.com/shop/bin/magento on line 21 There was very little info in the access and error logs, definitely nothing of relevance. Is there a command to run logs from the command line to search for something specific (and if so from what directory)? Could it be that the pre-installed script doesn't have everything it needs and maybe I should just upload the full script (and this time with data examples) and install it by the console instead? – Steve Bellinger Feb 11 '17 at 14:29
  • I'm not very experienced with Magento and this is the first time I've used the command line with magento so I don't know all the commands on it. So, I'm not sure what I should be looking for or what the normal behavior is when trying to run these commands. Does the above provide any clues as to why I can't run the commands? – Steve Bellinger Feb 11 '17 at 14:30
  • @Andrew, I compared your magento file with mine and the only difference was on line 31 where mine says ( exit(Cli::RETURN_FAILURE); ) instead of ( exit(Magento\Framework\Console\Cli::RETURN_FAILURE); ).. doesn't seem to be an issue though.. – Steve Bellinger Feb 11 '17 at 15:06