How to install composer on Godaddy cPanel

If you want to install composer on a godaddy shared hosting, you can follow these steps:

On root folder type:

wget https://getcomposer.org/installer
php installer --check
php installer
rm -f installer

to return the path of composer type:

which composer

it’ll return something like: /opt/cpanel/composer/bin/composer

then you can use composer using its full path:
php-cli /opt/cpanel/composer/bin/composer install

for ex. :

php-cli /opt/cpanel/composer/bin/composer install
php-cli /opt/cpanel/composer/bin/composer update

Also if you want to run php artisan , you can type:

/usr/bin/php-cli artisan

Can’t access DB or phpmyadmin locally

If you got an error like: “Host ‘localhost’ is not allowed to connect to this MariaDB server” you can edit the file xampp\mysql\bin\my.ini

Add this line:
skip-grant-tables
after [mysqld] group.

Example:
[mysqld]
skip-grant-tables
port=3306
socket=/tmp/mysql.sock

After that, login to phpmyadmin and repair the users table as it mostly is corrupted.

Also try to rename :

xampp\mysql\data\ibdata1
to
xampp\mysql\data\ibdata1.bak

How to put Magento 2 in maintenance mode

Even I think this should be a simple checkbox in Magento Control Panel but the most simple way I found is to put a file in var folder with the name of: var/.maintenance.flag

If you want to allow an ip or a group of ips you simply write this list of ips in a file: var/.maintenance.ip

Of course if you have access to CLI you can just type:

bin/magento maintenance:enable –ip=1.2.3.4

where –ip=1.2.3.4 is the ip that can access the website normally ..

if you use a shared hosting, to run the above command you have to go to the public_html folder first :
cd public_html

and then run the command using php
php bin/magento maintenance:enable –ip=1.2.3.4

For more information go to :
https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-maint.html

How to configure your host in one company and your email in another

If you want to host your website with one company and your emails in another you have to edit your domain name DNS Zone.

All you have to do is to add A host @ to point to your website host and “mail” to point to your email server and finally add MX record @ with priority 0 and Points to mail.yourdomain.com ..

For more details, check this page:

How to redirect everything to HTTPS

Redirect all non-HTTPS traffic to HTTPS using htaccess

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTPS} !on [NC]
 RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

for more htaccess tips, go to this url:

https://www.leaseweb.com/labs/tag/htaccess/

Download a file using command line in Windows

If you want to download a file using only command line, you can create a batch file (.bat) with the following :

download.bat

@Echo OFF
SetLocal EnableDelayedExpansion
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('http://www.source.com/test.txt', 'C:\destination\test.txt')

Of course you have to change the source and destination according to your needs.

The only problem is that running this file will open the command prompt for few seconds .. to avoid that you can create a VBscript file (.vbs) that will run the batch file in the background without the appearance of the command prompt.

runme.vbs

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c download.bat"
oShell.Run strArgs, 0, false