certbot certonly --manual --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory -d *.yourdomain.com
Linux – see who has sudo / root access
cat /etc/group | grep sudo
Duplicating a MySQL table, indices, and data
To copy with indexes and triggers do these 2 queries:
CREATE TABLE newtable LIKE oldtable; INSERT INTO newtable SELECT * FROM oldtable;
To copy just structure and data use this one:
CREATE TABLE tbl_new AS SELECT * FROM tbl_old;
Yii2 Gii – Table Update
ALTER TABLE `tablename` ADD `lock` int(5) NOT NULL, ADD `created_at` date DEFAULT NULL, ADD `created_by` int(11) NOT NULL DEFAULT 0, ADD `deleted_by` int(11) NOT NULL DEFAULT 0, ADD `deleted_at` date DEFAULT NULL, ADD `updated_at` date DEFAULT NULL, ADD `updated_by` int(11) NOT NULL DEFAULT 0 AFTER branch_status;
Magento Set the File permission
Magento Set the File permission (you need to be root/ sudo)
sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} \; && sudo find var vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} \; && sudo chown -R www-data:www-data . && sudo chmod u+x bin/magento With the path: cd /var/www/html/magento2 && find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} + && chmod u+x bin/magento
Letsencrypt Force Renew
certbot renew --force-renewal -i apache -d example.com -d www.example.com
Linux and Unix Copy files
To copy a directory with all subdirectories and files, use the cp command. Below is an example command of how you would use the cp command to copy files. Additional information about this command and other examples are available through the above cp link.
cp -r /home/hope/files/* /home/hope/backup
In the example above, the cp command would copy all files, directories, and subdirectories in the /home/hope/files directory to the /home/hope/backup directory.
or
Copy a folder called /tmp/conf to /tmp/backup:
cp -avr /tmp/conf/ /tmp/backup
-a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all.
-v : Explain what is being done.
-r : Copy directories recursively. Example
Cannot access field from join query in search model (Yii2)
echo < pre >; var_dump($query->createCommand()->sql); echo < /pre >;
Add Foreign Key to existing table (MySQL)
To add a foreign key (grade_id) to an existing table (users), follow the following steps:
ALTER TABLE users ADD grade_id SMALLINT UNSIGNED NOT NULL DEFAULT 0; ALTER TABLE users ADD CONSTRAINT fk_grade_id FOREIGN KEY (grade_id) REFERENCES grades(id);
Letsencrypt (Certbot) Generate The Wildcard SSL Certificate
Now with the help of Certbot will generate wildcard certificate for our test domain erpnext.xyz
sudo certbot certonly --manual --preferred-challenges=dns --email nome@erpnext.xyz --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -d *.erpnext.xyz
After executing the above command, the Certbot will share a text record to add to your DNS.
Please deploy a DNS TXT record under the name _acme-challenge.erpnext.xyz with the following value: J50GNXkhGmKCfn-0LQJcknVGtPEAQ_U_WajcLXgqWqo
Then you will receive:
Press Enter to Continue Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/erpnext.xyz-0001/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/erpnext.xyz-0001/privkey.pem Your cert will expire on 2019-08-31. To obtain a new or tweaked version of this certificate in the future, simply run certbot again. To non-interactively renew *all* of your certificates, run "certbot renew" - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
done!