Using this command we can easily configure the python 3.4 in virtual environment :-
virtualenv -p /usr/bin/python3.4 newpython
/django/contrib/admin/templates/registration/password_reset_form.html
/django/contrib/admin/templates/registration/password_reset_done.html
/django/contrib/admin/templates/registration/password_reset_confirm.html
/django/contrib/admin/templates/registration/password_reset_complete.html
/django/contrib/admin/templates/registration/password_reset_email.html
sudo apt-get install libapache2-mod-wsgi python-dev
#To enable mod_wsgi, run the following command:
sudo a2enmod wsgi
a. cd /var/www
b. sudo mkdir FlaskApp
c. cd FlaskApp
d. sudo mkdir FlaskApp
e .cd FlaskApp
f .sudo mkdir static templates
sudo nano __init__.py
#Add following logic to the file:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, I love Digital Ocean!"
if __name__ == "__main__":
app.run()
sudo nano /etc/apache2/sites-available/FlaskApp (for older ubuntu version)
sudo nano /etc/apache2/sites-available/FlaskApp.conf (for 13+ ubuntu version)
#Add the following lines of code to the file to configure the virtual host.
<VirtualHost *:8080> ServerName localhost ServerAdmin admin@mywebsite.com WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi <Directory /var/www/FlaskApp/FlaskApp/> Order allow,deny Allow from all </Directory> Alias /static /var/www/FlaskApp/FlaskApp/static <Directory /var/www/FlaskApp/FlaskApp/static/> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
sudo a2ensite FlaskApp
cd /var/www/FlaskApp sudo nano flaskapp.wsgi
Add the following lines of code to the flaskapp.wsgi file:
#!/usr/bin/python import sys import logging logging.basicConfig(stream=sys.stderr) sys.path.insert(0,"/var/www/FlaskApp/") from FlaskApp import app as application application.secret_key = '123456789'Save and close the file.
|--------FlaskApp |----------------FlaskApp |-----------------------static |-----------------------templates |-----------------------__init__.py |----------------flaskapp.wsgi
sudo service apache2 restart