DEV Community

Discussion on: Flask Deploy with Apache on CentOS - Minimal Setup

Collapse
 
chasexu profile image
Chase

hi, I got a 403 forbidden error, any possible solutions? I created my app not in www folder, is this going to cause a trouble.

Collapse
 
sm0ke profile image
Sm0ke

Hello Chase. Thank you for noticing the article.
Can you extract drop here some relevant information from the apache logs?
Also, using a Heroku deploy, might be a good choice.

Collapse
 
chasexu profile image
Chase

Hi, I have figured out the problem, all I have to do is to create every in var/www folder instead. But I started to have another problem is that, the system try to run the app using python2.7 which is absolutely causing errors.
Here is the error log gives me,

[Thu Feb 06 23:17:27.417817 2020] [:error] [pid 24709] [client ::1:39996] SyntaxError: invalid syntax
[Thu Feb 06 23:20:07.161239 2020] [:error] [pid 24708] [client ::1:39998] mod_wsgi (pid=24708): Target WSGI script '/var/www/nzn/wsgi.py' cannot be loaded as Python module.
[Thu Feb 06 23:20:07.161274 2020] [:error] [pid 24708] [client ::1:39998] mod_wsgi (pid=24708): Exception occurred processing WSGI script '/var/www/nzn/wsgi.py'.
[Thu Feb 06 23:20:07.161288 2020] [:error] [pid 24708] [client ::1:39998] Traceback (most recent call last):
[Thu Feb 06 23:20:07.161301 2020] [:error] [pid 24708] [client ::1:39998] File "/var/www/nzn/wsgi.py", line 10, in
[Thu Feb 06 23:20:07.161344 2020] [:error] [pid 24708] [client ::1:39998] from nzn import app as application
[Thu Feb 06 23:20:07.161372 2020] [:error] [pid 24708] [client ::1:39998] File "/var/www/nzn/nzn/init.py", line 64
[Thu Feb 06 23:20:07.161376 2020] [:error] [pid 24708] [client ::1:39998] marks = {range: f'{range:.2f}' for range in [0.02, 0.05, 0.1, 0.15, 0.2]},
[Thu Feb 06 23:20:07.161379 2020] [:error] [pid 24708] [client ::1:39998] ^
[Thu Feb 06 23:20:07.161381 2020] [:error] [pid 24708] [client ::1:39998] SyntaxError: invalid syntax

As my personal experience this error is caused by using the python2 instead of python3.

Thanks

Thread Thread
 
sm0ke profile image
Sm0ke

Hello, yep might be the Python version.
Using Python3 is not an option? Python2 reach the EOL in Jan this year.