2

I am trying to find my way to reindex the system using cli (in cms graphical interface on save and schedule corn jobs did not work). Diverse commands were tried:

- php /bin/magento indexer:reindex [indexer]
- php /bin/magento indexer:reindex 

Unfortunately nothing worked and returned message "Could not open input file: /bin/magento".

Any advise?

Situation: - Mode in developer set yesterday successfully (Today cannot open), used command: php magento deploy:mode:set developer, confirmation "Enabled developer mode."

  • In /bin structure ran command ls -la shown that the Magento file is there (what I see in file structure as well).

3 Answers 3

4

You should not have an initial forward slash. Make sure you are in root of magento directory and run:

php bin/magento indexer:reindex 

or

bin/magento indexer:reindex

rather than:

php /bin/magento indexer:reindex 

If this still does not work execute permissions are not present for bin/magento and you will get a different error 'Permission Denied'. To fix this running 'chmod u+x bin/magento' from root will fix the permissions. Now you should be able to run the 'bin/magento indexer:reindex' command.

15
  • Is there still an error?
    – harri
    Jun 14, 2017 at 11:51
  • 1. by command "php bin/magento indexer:reindex", reply "[Zend_Db_Adapter_Exception] SQLSTATE[HY000] [2002] No such file or directory" and "[PDOException] SQLSTATE[HY000] [2002] No such file or directory ". I think its because "bin" is a folder from root perspective and to enter it, its missing "/"; 2. by command "bin/magento indexer:reindex" I got the answer as you said "bash: bin/magento: Permission denied". To fix it I tried
    – Ausra
    Jun 14, 2017 at 11:54
  • to place command "chmod u+x bin/magento" direct after it in root as you told. Unfortunately, no reaction after it.. any alternative advises or how could I go around that permission issue? PS sorry @Harri had to split content due to max char limit
    – Ausra
    Jun 14, 2017 at 11:54
  • There wont be a reaction after changing permission it just changes it silently. Try the bin/magento indexer:reindex again now you have permission to execute bin/magento
    – harri
    Jun 14, 2017 at 11:59
  • Also if your permissions are wrong for bin/magento also will be worth looking over devdocs.magento.com/guides/v2.1/install-gde/prereq/… to make sure all permissions are set corectly.
    – harri
    Jun 14, 2017 at 12:07
2

Remove cache manually from these directories except .htaccess file:

  1. pub/static (except .htaccess)
  2. var/cache
  3. var/di
  4. var/page_cache
  5. var/view_preprocessed (except .htaccess)

It will work by these only. Comment If didnt

13
  • Thank you for follow-up, @Jai. Sorry never did it before. You mean deleting all folders in the structures except ".htaccess"? Are you sure? :) in the 1st "pub/static" there are 3 sub-folders ("_requirejs", "adminhtml", "frontend"), in 2nd "var/cache" there are 8 sub-folders with "mage" begining and etc. :) all sub-folders to delete?
    – Ausra
    Jun 14, 2017 at 12:35
  • yes. delete all as mentioned. Only to skip .htaccess file.
    – Jarnail S
    Jun 14, 2017 at 12:38
  • good news, @Jai :) - the system survived after deleting all the structures. Static files, and other cache were flushed, re-entered to cli, but the indexing command still does not work..."bin/magento indexer:reindex" returns "bash: bin/magento: Permission denied", although I am the only user account on server (admin). Any ideas how to work around that permission (Im in development mode)? I placed in root structure "chmod u+x bin/magento", but the cli did not bring anything back...
    – Ausra
    Jun 14, 2017 at 16:37
  • Good. Now run these commands and let me know: "find ./ -type f | xargs chmod 644" ,"find ./ -type d | xargs chmod 755" ,"chmod -Rf 777 var" ,"chmod -Rf 777 media"
    – Jarnail S
    Jun 15, 2017 at 3:55
  • This will solve your problem: "chmod -R 777 /var/www/magento2" => magento2 is root directory . Let me know if it didnt work
    – Jarnail S
    Jun 15, 2017 at 4:01
0

Could you please check the file and folder permission as given in Magento 2 Docs

Files and Folder Permissions

cd <your Magento install dir>

find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;

find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;

chown -R :<web server group> .

chmod u+x bin/magento

For Your Reference Files and Folder Permission in Magento 2

9
  • have to admit that I dont know how to do it. I placed the lines one after the other, no reaction from server after entering one after the other: "find var vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \;", then "find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \;", then "chmod u+x bin/magento". Maybe I did it wrong? What do you mean by "<web server group>" is this a root structure?
    – Ausra
    Jun 14, 2017 at 12:29
  • "<web server group>" is user group created in the server. For example some of server have "vhosts" as user group.
    – Suresh S
    Jun 14, 2017 at 13:32
  • Im on server provider(hosting company), is this still the same thing if its sharing server basis?
    – Ausra
    Jun 14, 2017 at 15:59
  • are you in dedicated server or shared server? can you excute the command ls -l and send the screenshot. Let me check and share the details how to do this.
    – Suresh S
    Jun 14, 2017 at 16:27
  • I am on shared server. The command that you gave on root structure brought: total 896 link to ScreenShot dropbox.com/s/kumf41nybwcyo8b/…
    – Ausra
    Jun 14, 2017 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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