Is it possible to do Index Management without SSH/Shell Access in Magento ver. 2.1.0 ?

  • In magento 1 you can just access the backend, go to System > Index and regenerate them. Doesn't this work for Mage 2? Oct 1, 2016 at 21:16
  • if it did i wouldn't be asking. Even the backend looks totally different now. Oct 2, 2016 at 5:32
  • @FabianBlechschmidt no you can reindex from M2 backend. Here's a small module I just wrote to do so: github.com/digitalpianism/reindex Oct 3, 2016 at 10:01

2 Answers 2


Module link

After your question I ended up developping a small module for that. It is available here: https://github.com/digitalpianism/reindex

Module Code

But here is the how to:


<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="DigitalPianism_Reindex" setup_version="0.1.0">
            <module name="Magento_Index"/>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::system">
                    <resource id="Magento_Backend::tools">
                        <resource id="DigitalPianism_Reindex::reindex" title="Reindex" translate="title" sortOrder="30" />


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="reindex" frontName="reindex">
            <module name="DigitalPianism_Reindex" />

Now we add a new mass action to the index grid mass actions dropdown:


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="adminhtml.indexer.grid.grid.massaction">
                <argument name="options" xsi:type="array">
                    <item name="reindex" xsi:type="array">
                        <item name="label" xsi:type="string" translate="true">Reindex</item>
                        <item name="url" xsi:type="string">reindex/reindex/reindex</item>

Finally we create the controller that will handle the reindex:



namespace DigitalPianism\Reindex\Controller\Adminhtml\Reindex;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;

 * Class Index
 * @package DigitalPianism\Reindex\Controller\Adminhtml\Reindex
class Reindex extends Action
     * Check the permission to run it
     * @return bool
    protected function _isAllowed()
        return $this->_authorization->isAllowed('DigitalPianism_Reindex::reindex');

     * @return void
    public function execute()
        $indexerIds = $this->getRequest()->getParam('indexer_ids');
        if (!is_array($indexerIds)) {
            $this->messageManager->addError(__('Please select indexers.'));
        } else {
            try {
                foreach ($indexerIds as $indexerId) {
                    /** @var \Magento\Framework\Indexer\IndexerInterface $model */
                    $model = $this->_objectManager->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId);
                    __('%1 indexer(s) were reindexed.', count($indexerIds))
            } catch (\Magento\Framework\Exception\LocalizedException $e) {
            } catch (\Exception $e) {
                    __("We couldn't reindex indexer(s)' because of an error.")



How to

First enable the module:

php bin/magento module:enable DigitalPianism_Reindex
php bin/magento setup:upgrade

Then go to System > Index Management, select the indexes you want to reindex and choose reindex in the mass actions dropdown. Click the submit button and you're done

enter image description here


Create deploy.sh file in your project root directory and past following content

rm -rf /var/www/project/public_html/var/cache/ /var/www/project/public_html/var/page_cache/ /var/www/project/public_html/var/generation/ /var/www/project/public_html/var/view_preprocessed/ /var/www/project/public_html/pub/static/adminhtml/ /var/www/project/public_html/pub/static/frontend/ /var/www/project/public_html/pub/static/_requirejs/
/var/www/project/public_html/bin/magento setup:upgrade
/var/www/project/public_html/bin/magento setup:static-content:deploy
/var/www/project/public_html/bin/magento indexer:reindex

now create deploy.php file in your project root directory and past following content

ini_set('display_errors', 'On');
$log = '';
$file = /*'/bin/bash ' .*/ dirname(__FILE__) . '/deploy.sh';
$cmds = explode("\n", file_get_contents($file));
foreach($cmds as $k=>$cmd) {
if(substr($cmd, 0, 1) == '#') continue;
$log_bfr = '';
    $log_bfr = shell_exec("$cmd");
if(strlen($log_bfr) <= 0)    
   $log .= $cmd . '<br>' . $log_bfr;
echo $log;

whenever you need reindex ya cache clean you run this file.

  • I ran your code many times but its still not indexing anything :-( Sep 30, 2016 at 12:07
  • you need to replace this path /var/www/project/public_html/var/cache/ and add your project application path.
    – Pratik
    Sep 30, 2016 at 12:14
  • I did that: /var/www/vhosts/my-site/my-site-sub-domain/var/ Sep 30, 2016 at 12:22
  • Do i need to increase server timeout ? Sep 30, 2016 at 12:53

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.