sudo pip3 install Flask
sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi-py3
sudo apt-get install php
sudo nano /var/www/heeseop/run.wsgi
import sys
sys.path.append("/var/www/heeseop")
from heeseop import app as application
* from heeseop is << heeseop means heeseop.py
sudo nano /var/www/heeseop/heeseop.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
sudo nano /etc/apache2/apache2.conf
#For FLASK folder
<VirtualHost *:80>
ServerName heeseop.com
WSGIScriptAlias / /var/www/heeseop/run.wsgi
</VirtualHost>
#For another domain
<VirtualHost *:80>
ServerName domian.com
WSGIScriptAlias / /var/www/domain/run.wsgi
</VirtualHost>
#For PHP or HTML foler
<VirtualHost *:80>
ServerName blog.com
DocumentRoot /var/www/blog
</VirtualHost>
-------------------------------------------------------
ref
-------------------------------------------------------
Virtual Environment
sudo pip install virtualenv
mkdir myproject
cd myproject
virtualenv venv
. venv/bin/activate
-------------------------------------------------------
Simple Demo - app.py
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run(0.0.0.0)
0.0.0.0 is several ip address in case of remote connection.
sudo nano /etc/apache2/sites-available/heeseop.conf<VirtualHost *:80> ServerName 192.168.50.216 WSGIDaemonProcess app threads=5 WSGIScriptAlias / /var/www/heeseop/run.wsgi DocumentRoot /var/www/heeseop <Directory /var/www/heeseop> WSGIProcessGroup app WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> ErrorLog /var/www/heeseop/logs/error.log LogLevel warn CustomLog /var/www/heeseop/logs/access.log combined </VirtualHost>
-------------------------------------------------------
Virtual Environment
sudo pip install virtualenv
mkdir myproject
cd myproject
virtualenv venv
. venv/bin/activate
-------------------------------------------------------
Simple Demo - app.py
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run(0.0.0.0)
0.0.0.0 is several ip address in case of remote connection.
sudo nano /etc/apache2/sites-available/heeseop.conf<VirtualHost *:80> ServerName 192.168.50.216 WSGIDaemonProcess app threads=5 WSGIScriptAlias / /var/www/heeseop/run.wsgi DocumentRoot /var/www/heeseop <Directory /var/www/heeseop> WSGIProcessGroup app WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all </Directory> ErrorLog /var/www/heeseop/logs/error.log LogLevel warn CustomLog /var/www/heeseop/logs/access.log combined </VirtualHost>
cd /etc/apache2/sites-available
sudo a2dissite 000-default
sudo a2ensite heeseop.conf
sudo service apache2 restart