Tuesday, February 23, 2021

How to host static websites for free using GIT HUB

 




prerequisite--CREATE A GITHUB ACCOUNT

username-

password- 

(-your computer will generate ssh key which will be added to the GIT



Step 1: Create a new repository

Log in and click on New in the top left section of your dashboard to create a new repository.

The repository can be public or private. Also, do not forget to check the Initialize this repository with a README option.



Step 2: Upload your Project

Click on Upload files button on top and upload all your project files.

In Commit Changes you can put in any message you want.



(OR)

TRANSFER FOLDER FROM YOUR LOCAL COMPUTER TO REMOTE COMPUTER (GITHUB)

-open terminal in /var/www/html in your computer

-from the project page(first page) click on git clone or download.

  1. Clone the repository locally --using git clone command: git clone <copied item>

  2. Make the changes to the local version – edit code

  3. Commit the changes locally -git status

              - git add <file1> <file2>

              - git commit -m ‘changes’

  4. Push the changes back up to the GitHub repository -git push origin master



Step 3: Make it live

- Go to Settings on the top right of your repo

  • Scroll down to section GitHub Pages

  • In the Source dropdown select master

Voila! Your website is live 🎉


Step 4: Look at your published website

Alright, time to visit your hosted website. In your browser got to:

{{yourUserName}}.github.io/{{yourRepoName}}


eg dawnStreaks.github.io/techStreaks



References-

https://medium.com/javascript-in-plain-english/how-to-host-a-static-website-for-free-7a2a959f5e4


Configure the DNS settings for your custom domain to point to GitHub Pages. This involves adding or updating DNS records to map your domain to GitHub's servers.

  • Log in to your domain registrar's website.
  • Locate the DNS settings or DNS management section.
  • Add the following DNS records:
    • For the root domain (e.g., example.com), create an A record with the value 185.199.108.153, 185.199.109.153, 185.199.110.153, and 185.199.111.153. These IP addresses are GitHub's Pages servers.
    • If you want to use a subdomain (e.g., www.example.com), create a CNAME record pointing to your GitHub Pages URL. You can find your GitHub Pages URL in your repository settings under the "GitHub Pages" section.

Note: DNS changes might take some time to propagate, so be patient.

 

To redirect www subdomain to the original domain, add a CNAME record with your GitHub pages profile URL with a .(dot) in the end, for example, ‘YOUR-GITHUB-USERNAME.github

 

set up custom domain

reference-

https://medium.com/@hossainkhan/using-custom-domain-for-github-pages-86b303d3918a

https://gist.github.com/notTag/4a60598d018124c9ac4a7b1f3e2bac9a


Downloading Laravel folder from Github to local computer

 

while downloading from git hub repository


-create a folder inside var/www/html

-do git clone for front end

    -delete node modules,

    -perform npm install

-do git clone for back end

    -delete vendor file

    -perform composer install

- php artisan key:generate

 

eg: coreui laravel template

https://github.com/coreui/coreui-free-vue-laravel-admin-template

push an existing repository from the local computer to git repo using command line

 Create a github account with username and password .

When you want to make a folder as git repository, associate that repository with the corresponding github account by adding the same username and password.

 

 To push an existing repository

 

Go to var/www/html/project-folder


git init

git config --global user.name "Your Name"

git config --global user.email "Your Email"

--------------------------------------------------------

git config --list to check current username & email

  1. Change username & email as desired. Make it a global change or specific to the local repo:
    git config [--global] user.name "Full Name"
    git config [--global] user.email "email@address.com"
  2. Per repo basis you could also edit .git/config manually instead
  3. -------------------------------------------------------------------------------------------------------------

 

create github repository

Add local machine ssh key to your github settings ssh


git remote add origin git@github.com:dawnStreaks/github_repo_name.git
git add . //to add all files
git commit -am “adding new project” //t
git push origin master

Please make sure you have the correct access rights
----------------------------------------------------
in case of any errors remove the remote origin,  then reset it in the following way:
-----------------------------------------------------------------------------------
        git remote rm origin
        git remote add origin  https://USERNAME:PASSWORD@github.com/username/reponame.git 
or       git remote add origin git@github.com:username/reponame.git  
 References:
https://www.atlassian.com/git/tutorials/syncing/git-pull 

Helpful linux commands

 
Let us create a directory
    sudo  mkdir -p /var/www/html/ostechnix1.lan/public_html....<directory name>
        


directories are owned by root user. We need to change the ownership to the regular user.
    sudo chown -R $USER:$USER /var/www/html


set read permissions to the Apache root directory i.e /var/www/html/
    sudo chmod -R 755 /var/www/html/

to open file
    sudo nano <filename with full path>

to generate key for GITHUB-to add your system to bitbucket

    $ ssh-keygen

to collect software
    sudo apt-get install <software_name>
eg
        sudo apt-get install nodejs
sudo apt-update

To set up a framework(eg. laravel, ubuntu)
    $sudo apt-get install npm
    $sudo apt install composer
    curl -sS https://getcomposer.org/installer | sudo php — –install-dir=/usr/local/bin –filename=composer
    sudo apt install curl
    $npm install// to install from packages folder in a project--based on package.json
    $composer install// to install into a project vendor folder--based on composer.json
    $sudo apt-get install nodejs

To convert eml to jpeg (munpack)

 munpack ForwardedMessage7.eml

-----------------------------------------------------
check php version
---------------------------------------------------
sudo php -v
sudo composer
sudo mysql -V    

 

------------------------------------------------
while removing windows from computer
------------------------------------------

after deleting the partition
sudo update-grub
------------------------------------------------------

Install PHP

-----------------------------------------------------
sudo apt update
sudo apt -y install php7.4
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

sudo apt-get install -y php7.3-{cli,fpm,json,common,bcmath,bz2,intl,gd,mbstring,zip,curl,xml,pear} 

-------------------------------------------------

TEST

    sudo nano /var/www/html/info.php
WRITE
    <?php
phpinfo();
?>

    http://your_server_ip/info.php

-------------------------------------
delete php
------------------------
sudo apt-get purge php7.*
$ sudo apt-get autoclean
$ sudo apt-get autoremove

FIND AND KILL THE RUNNING PROCESS

ps aux | grep -i apt

 

sudo kill <process_id>

 

How to create a virtual host in ubuntu

 To set up virtual host

    -create a project directory

Step 1 — Create a conf file

Copy 000-default.com.conf to create a new file in /etc/apache2/sites-available:

$ cd /etc/apache2/sites-available
$ sudo cp 000-default.com.conf example.com.conf


    -include that directory to sites available using <directoryname>.conf file- sudo nano /etc/apache2/sites-available/directoryname.conf
*nano-open editor
    -include the following contents for bionic beaver 18.04 ubuntu
        

Step 2 — Modify the new conf file


    -

<VirtualHost *:80>
    ServerAdmin your.email@gmail.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    <Directory /var/www/example.com/public_html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
    </IfModule>
</VirtualHost>



--------------------------

Restarting apache


    
include in/etc/hosts  if you dont have any ip

/or set up domain in godaddy
        -ip adress and server name
------------------------------------------------

Step 3 — Enabling a virtual host


-to enable the site
        sudo a2ensite <directoryname>
    -to test for syntax errors
        sudo apachectl configtest
-syntax ok

    -restart apache services
        sudo systemctl restart apache2

Step 4— Enabling SSL

Install certbot

sudo snap install --classic certbot

 

$ sudo certbot --apache -d example.com -d www.example.com 
 
sudo systemctl restart apache2 

 Reference website:

https://towardsdatascience.com/how-to-host-multiple-website-with-apache-virtual-hosts-4423bd0aefbf

Install LAMP in ubuntu




APACHE 2 INSTALLATION
    sudo apt update
    sudo apt install apache2

sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
sudo ufw app list
1
2
3
4
5
OutputAvailable applications:
  Apache
  Apache Full
  Apache Secure
  OpenSSH

As indicated by the output, there are three profiles available for Apache:

  • Apache: This profile opens only port 80 (normal, unencrypted web traffic)
  • Apache Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
  • Apache Secure: This profile opens only port 443 (TLS/SSL encrypted traffic)
sudo ufw allow 'Apache Full'
 

 

 
 




 Press Y and hit ENTER to continue


TEST:
http://your_server_ip

INSTALL MYSQL


1)sudo apt install mysql-server

