Monday, May 4, 2020

How To install And configure Chrony as NTP Server & Client On Ubuntu 20

Video Tutorial - https://youtu.be/GoqzGN8dxxU

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

In this Tutorial, you will learn how to configure chrony as NTP server and NTP Client. With chrony suite you can synchronize the system clock with an external time server using the Network Time Protocol (NTP).
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing Environment Setup-
Server Ubuntu 20.04 LTS             Hostname - www.yourdomain.com  , ip Address - 192.168.1.50 
Chrony Client- Linux Mint 19.3 Tricia    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd
apt update ; apt install -y build-essential net-tools curl git software-properties-common

apt update ; apt install chrony -y
systemctl start chrony ; systemctl enable chrony
nano /etc/chrony/chrony.conf
pool 0.jp.pool.ntp.org iburst maxsources 2
pool 1.jp.pool.ntp.org iburst maxsources 2
pool 2.jp.pool.ntp.org iburst maxsources 2
pool 3.jp.pool.ntp.org iburst maxsources 2

allow 192.168.1.50
allow 192.168.1.50/24
systemctl restart chrony
chronyc clients



Chrony Client Setup -
apt update ; apt install chrony -y
systemctl start chrony ; systemctl enable chrony
nano /etc/chrony/chrony.conf
server 192.168.1.50 prefer iburst
systemctl restart chrony
chronyc sources
chronyc sources -v

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

Sunday, May 3, 2020

How To Install & Configure NTP Server and Client on Ubuntu 20.04 LTS

 Video Tutorial -https://youtu.be/4pqktasscIc

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

NTP (Network Time Protocol) is a networking protocol designed to synchronize the clocks of computers over a network. NTP allows you to synchronize the clocks of all the systems within the network. NTP server synchronizes its time by contacting a number of servers around the world.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing Environment Setup-
Server - Ubuntu 20.04 LTS             Hostname - www.yourdomain.com  , ip Address - 192.168.1.50 
Client -Linux Mint 19.3 Tricia     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd
apt update ; apt install -y build-essential net-tools curl git software-properties-common

sudo apt-get update ; sudo apt-get install ntp -y
sntp --version
sudo nano /etc/ntp.conf
https://support.ntp.org/bin/view/Servers/NTPPoolServers

pool 0.asia.pool.ntp.org iburst
pool 1.asia.pool.ntp.org iburst
pool 2.asia.pool.ntp.org iburst
pool 3.asia.pool.ntp.org iburst
sudo service ntp restart ; sudo service ntp status


NTP Client -
sudo apt-get update ; sudo apt-get install ntpdate -y
sudo nano /etc/hosts
192.168.1.50    www.yourdomain.com    
sudo service ntp stop
sudo ntpdate www.yourdomain.com
sudo service ntp start

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

How To install Composer On Ubuntu 20.04 LTS / Linux Mint 19.3

Video Tutorial -

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

Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and install them for you, using the appropriate versions according to the project requirements.
Offcial Website - https://getcomposer.org/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Testing Environment Setup-  : Ubuntu 20.04 LTS (focal fossa)   |  Linux Mint 19.3 Tricia
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd
apt update ; apt install -y build-essential net-tools curl git software-properties-common php-cli

curl -sS https://getcomposer.org/installer | php ; mv composer.phar /usr/local/bin/composer ; chmod +x /usr/local/bin/composer ; composer -V


Or
apt update ; apt install -y build-essential net-tools curl git software-properties-common php-cli
Composer link - https://getcomposer.org/download/


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

composer -V

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

How To Install Yarn on Ubuntu 20.04 / Linux Mint 19.3 Tricia

Video Tutorial -  https://youtu.be/XO80AfXtLIg

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

Yarn is the fast, reliable, and secure package management system for Nodejs application.
Offcial website :https://classic.yarnpkg.com/en/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Os : Ubuntu 20.04 LTS (focal fossa) 64Bit ||         Linux Mint 19.3 Tricia
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
apt install -y build-essential net-tools curl git software-properties-common curl

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs -y
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
source ~/.profile  
nvm install v12.16.2
nvm use v12.16.2

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update && sudo apt install yarn -y
yarn --version
npm install -g yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
source ~/.bashrc

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

