Tag: Magento 2

  • How to Enable Magento 2 Cronjob

    Magento uses cron jobs for numerous features to schedule activities. To enable the cron job in Magento 2, log in to the server using SSH. Switch to the appropriate user if you are logged in as root. Now run command

    php bin/magento cron:install
    

    If you need to remove the cronjob, run

    php bin/magento cron:remove
    

    set cronjob in magento 2

    See Magento

  • Set Magento 2 in Production Mode

    To see current mode in Magento 2, run

    php bin/magento deploy:mode:show
    

    Example

    Magento 2 mode

    To set Magento 2 in production mode, run

    php bin/magento deploy:mode:set production
    

    See Magento 2

  • Magento 2 Change Email of an Admin user

    To change email address of an admin user, run following SQL in MySQL command promt or in phpMyAdmin

    update admin_user set email='NEW_EMAIL_ADDR_HERE' where email='OLD_EMAIL_ADDR_HERE';
    

    See Magento 2

  • Magento 2 Disable Two-Factor Authentication

    Magento 2.4.0 come with Two-Factor authentication. Once you installed Magento 2.4.0 or latest you will be asked to setup Two-Factor Autentication.

    magento 2

    To Disable Two-Factor Authentication, edit file

    vi app/etc/config.php
    

    Find

            'Magento_TwoFactorAuth' => 1,
    

    Replace with

            'Magento_TwoFactorAuth' => 0,
    

    Run commands

    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy -f
    

    Now you will be able to login to Magento Admin with out setting up Two-Factor autentication.

    See Magento 2

  • Magento 2 Enable SSL

    To enabel SSL on magento 2 site using command line (SSH), first change to the folder where magento installed.

    cd /home/yoursite/html
    

    Now run

    php bin/magento setup:store-config:set --use-secure=1 --base-url="https://m2.serverok.in"
    php bin/magento setup:store-config:set --use-secure-admin=1 --base-url="https://m2.serverok.in"
    

    Replace “m2.serverok.in” with your Magento installation Url.

  • Magento 2 CLI

    Create Magento project

    composer create-project --repository=https://repo.magento.com/ magento/project-community-edition=2.4.6 .

    To install Magento 2

    php bin/magento setup:install --base-url=https://yourdomain.com --db-host=localhost --db-name=magento --db-user=root --db-password=MYSQL_ROOT_PW_HERE --admin-firstname=Yujin --admin-lastname=Boby [email protected] --admin-user=OkAdmin --admin-password=ADMIN_PW_HERE --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1 --backend-frontname="admin" --search-engine=elasticsearch7

    To create an Admin user, run

    php bin/magento admin:user:create --admin-user="serverok" --admin-firstname="Server" --admin-lastname="Ok" --admin-email="[email protected]" --admin-password="secUre@1919"

    Maintenance mode

    php -d memory_limit=-1 bin/magento maintenance:enable

    Check Maintenance mode status

    php -d memory_limit=-1 bin/magento maintenance:status

    To allow IP in maintance mode

    php -d memory_limit=-1 bin/magento maintenance:allow-ips 117.247.196.198 112.133.248.2

    Flush Magento cache

    php bin/magento cache:flush

    Deploy static content

    php -d memory_limit=-1 bin/magento setup:static-content:deploy
    php -dmemory_limit=6G  bin/magento setup:static-content:deploy -f de_DE en_US it_IT fr_FR

    Change admin login path

    php bin/magento setup:config:set --backend-frontname="admin_path"

    Show Magento configuration. The second command shows the configuration related elastic search

    php bin/magento config:show
    php bin/magento config:show | grep 'elastic'

    See Magento 2