---------------------------------------------------

  switch its authentication method from auth_socket to mysql_native_password

        sudo mysql
        SELECT user,authentication_string,plugin,host FROM mysql.user;

        ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
        FLUSH PRIVILEGES;

TEST
        SELECT user,authentication_string,plugin,host FROM mysql.user;
        exit

 

---------------------------------------------------
2)sudo mysql_secure_installation

--VALIDATE PASSWORD PLUGIN.-NO
REST- YES






INSTALL PHP MYADMIN
        sudo apt update
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

 adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is read automatically. The only thing you need to do is explicitly enable the mbstring PHP extension, which you can do by typing:

        sudo phpenmod mbstring

SEE PHPMYADMIN IN THE BROWSER

        sudo mysql -u root -p

        GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost';
        FLUSH PRIVILEGES;
        EXIT

 TEST

http://your-server-IP/phpmyadmin

RESTART APACHE2
    sudo systemctl restart apache2

Log in as either your root MySQL user or as a user dedicated to managing databases through the phpMyAdmin

-------------------------------------------------------------------------------------------------

Install PHP8.1

---------------------------------------------------------------------------------------------------

Add PPA for PHP 8.1

 

sudo apt install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

 

Install PHP 8.1

sudo apt install php8.1

 

Install PHP 8.1 Packages

sudo apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-intl -y

 

PHP 8 Enable

sudo a2dismod php8.0

sudo a2enmod php8.1

sudo service apache2 restart

 

php -v

