• Home
  • Jobs
  • Courses
  • Teachers
  • For business
  • Blog
  • ES/EN

0

5
Views
apache lib-wsgi 403 Forbidden

The only way I can run apps on my local machine is by using apache and lib-wsgi. I have installed all the relevent packages including encodings but in my browser I am getting a 403 Forbidden error and in my error logs I am getting this:

AH00051: child pid 28900 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'

I have run

sudo chmod a+x on my files

and

sudo chmod +rw on my folders.

and

sudo chown on my working directories

What do I need to do to get this working?

These are my files:

.conf file:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/demo1
        ServerName 127.0.0.1
        # Give an alias to to start your website url with
     WSGIDaemonProcess application python-home=/var/www/html/demo1
     WSGIProcessGroup flask-hello-app
     WSGIApplicationGroup %{GLOBAL}
     WSGIScriptAlias /demo1 /var/www/html/demo1/flask-hello-app.wsgi
     <Directory /var/www/html/demo1/>
                # set permissions as per apache2.conf file
            Options FollowSymLinks
            # AllowOverride None
            # Require all granted
            Order deny,allow
            Allow from all
     </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

flask-hello-app.wsgi

#!/uae/bin/python3
import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/var/www/html/demo1/')
from application import app as application
application.secret_key = 'super_secret_key'

flask-hello-app.py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:F00tBall@127.0.0.1:5432/example'
db = SQLAlchemy(app)

class Person(db.Model):
    __tablename__ = 'persons'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(), nullable=False)

db.create_all()

@app.route('/')
def index():
    return 'Hello '

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

I really need to know how to get this working.

Thanks.

10 days ago ·

Santiago Trujillo

Answer question
Remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Startups
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.