Saturday, May 2, 2020

Setup Apache as Reverse Proxy for Tomcat Server On Ubuntu 20.04 LTS / Linux Mint 19.3


Video Tutorial - https://youtu.be/Ho3AqTvX9fo

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

Apache Tomcat a free and open-source web server used for hosting the Java-based web application. It is one of the most widely used web server that enables you to run Java files easily.
Offcial Tomcat Website - http://tomcat.apache.org/
Apache Reverse Proxy Guide - https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Os Details-
Ubuntu 20.04 LTS (focal fossa)|| hostname - www.yourdomain.com || java -version -openjdk version "11.0.7
Linux Mint 19.3 Tricia  || Hostname - www.example.com | java -version -openjdk version "11.0.7
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd
apt install -y build-essential net-tools curl git software-properties-common
groupadd tomcat ; useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Tomcat Download Page - https://tomcat.apache.org/download-90.cgi
cd /opt/ ; wget http://apachemirror.wuchna.com/tomcat/tomcat-9/v9.0.34/bin/apache-tomcat-9.0.34.tar.gz
tar -xzvf apache-tomcat-9.0.34.tar.gz ; mv apache-tomcat-9.0.34/ tomcat/
chown -R tomcat:tomcat /opt/tomcat ; chmod +x /opt/tomcat/bin/*
nano ~/.bashrc
export CATALINA_HOME=/opt/tomcat
source ~/.bashrc
echo $CATALINA_HOME ; $CATALINA_HOME/bin/startup.sh
$CATALINA_HOME/bin/shutdown.sh ; chown -hR tomcat:tomcat /opt/tomcat/
nano /etc/systemd/system/apache-tomcat.service
[Unit]
Description=Apache Tomcat 9 Servlet Container
After=syslog.target network.target

[Service]
User=tomcat
Group=tomcat
Type=forking
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
systemctl daemon-reload ; systemctl start apache-tomcat ; systemctl enable apache-tomcat ; systemctl status apache-tomcat

nano /opt/tomcat/conf/tomcat-users.xml
<tomcat-users>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="admin-gui,manager-gui"/>
</tomcat-users>

User - admin || Password - admin

nano /opt/tomcat/webapps/manager/META-INF/context.xml
<!-- -->
nano /opt/tomcat/webapps/host-manager/META-INF/context.xml
<!-- -->
systemctl restart apache-tomcat

apt-get install apache2 -y
systemctl stop apache2.service ; systemctl start apache2.service ; systemctl enable apache2.service
a2enmod proxy proxy_http

nano /etc/apache2/sites-available/yourdomain.conf
<VirtualHost *:80>
        ServerName yourdomain.com
        ServerAlias www.yourdomain.com
        ServerAdmin webmaster@yourdomain.com
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyRequests Off
        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>
      
        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http://127.0.0.1:8080/

        <Location />
          Order allow,deny
          Allow from all
        </Location>

   </VirtualHost>

a2dissite 000-default.conf ; a2ensite yourdomain.conf
systemctl restart apache2.service
http://www.yourdomain.com           
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------apt-get install apache2 -y
systemctl stop apache2.service ; systemctl start apache2.service ; systemctl enable apache2.service
a2enmod proxy proxy_http
nano /etc/apache2/sites-available/example.conf
<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin webmaster@example.com
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyRequests Off
        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>
      
        ProxyPass / http://127.0.0.1:8080/
        ProxyPassReverse / http://127.0.0.1:8080/

        <Location />
          Order allow,deny
          Allow from all
        </Location>

   </VirtualHost>

a2dissite 000-default.conf ; a2ensite example.conf
systemctl restart apache2.service
http://www.example.com           
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

installing Tomcat with Nginx As a Reverse Proxy On Ubuntu 20.04 LTS / Linux Mint 19.3 Tricia

Video Tutorial - https://youtu.be/4LVA6emT9zI

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

Apache Tomcat a free and open-source web server used for hosting the Java-based web application. It is one of the most widely used web server that enables you to run Java files easily.
Offcial Apache Tomcat Website - http://tomcat.apache.org/

Nginx is a high performance reverse proxy server and web server.
Proxying is typically used to distribute the load among several servers, seamlessly show content from different websites, or pass requests for processing to application servers over protocols other than HTTP.
Offcial Nginx Website - https://www.nginx.com/
NGINX Reverse Proxy - https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Os Details-
Ubuntu 20.04 LTS (focal fossa)|| hostname - www.yourdomain.com || java -version -openjdk version "11.0.7
Linux Mint 19.3 Tricia  || Hostname - www.example.com | java -version -openjdk version "11.0.7
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd 
apt install -y build-essential net-tools curl git software-properties-common nginx
groupadd tomcat ; useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

Tomcat Download Page - https://tomcat.apache.org/download-90.cgi
cd /opt/ ; wget http://apachemirror.wuchna.com/tomcat/tomcat-9/v9.0.34/bin/apache-tomcat-9.0.34.tar.gz
tar -xzvf apache-tomcat-9.0.34.tar.gz ; mv apache-tomcat-9.0.34/ tomcat/
chown -R tomcat:tomcat /opt/tomcat ; chmod +x /opt/tomcat/bin/*

nano ~/.bashrc
export CATALINA_HOME=/opt/tomcat
source ~/.bashrc
echo $CATALINA_HOME ; $CATALINA_HOME/bin/startup.sh

$CATALINA_HOME/bin/shutdown.sh ; chown -hR tomcat:tomcat /opt/tomcat/
nano /etc/systemd/system/apache-tomcat.service
[Unit]
Description=Apache Tomcat 9 Servlet Container
After=syslog.target network.target

[Service]
User=tomcat
Group=tomcat
Type=forking
Environment=CATALINA_PID=/opt/tomcat/tomcat.pid
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
systemctl daemon-reload ; systemctl start apache-tomcat ; systemctl enable apache-tomcat ; systemctl status apache-tomcat

nano /opt/tomcat/conf/tomcat-users.xml
<tomcat-users>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="admin-gui,manager-gui"/>
</tomcat-users>

User - admin || Password - admin

nano /opt/tomcat/webapps/manager/META-INF/context.xml
<!-- -->
nano /opt/tomcat/webapps/host-manager/META-INF/context.xml
<!-- -->
systemctl restart apache-tomcat

nano /etc/nginx/sites-available/tomcat.conf
server {
  listen 80;

  server_name   www.yourdomain.com;
  access_log /var/log/nginx/tomcat-access.log;
  error_log /var/log/nginx/tomcat-error.log;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
  }
}
ln -s /etc/nginx/sites-available/tomcat.conf /etc/nginx/sites-enabled/
systemctl restart nginx

http://www.yourdomain.com            
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
nano /etc/nginx/sites-available/tomcat.conf
server {
  listen 80;

  server_name   www.example.com;
  access_log /var/log/nginx/tomcat-access.log;
  error_log /var/log/nginx/tomcat-error.log;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
  }
}

ln -s /etc/nginx/sites-available/tomcat.conf /etc/nginx/sites-enabled/
systemctl restart nginx
http://www.example.com

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

installing Java & Setting Up Environment Variables on Ubuntu 20.04 / Linux Mint 19.3 Tricia

Video Tutorials -

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

Java is one of the most popular programming languages used to build different kinds of applications and systems. Java runs on all major operating systems and devices. You can find applications developed in Java on your laptop, phone, and game console.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Os : Ubuntu 20.04 LTS (focal fossa) 64Bit        ||         Linux Mint 19.3 Tricia
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd  ; apt install -y build-essential net-tools curl git software-properties-common

apt update
apt install openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless -y
update-alternatives --config java

Setting Up Environment Variables :
nano /etc/profile.d/java.sh
export PATH=$PATH:/usr/lib/jvm/java-11-openjdk-amd64/bin/
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
export J2SDKDIR=/usr/lib/jvm/java-11-openjdk-amd64/
source /etc/profile.d/java.sh
java -version ; echo $JAVA_HOME ; which java

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