sudo update-alternatives --set php /usr/bin/php8.1

 

 

 

 

 

 

------------------------------------------------------------------------------------------------

Reference:

1) https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04

2)https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04

Commonly used magento commands

 Magento Commands
-----------------------------------------------------------------------------
php bin/magento indexer:reindex

php bin/magento indexer:info

php bin/magento indexer:status

php bin/magento indexer:reset

 
php bin/magento cache:clean

php bin/magento cache:flush

php bin/magento cache:status

php bin/magento cache:clean full_page block_html

 
php bin/magento maintenance:status

php bin/magento maintenance:enable

php bin/magento maintenance:disable
 

php bin/magento cron:run
php bin/magento cron:run --group rb_crongroup
bin/magento --version


 -------------------------------------------------------------------------------
php bin/magento indexer:status
php bin/magento indexer:reindex catalogsearch_fulltext
php bin/magento indexer:reset catalogsearch_fulltext
php bin/magento indexer:info
php bin/magento indexer:status


 php bin/magento cron:run

How to backup db from the remote server to your computer

 1) ssh to the remote server using command or putty credentials (hostname, username, password, port)

 eg:ssh production-host@ssh.clouduser

2) Change directory to /tmp

         eg: cd /tmp

3)create a backup using db command and  credentials(username, password, hostname)

 WHOLE DB back up

mysqldump -h database.hostname -u username -p dbname | gzip > filename.dbbckup.sql.gz 


ONLY TABLES back up

mysqldump -h database.hostname -u username -p dbname <table_1> <table_2> | gzip > filename.sql.gz

4)Download it to your local computer

In your local computer command line enter the following command

scp -r production-host@ssh.clouduser:/tmp/filename.dbbckup.sql.gz /home/path/Desktop/


Monday, February 22, 2021

How to add meta tags to your magento account

Steps to add meta title, keywords and description to the Magento2.2 back-end

1)Login to the admin panel

2)Go to Content->Design->Configuration

 3)Select the website/store depending on your priority.

4)Store meta has higher priority than website meta

5)Add value  to the corresponding fields

6)Then in the HTML header section copy and paste the first part from google tag manager generated code

7) In the miscellaneous part copy and paste the second part from google tag manager generated code

8) Go to Store->Configuration->Sales->Google Analytics->Add the container ID from GTM generated code.

 

Reference: https://meetanshi.com/blog/magento-2-google-tag-manager/

Monday, February 15, 2021

Motherhood

 God!!

How life teaches you lessons.. Growing up, I thought how heartless some parents are and what a sweetheart some others turn out to be. 

But further as I grew up, I realize how frustrated you become in not being able to mould your kids into expected ways. To take such high degree risks without having any shoulder to back on, all this , just so that their kids may have a better life. And all the anger that was projected , was because you were way too dedicated, too ambitious and selfish only so that you kids may have a better life.

At the end of it all, you learn a lesson. To be hardworking and hustling. No matter how hard you try, you will be put down by the people you care. And that wont matter the least, Because you know when your kid grows up and reaches your place, she will reallize the reason behind your anger.  Because at the end of it, only hardwork and perseverence shows result. All those who were nice to you, were almost least bothered about your well being.


Sunday, February 14, 2021

How to setup magento in alpha server



Steps to deploy in a server
-----------------------------------------------------
1. download data base to the local
2. download code to the local
3. transfer to server using filezilla  SFTP (using ppk in case of shared hosting)

    - Upload the latest DB backup (.gz file) to alpha hosting inside dev.mysqlstaging.com folder

   - unzip the db backup file. command: gunzip filename.sql.gz

4. setup putty for ssh 

        login to SSH through Putty. port 87

5. login to mysql in cmd. credentials are in app/etc/env.php

mysql -u username -p;

6. use database

7. import the db using source command.
Command: source path to sql file

SOURCE /home/mysupplystagin/dev.mysupplystaging.com/9feb2021.dbbckup.sql;

5. give permission chmod -R 777 var pub generated

COMMANDS AT MAGENTO FOLDER USING SSH


1. php bin/magento deploy:mode:set developer

2. php bin/magento setup:upgrade
-------------------------------------------------------------------
Area code not set error://error on setup upgrade

UPDATE flag SET flag_data = NULL WHERE flag_code = 'system_config_snapshot';
UPDATE flag SET flag_data = NULL WHERE flag_code = 'config_hash';
DELETE FROM flag WHERE flag_code = 'system_config_snapshot';

php bin/magento app:config:import
php bin/magento cache:clean
php bin/magento setup:upgrade
-------------------------------------------------------------------------------

3. php bin magento setup:di:compile
4.php bin/magento setup:static-content:deploy -f
5.php bin/magento indexer:reindex
6.php bin/magento cache:clean
7.php bin/magento cache:flush

---------------------------------------------------------------------------------

Access the server using the folder name

--------------------------------------------------------------------------------

//missing css files. 

fixed by uploading .htaccess file to pub/static