Tuesday, April 11, 2023

Ruby Hello World Example- How To Write and Execute Ruby Program on Ubuntu 20.04

 Ruby is an interpreted, high-level, general-purpose programming language which supports multiple programming paradigms.

apt update ; apt-get install ruby -y
whereis ruby
which ruby

nano helloworld.rb
#!/usr/bin/ruby

# Hello world ruby program

puts "Hello World!";

ruby helloworld.rb
( or )
chmod u+x helloworld.rb
./helloworld.rb

Executing Ruby one liner - ruby -e 'puts "Hello World!\n"'

_____________________________________________________________________________________

Tuesday, April 4, 2023

How To Install Flask with Gunicorn and Nginx on Oracle Linux 9

 in This Tutorial you will Learn " How To Install Flask with Gunicorn and Nginx on Oracle Linux 9"
Flask is a web application framework written in Python.
Gunicorn is a WSGI server.
NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9.0   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
sudo dnf update ;  sudo dnf install epel-release -y
sudo dnf install python3-pip python3-devel gcc -y
dnf install nginx -y
nginx -version


dnf install --assumeyes python3-pip
pip3 install virtualenv
sudo update-crypto-policies --set LEGACY
sudo reboot
sudo mkdir /sample_project && cd /sample_project
sudo chmod 777 /sample_project
virtualenv projectenv
source projectenv/bin/activate

pip3 install gunicorn flask
pip install --upgrade pip
nano  /sample_project/helloworld.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return "<h1 style='color:red'>Hello, World!</h1>"

if __name__ == '__main__':
    app.run(host='0.0.0.0')


sudo firewall-cmd --add-port=5000/tcp --permanent ; sudo firewall-cmd --reload

python helloworld.py
http://127.0.0.1:5000


nano /sample_project/wsgi.py
from helloworld import app

if __name__ == "__main__":
    app.run()

firewall-cmd --add-port=8000/tcp --permanent ; firewall-cmd --reload
python helloworld.py
http://0.0.0.0:8000
deactivate
gunicorn --bind 0.0.0.0:8000 wsgi:app
_________________________________________________________________________________________________________________________________