Friday, October 21, 2022

How to upload local file to Linux server through Mac SSH terminal

scp /path/to/file username@servername/ip:/destination/folder/

scp /Volumes/HDD/yourfilename.zip root@ip/server:/var/www/yourdirectorypath/public



To copy a file from the local server to the remote one:

scp FILENAME user@remote_server:/remote/path/FILENAME

To copy a file from the remote server to the local one:

scp user@remote_server:/remote/path/FILENAME /local/path/FILENAME


Installing PHP 8.1 to Add PHP support to Nginx on Ubuntu

 Install PHP for Nginx with PHP-FPM:

sudo apt update

sudo apt install --no-install-recommends php8.1 [Apache HTTP server and its httpd process]

sudo apt-get install php8.1-fpm -y [For PHP-FPM works with nginx]

php -v

sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-imap

php -m


Check if PHP-FPM is running:

sudo systemctl status php8.1-fpm

Add PHP support to Nginx:

sudo nano /etc/nginx/sites-available/default

Enable PHP in Nginx’s config file:

server {

  # Example PHP Nginx FPM config file

  listen 80 default_server;

  listen [::]:80 default_server;

  root /var/www/html;

  # Add index.php to setup Nginx, PHP & PHP-FPM config

  index index.php index.html index.htm index.nginx-debian.html;

  server_name _;

  location / {

    try_files $uri $uri/ =404;

  }

  # pass PHP scripts on Nginx to FastCGI (PHP-FPM) server

  location ~ \.php$ {

    include snippets/fastcgi-php.conf;


    # Nginx php-fpm sock config:

    fastcgi_pass unix:/run/php/php8.1-fpm.sock;

    # Nginx php-cgi config :

    # Nginx PHP fastcgi_pass 127.0.0.1:9000;

  }

  # deny access to Apache .htaccess on Nginx with PHP, 

  # if Apache and Nginx document roots concur

  location ~ /\.ht {

    deny all;

  }

} # End of PHP FPM Nginx config example

sudo nginx -t

sudo systemctl restart nginx

How to install MySQL on Ubuntu 22.04

 Installing MySQL:

sudo apt update

sudo apt install mysql-server

sudo systemctl start mysql.service


Configuring MySQL:

sudo mysql_secure_installation



Creating a Dedicated MySQL User and Granting Privileges:

  sudo mysql

 mysql -u root -p

 CREATE USER 'mailapp'@'localhost' IDENTIFIED WITH authentication_plugin BY 'password';

 CREATE USER 'mailapp'@'localhost' IDENTIFIED BY 'password';

 CREATE USER 'mailapp'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

 ALTER USER 'mailapp'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

 GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT on *.* TO 'mailapp'@'localhost' WITH GRANT OPTION;

 GRANT ALL PRIVILEGES ON *.* TO 'mailapp'@'localhost' WITH GRANT OPTION;

 FLUSH PRIVILEGES;

 exit

 

 mysql -u mailapp -p

How To Make secured Nginx with Let's Encrypt on Ubuntu

 Installing Certbot:

sudo apt install certbot python3-certbot-nginx

Confirming Nginx’s Configuration:

sudo nano /etc/nginx/sites-available/example.com

sudo nginx -t

sudo systemctl reload 


Allowing HTTPS Through the Firewall:

sudo ufw status

sudo ufw allow 'Nginx Full'

sudo ufw delete allow 'Nginx HTTP'

sudo ufw status


Obtaining an SSL Certificate:

sudo certbot --nginx -d example.com -d www.example.com



 Verifying Certbot Auto-Renewal:

 sudo systemctl status certbot.timer

 sudo certbot renew --dry-run

Monday, September 26, 2022

How to change Folder and File Permission in Linux


sudo find /var/www/html -type d -exec chmod 755 {} \;

sudo find /var/www/html -type f -exec chmod 644 {} \;

sudo chmod 644 /var/www/html/textbook.php

sudo chmod 644 /var/www/html/textbook.php


sudo systemctl restart httpd

Wednesday, September 21, 2022

Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache Engine

Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:
Restart:
/etc/init.d/apache2 restart

sudo /etc/init.d/apache2 restart

sudo service apache2 restart

Stop
/etc/init.d/apache2 stop

sudo /etc/init.d/apache2 stop

sudo service apache2 stop

/etc/init.d/apache2 start

sudo /etc/init.d/apache2 start

sudo service apache2 start

Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:

sudo systemctl start apache2.service

sudo systemctl stop apache2.service

sudo systemctl restart apache2.service

sudo systemctl status apache2.service

CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x:

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

CentOS/Fedora/RHEL (Red Hat) Linux version 7.x or newer:

## Start command ##
sudo systemctl start httpd.service
## Stop command ##
sudo systemctl stop httpd.service
## Restart command ##
sudo systemctl restart httpd.service

Alpine Linux:

service apache2 start
service apache2 stop
service apache2 status
service apache2 restart


Tuesday, September 20, 2022

Two-Factor Authentication (2FA) for Webmin with Google Authenticator

First install Perl Modules :
https://blog.olineit.com/2022/09/install-perl-cpan-module-in-centos-8.html

Then follow the instructions as given through the URL:
https://devtutorial.io/how-to-install-two-factor-authentication-2fa-for-webmin-p2845.html

How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...