Apache & mod_wsgi issue working together

47 views
Skip to first unread message

Νίκος Βέργος

unread,
Sep 5, 2018, 11:24:16 AM9/5/18
to modwsgi
=================
httpd-vhosts.conf
=================

<VirtualHost *:80>
    ServerName superhost.gr
    ServerAdmin ni...@superhost.gr

    WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
    WSGIScriptAlias / /home/nikos/public_html/app.py

    <Directory /home/nikos/public_html>
        WSGIProcessGroup public_html
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading On

       AllowOverride None
       Require all granted
    </Directory>

    #ErrorLog /home/nikos/public_html/logs/error.log
</VirtualHost>

[root@superhost BACKUP]# chmod -R 755 /home/nikos/
chmod: changing permissions of ‘/home/nikos/fcgi-bin/php7.3.fcgi’: Operation not permitted

[root@superhost BACKUP]# ls -ld /home/nikos/
drwxr-xr-x 13 nikos nikos 4096 Sep  5 15:31 /home/nikos/

[root@superhost BACKUP]# chmod -R 755 /home/nikos/
chmod: changing permissions of ‘/home/nikos/fcgi-bin/php7.3.fcgi’: Operation not permitted
[root@superhost BACKUP]# ls -ld /home/nikos/
drwxr-xr-x 13 nikos nikos 4096 Sep  5 15:31 /home/nikos/

I Removed both mod_wsgi and python36u-mod_wsgi as well. I installed yum install httpd-devel to get rid of the 'apsx' issue. Here is the results of the express install. 

[root@superhost public_html]# 
mod_wsgi-express install-module 
LoadModule wsgi_module "/usr/lib64/httpd/modules/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIPythonHome "/usr" 

Do you make anyhting out of it as to why still cannot load my wsgi file? I'm still getting the forbidden error.... :-(

Graham Dumpleton

unread,
Sep 5, 2018, 7:38:02 PM9/5/18
to mod...@googlegroups.com
I don't see anything in this email to confirm that you have done things I previously suggested you do.

1. No indication that you are successfully using Include directive to include httpd-vhosts.conf into the main Apache configuration file.

2. No indication that you have correct LoadModule line in the main Apache configuration. Running ``mod_wsgi-express install-module`` does not modify the main Apache configuration file, it only shows what you need to add. It should be added just after existing LoadModule lines in the main Apache configuration file.

3. You are still using ServerName with value superhost.gr when I told you that because you had an existing VirtualHost for post 80 with the same ServerName, that the existing one would be used and not this one. You would have to create a new sub domain for use with this if want a separate site where the WSGI application runs at the root of the site.

Since you are having so may issues with having the second VirtualHost, to make it easier to understand and identify where you are missing things, add the configuration inside of your existing VirtualHost in the main Apache configuration file. That is, add:

    WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
    WSGIScriptAlias /mypythonapp /home/nikos/public_html/app.py


    <Directory /home/nikos/public_html>
        WSGIProcessGroup public_html
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptReloading On

       AllowOverride None
       Require all granted
    </Directory>

Note that I have changed the first argument of WSGIScriptAlias to '/mypythonapp'.

This means when you make a web request, you should use:


Note that I am travelling this week for work, so expect slow responses.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Νίκος @ SuperHost

unread,
Sep 6, 2018, 12:51:30 AM9/6/18
to mod...@googlegroups.com
When i moved the contents form vhosts.conf to httpd.conf it worked right away!! 2 questions.

1. If i put the contents back to vhosts.conf and create a new subdomain like 'nikos.superhost.gr' then i could only access my webpage as 'http://nikos.superhost.gr' ?Becouse i want to access it only as 'http://superhost.gr' nto with subdomain in front

2. I have 3 scripts inside 'public_html'. Is this the right way to configure to run them through mod_wsgi  or there is a more general way so i dont have an each line for every script?
WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py

<Directory /home/nikos/public_html>
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptReloading On

    AllowOverride None
    Require all granted
</Directory>

You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/4sM5QIitIyI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.

Graham Dumpleton

unread,
Sep 6, 2018, 8:24:51 AM9/6/18
to mod...@googlegroups.com

On 6 Sep 2018, at 2:51 pm, Νίκος @ SuperHost <nikos.at....@gmail.com> wrote:

When i moved the contents form vhosts.conf to httpd.conf it worked right away!! 2 questions.

1. If i put the contents back to vhosts.conf and create a new subdomain like 'nikos.superhost.gr' then i could only access my webpage as 'http://nikos.superhost.gr'

Correct.

Becouse i want to access it only as 'http://superhost.gr' nto with subdomain in front

So it must be part of the existing VirtualHost with that ServerName.

2. I have 3 scripts inside 'public_html'. Is this the right way to configure to run them through mod_wsgi  or there is a more general way so i dont have an each line for every script?
WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
This will not work as written because the first one for '/' will match first with higher precedence that sub URLs, you need to reverse the order.

It also may not work because you are setting WSGIApplicationGroup to fixed value. This means all will be run in same interpreter context and thus may interfere with each other. Better to use:

<Directory /home/nikos/public_html>
    AllowOverride None
    Require all granted
</Directory>

WSGIDaemonProcess downloads user=nikos group=nikos threads=5
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess clientele user=nikos group=nikos threads=5
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess app user=nikos group=nikos threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py process-group=app application-group=%{GLOBAL}

This way each is own process.

You don't need to set WSGIScriptReloading as that is enabled by default.

The above is recommended over trying to run in same process group in different interpreter contexts (application group), as some Python packages will not work in sub interpreters. By using different daemon process groups, you can force main interpreter context (%{GLOBAL%}) and so ensure you don't have such issues.

Νίκος @ SuperHost

unread,
Sep 6, 2018, 9:57:30 AM9/6/18
to mod...@googlegroups.com
It worked very well Graham, thank you!
One last thing!

Is there a way to move this directives to vhost.conf and Apache looks there as supplementery directives for superhost.gr?
As extra directions that for what is already having in its httpd.conf for superhost.gr domain.

Νίκος Βέργος

unread,
Sep 6, 2018, 10:56:38 AM9/6/18
to modwsgi
I just noticed that although 'app.py' is loading the other 2 scripts cannot laod the same way as this one although we now have 2 separated process for each script.

Error is: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Graham Dumpleton

unread,
Sep 6, 2018, 7:16:45 PM9/6/18
to mod...@googlegroups.com

On 6 Sep 2018, at 11:57 pm, Νίκος @ SuperHost <nikos.at....@gmail.com> wrote:

It worked very well Graham, thank you!
One last thing!

Is there a way to move this directives to vhost.conf and Apache looks there as supplementery directives for superhost.gr?
As extra directions that for what is already having in its httpd.conf for superhost.gr domain.

Not as a separate VirtualHost.

You could add to the separate file just:

<Directory /home/nikos/public_html>
    AllowOverride None
    Require all granted
</Directory>

WSGIDaemonProcess downloads user=nikos group=nikos threads=5
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess clientele user=nikos group=nikos threads=5
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess app user=nikos group=nikos threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py process-group=app application-group=%{GLOBAL}

and then in the main VirtualHost where you had put this, have:

    Include python-app.conf

So you aren't defining it as distinct VirtualHost, just extra config you include within the existing VirtualHost.

Graham Dumpleton

unread,
Sep 6, 2018, 7:18:37 PM9/6/18
to mod...@googlegroups.com

On 7 Sep 2018, at 12:56 am, Νίκος Βέργος <nikos.at....@gmail.com> wrote:

I just noticed that although 'app.py' is loading the other 2 scripts cannot laod the same way as this one although we now have 2 separated process for each script.

Error is: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.


Are clientele.py and download.py separate WSGI applications, or just modules to be used by app.py?

If the latter, you only want:

WSGIDaemonProcess app user=nikos group=nikos threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py process-group=app application-group=%{GLOBAL}

but change it to:

WSGIDaemonProcess app user=nikos group=nikos threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py process-group=app application-group=%{GLOBAL} python-path=/home/nikos/public_html

so app.py can import them. That is what python-path option does, by telling Python where the modules are to be imported.

If that isn't issue, you need to look at the Apache error log to see what the error is.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 4:45:35 AM9/7/18
to mod...@googlegroups.com
They are separate WSGI applications and when iam trying to run them directly in browser i get:

[Fri Sep 07 11:44:07.438696 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7359] [2018-09-07 11:44:07,438] ERROR in app: Exception on /clientele.py [GET]
[Fri Sep 07 11:42:08.911817 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336] [2018-09-07 11:42:08,911] ERROR in app: Exception on /downloads.py [GET]

while if i try to run them withe the flask development server they work as expected.

Νίκος Βέργος

unread,
Sep 7, 2018, 4:49:04 AM9/7/18
to modwsgi
Also both of those scripts seems to try to download. 'app.py' instead of themselves and i can see that because they give the same output as 'app.py' in the error log:

[Fri Sep 07 11:42:08.911854 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336] Traceback (most recent call last):
[Fri Sep 07 11:42:08.911858 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 11:42:08.911861 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     response = self.full_dispatch_request()
[Fri Sep 07 11:42:08.911865 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 11:42:08.911868 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     rv = self.handle_user_exception(e)
[Fri Sep 07 11:42:08.911871 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 11:42:08.911874 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 11:42:08.911876 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 11:42:08.911880 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     raise value
[Fri Sep 07 11:42:08.911882 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 11:42:08.911885 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     rv = self.dispatch_request()
[Fri Sep 07 11:42:08.911888 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 11:42:08.911892 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 11:42:08.911894 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/home/nikos/public_html/app.py", line 336, in index
[Fri Sep 07 11:42:08.911897 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     pagehit = cur.fetchone()[0] 
[Fri Sep 07 11:42:08.911817 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336
] [2018-09-07 11:42:08,911] ERROR in app: Exception on /downloads.py [GET]
[Fri Sep 07 11:42:08.911854 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336] Traceback (most recent call last):
[Fri Sep 07 11:42:08.911858 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 11:42:08.911861 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     response = self.full_dispatch_request()
[Fri Sep 07 11:42:08.911865 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 11:42:08.911868 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     rv = self.handle_user_exception(e)
[Fri Sep 07 11:42:08.911871 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 11:42:08.911874 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 11:42:08.911876 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 11:42:08.911880 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     raise value
[Fri Sep 07 11:42:08.911882 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 11:42:08.911885 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     rv = self.dispatch_request()
[Fri Sep 07 11:42:08.911888 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 11:42:08.911892 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 11:42:08.911894 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]   File "/home/nikos/public_html/app.py", line 336, in index
[Fri Sep 07 11:42:08.911897 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336]     pagehit = cur.fetchone()[0]
[Fri Sep 07 11:42:08.911901 2018] [wsgi:error] [pid 19469] [remote 46.103.174.201:7336] TypeError: 'NoneType' object is not subscriptable

Νίκος Βέργος

unread,
Sep 7, 2018, 4:54:23 AM9/7/18
to modwsgi
I also tried to run with the config as this:


WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5

WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias / /home/nikos/public_html/app.py

<Directory /home/nikos/public_html>
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}

    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    Require all granted
</Directory>
WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5

WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias / /home/nikos/public_html/app.py

<Directory /home/nikos/public_html>
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}

    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    Require all granted 

WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5

WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias / /home/nikos/public_html/app.py

<Directory /home/nikos/public_html>
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}

    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    Require all granted
</Directory>

But still iam gettign the exact error message.
WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5

WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
WSGIScriptAlias / /home/nikos/public_html/app.py

<Directory /home/nikos/public_html>
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}

    Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
    Require all granted
</Directory>

Graham Dumpleton

unread,
Sep 7, 2018, 4:59:38 AM9/7/18
to mod...@googlegroups.com
A common mistake people make when writing web apps is assuming that the current working directory is where your code is. Under a production web server, it often isn't. See:


Make sure you aren't trying to open files by relative paths, calculate an absolute path instead.

Alternative, add:

    home=/home/nikos/public_html

option to each WSGIDaemonProcess, if that is the directory where your code is written to assume it runs.

Too hard to guess what else it may be because the error traceback is displaying really badly for some reason for me and appears to be incomplete.

Graham

Νίκος @ SuperHost

unread,
Sep 7, 2018, 5:16:14 AM9/7/18
to mod...@googlegroups.com
Here is the error log when i try torun by browser clientele.py

[Fri Sep 07 12:10:39.767400 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639] [2018-09-07 12:10:39,767] ERROR in app: Exception on /clientele.py [GET]
[Fri Sep 07 12:10:39.767434 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639] Traceback (most recent call last):
[Fri Sep 07 12:10:39.767437 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 12:10:39.767450 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     response = self.full_dispatch_request()
[Fri Sep 07 12:10:39.767453 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 12:10:39.767456 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     rv = self.handle_user_exception(e)
[Fri Sep 07 12:10:39.767458 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 12:10:39.767461 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 12:10:39.767463 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 12:10:39.767466 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     raise value
[Fri Sep 07 12:10:39.767469 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 12:10:39.767471 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     rv = self.dispatch_request()
[Fri Sep 07 12:10:39.767474 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 12:10:39.767476 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 12:10:39.767479 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/home/nikos/public_html/app.py", line 337, in index
[Fri Sep 07 12:10:39.767481 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     cur.execute( '''SELECT hits FROM pages WHERE url = %s''', page )
[Fri Sep 07 12:10:39.767484 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib64/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
[Fri Sep 07 12:10:39.767486 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     result = self._query(query)
[Fri Sep 07 12:10:39.767489 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib64/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
[Fri Sep 07 12:10:39.767491 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     conn.query(q)
[Fri Sep 07 12:10:39.767494 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib64/python3.6/site-packages/pymysql/connections.py", line 515, in query
[Fri Sep 07 12:10:39.767496 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     self._execute_command(COMMAND.COM_QUERY, sql)
[Fri Sep 07 12:10:39.767499 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]   File "/usr/lib64/python3.6/site-packages/pymysql/connections.py", line 745, in _execute_command
[Fri Sep 07 12:10:39.767502 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639]     raise err.InterfaceError("(0, '')")
[Fri Sep 07 12:10:39.767509 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639] pymysql.err.InterfaceError: (0, '')
[Fri Sep 07 12:10:39.767530 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7639] 
[Fri Sep 07 12:10:40.216819 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640] [2018-09-07 12:10:40,216] ERROR in app: Exception on /favicon.ico [GET]
[Fri Sep 07 12:10:40.216876 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640] Traceback (most recent call last):
[Fri Sep 07 12:10:40.216883 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 12:10:40.216889 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     response = self.full_dispatch_request()
[Fri Sep 07 12:10:40.216895 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 12:10:40.216920 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     rv = self.handle_user_exception(e)
[Fri Sep 07 12:10:40.216927 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 12:10:40.216932 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 12:10:40.216938 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 12:10:40.216943 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     raise value
[Fri Sep 07 12:10:40.216949 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 12:10:40.216954 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     rv = self.dispatch_request()
[Fri Sep 07 12:10:40.216960 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 12:10:40.216965 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 12:10:40.216971 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/home/nikos/public_html/app.py", line 337, in index
[Fri Sep 07 12:10:40.216976 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     cur.execute( '''SELECT hits FROM pages WHERE url = %s''', page )
[Fri Sep 07 12:10:40.216981 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:76 40]   File "/usr/lib64/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
[Fri Sep 07 12:10:40.216987 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     result = self._query(query)
[Fri Sep 07 12:10:40.216992 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib64/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
[Fri Sep 07 12:10:40.216998 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     conn.query(q)
[Fri Sep 07 12:10:40.217003 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib64/python3.6/site-packages/pymysql/connections.py", line 515, in query
[Fri Sep 07 12:10:40.217009 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     self._execute_command(COMMAND.COM_QUERY, sql)
[Fri Sep 07 12:10:40.217014 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]   File "/usr/lib64/python3.6/site-packages/pymysql/connections.py", line 745, in _execute_command
[Fri Sep 07 12:10:40.217020 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640]     raise err.InterfaceError("(0, '')")
[Fri Sep 07 12:10:40.217027 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640] pymysql.err.InterfaceError: (0, '')
[Fri Sep 07 12:10:40.217059 2018] [wsgi:error] [pid 10994] [remote 46.103.174.201:7640] 


I dont understand why its tryign to load 'app/py' when i give 'http://superhost.gr/clientele.py' 
and this is how i have the directives in the main config.

    WSGIDaemonProcess public_html user=nikos group=nikos processes=1 threads=5
    WSGIProcessGroup public_html
    WSGIApplicationGroup %{GLOBAL}

    WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py
    WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py
    WSGIScriptAlias / /home/nikos/public_html/app.py

    <Directory /home/nikos/public_html>
        Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
        Require all granted
    </Directory>









Graham Dumpleton

unread,
Sep 7, 2018, 5:20:31 AM9/7/18
to mod...@googlegroups.com
You seem to have ignored how I said to set it up previously. I said to use:

<Directory /home/nikos/public_html>
    AllowOverride None
    Require all granted
</Directory>

WSGIDaemonProcess downloads user=nikos group=nikos threads=5
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess clientele user=nikos group=nikos threads=5
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess app user=nikos group=nikos threads=5
WSGIScriptAlias / /home/nikos/public_html/app.py process-group=app application-group=%{GLOBAL}

You can't run the three separate apps in the one interpreter context when using Flask as they will interfere with each other.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 5:30:49 AM9/7/18
to mod...@googlegroups.com
Okey i have written it back as per your suggestion and with the home directive:


<Directory /home/nikos/public_html>
    AllowOverride None
    Require all granted
</Directory>

WSGIDaemonProcess downloads user=nikos group=nikos threads=5 home=/home/nikos/public_html
WSGIScriptAlias /downloads /home/nikos/public_html/downloads.py process-group=downloads application-group=%{GLOBAL}

WSGIDaemonProcess clientele user=nikos group=nikos threads=5 home=/home/nikos/public_html
WSGIScriptAlias /clientele /home/nikos/public_html/clientele.py process-group=clientele application-group=%{GLOBAL}

WSGIDaemonProcess app user=nikos group=nikos threads=5 home=/home/nikos/public_html

Still the same error message:
[Fri Sep 07 12:28:45.567259 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] [2018-09-07 12:28:45,565] ERROR in app: Exception on /clientele.py [GET] [Fri Sep 07 12:28:45.567313 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] Traceback (most recent call last): [Fri Sep 07 12:28:45.567317 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app [Fri Sep 07 12:28:45.567320 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] response = self.full_dispatch_request() [Fri Sep 07 12:28:45.567324 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request [Fri Sep 07 12:28:45.567327 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] rv = self.handle_user_exception(e) [Fri Sep 07 12:28:45.567330 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception [Fri Sep 07 12:28:45.567335 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] reraise(exc_type, exc_value, tb) [Fri Sep 07 12:28:45.567339 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise [Fri Sep 07 12:28:45.567344 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] raise value [Fri Sep 07 12:28:45.567349 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request [Fri Sep 07 12:28:45.567352 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] rv = self.dispatch_request() [Fri Sep 07 12:28:45.567355 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request [Fri Sep 07 12:28:45.567358 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] return self.view_functions[rule.endpoint](**req.view_args) [Fri Sep 07 12:28:45.567361 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] File "/home/nikos/public_html/app.py", line 338, in index [Fri Sep 07 12:28:45.567364 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] pagehit = cur.fetchone()[0] [Fri Sep 07 12:28:45.567368 2018] [wsgi:error] [pid 11929] [remote 46.103.174.201:7980] TypeError: 'NoneType' object is not subscriptable

You received this message because you are subscribed to a topic in the Google Groups "modwsgi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/modwsgi/4sM5QIitIyI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to modwsgi+u...@googlegroups.com.

Graham Dumpleton

unread,
Sep 7, 2018, 6:22:06 AM9/7/18
to mod...@googlegroups.com
Set:

    LogLevel info

in your Apache VirtualHost so can see in logs what daemon process group and interpreter context the scripts are loaded.

And make sure you did restart Apache.

Graham

Νίκος @ SuperHost

unread,
Sep 7, 2018, 7:25:56 AM9/7/18
to mod...@googlegroups.com
[root@superhost public_html]# tail -f ../logs/error_log 
[Fri Sep 07 14:25:15.877193 2018] [wsgi:info] [pid 15773] mod_wsgi (pid=15773): Exiting process 'app'.
[Fri Sep 07 14:25:16.026260 2018] [wsgi:info] [pid 15941] mod_wsgi (pid=15941): Attach interpreter ''.
[Fri Sep 07 14:25:16.057524 2018] [wsgi:info] [pid 15940] mod_wsgi (pid=15940): Attach interpreter ''.
[Fri Sep 07 14:25:16.060303 2018] [wsgi:info] [pid 15941] mod_wsgi (pid=15941): Imported 'mod_wsgi'.
[Fri Sep 07 14:25:16.060387 2018] [wsgi:info] [pid 15941] mod_wsgi (pid=15941, process='clientele', application=''): Loading Python script file '/home/nikos/public_html/clientele.py'.
[Fri Sep 07 14:25:16.065764 2018] [wsgi:info] [pid 15942] mod_wsgi (pid=15942): Attach interpreter ''.
[Fri Sep 07 14:25:16.109641 2018] [wsgi:info] [pid 15940] mod_wsgi (pid=15940): Imported 'mod_wsgi'.
[Fri Sep 07 14:25:16.109731 2018] [wsgi:info] [pid 15940] mod_wsgi (pid=15940, process='downloads', application=''): Loading Python script file '/home/nikos/public_html/downloads.py'.
[Fri Sep 07 14:25:16.117103 2018] [wsgi:info] [pid 15942] mod_wsgi (pid=15942): Imported 'mod_wsgi'.
[Fri Sep 07 14:25:16.117195 2018] [wsgi:info] [pid 15942] mod_wsgi (pid=15942, process='app', application=''): Loading Python script file '/home/nikos/public_html/app.py'.

Graham Dumpleton

unread,
Sep 7, 2018, 7:35:51 AM9/7/18
to mod...@googlegroups.com
Based on that they should be in separate processes, so there must be something in your code which is importing 'app.py' module into your other application. You will need to work through your code, add debugging statements as necessary to log what it is doing and see if you can find the issue. Turn hard for me to guess.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 7:40:23 AM9/7/18
to mod...@googlegroups.com
All 3 wsgi application have similar these 2 liens of code:

application = Flask(__name__)
app = application

but thats needed for the wsgi app to run. Is it because they have the same name?
should i name them app1, app2, app3 ?

Graham Dumpleton

unread,
Sep 7, 2018, 7:42:59 AM9/7/18
to mod...@googlegroups.com
It is the 'import' statements you have which will be the issue.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 7:44:15 AM9/7/18
to mod...@googlegroups.com
All 3 apps have the exact same import lines

import re, os, sys, socket, time, datetime, random, smtplib, subprocess, httpagentparser, geoip2.database, pymysql
from datetime import datetime, timedelta
from flask import Flask, request, redirect, render_template, url_for, Response

Graham Dumpleton

unread,
Sep 7, 2018, 7:58:10 AM9/7/18
to mod...@googlegroups.com
Rename your app.py file to main.py and change app.py in the Apache configuration to main.py as well and restart Apache.

See if anything breaks because it now can't import app module, or if some other error occurs.

Also, if you have any .pyc file (compiled byte code files) in the same directory, remove them.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 8:07:00 AM9/7/18
to mod...@googlegroups.com
After changin to main.py
superhost.gr continues to run

biut the other 2 separate wsgi script keep providing the same weeor message.

Graham Dumpleton

unread,
Sep 7, 2018, 8:09:44 AM9/7/18
to mod...@googlegroups.com
You are telling me that even though the app.py file no longer exists, you are getting the exact same error message and stack trace which shows:

File "/home/nikos/public_html/app.py", line 338, in index
If you aren't, it isn't really the same, so without seeing it I can't comment.

Graham

Νίκος @ SuperHost

unread,
Sep 7, 2018, 8:15:49 AM9/7/18
to mod...@googlegroups.com
Yes, i ahve modifies http.conf to


WSGIDaemonProcess main user=nikos group=nikos threads=5 home=/home/nikos/public_html WSGIScriptAlias / /home/nikos/public_html/main.py process-group=main application-group=%{GLOBAL}

and renamed app.py to main.py and restarted apache

[root@superhost public_html]# ll
total 60
-rwxr-xr-x 1 nikos nikos 14437 Sep  7 14:53 clientele.py
-rwxr-xr-x 1 nikos nikos  9766 Sep  7 14:53 downloads.py
-rwxr-xr-x 1 nikos nikos 13297 Sep  7 12:01 main.py
drwxr-xr-x 4 nikos nikos  4096 Sep  5 21:59 private
-rw------- 1 nikos nikos  1408 Sep  5 21:59 sftp-config.json
drwxr-xr-x 6 nikos nikos  4096 Sep  5 22:05 static
drwxr-xr-x 2 nikos nikos  4096 Sep  5 22:05 templates
[root@superhost public_html]# 
and the error is:

[root@superhost public_html]# systemctl restart httpd
[root@superhost public_html]# tail -f ../logs/error_log 
[Fri Sep 07 15:15:06.024468 2018] [wsgi:info] [pid 17701] mod_wsgi (pid=17701): Exiting process 'main'.
[Fri Sep 07 15:15:06.200115 2018] [wsgi:info] [pid 17883] mod_wsgi (pid=17883): Attach interpreter ''.
[Fri Sep 07 15:15:06.218236 2018] [wsgi:info] [pid 17884] mod_wsgi (pid=17884): Attach interpreter ''.
[Fri Sep 07 15:15:06.225575 2018] [wsgi:info] [pid 17882] mod_wsgi (pid=17882): Attach interpreter ''.
[Fri Sep 07 15:15:06.234264 2018] [wsgi:info] [pid 17883] mod_wsgi (pid=17883): Imported 'mod_wsgi'.
[Fri Sep 07 15:15:06.234352 2018] [wsgi:info] [pid 17883] mod_wsgi (pid=17883, process='clientele', application=''): Loading Python script file '/home/nikos/public_html/clientele.py'.
[Fri Sep 07 15:15:06.281984 2018] [wsgi:info] [pid 17882] mod_wsgi (pid=17882): Imported 'mod_wsgi'.
[Fri Sep 07 15:15:06.282110 2018] [wsgi:info] [pid 17882] mod_wsgi (pid=17882, process='downloads', application=''): Loading Python script file '/home/nikos/public_html/downloads.py'.
[Fri Sep 07 15:15:06.298443 2018] [wsgi:info] [pid 17884] mod_wsgi (pid=17884): Imported 'mod_wsgi'.
[Fri Sep 07 15:15:06.298542 2018] [wsgi:info] [pid 17884] mod_wsgi (pid=17884, process='main', application=''): Loading Python script file '/home/nikos/public_html/main.py'.
[Fri Sep 07 15:15:17.814760 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931] [2018-09-07 15:15:17,812] ERROR in app: Exception on /favicon.ico [GET]
[Fri Sep 07 15:15:17.814828 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931] Traceback (most recent call last):
[Fri Sep 07 15:15:17.814835 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 15:15:17.814842 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     response = self.full_dispatch_request()
[Fri Sep 07 15:15:17.814847 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 15:15:17.814853 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     rv = self.handle_user_exception(e)
[Fri Sep 07 15:15:17.814859 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 15:15:17.814865 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 15:15:17.814870 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 15:15:17.814876 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     raise value
[Fri Sep 07 15:15:17.814881 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 15:15:17.814887 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     rv = self.dispatch_request()
[Fri Sep 07 15:15:17.814892 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 15:15:17.814898 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 15:15:17.814904 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]   File "/home/nikos/public_html/main.py", line 338, in index
[Fri Sep 07 15:15:17.814909 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931]     pagehit = cur.fetchone()[0]
[Fri Sep 07 15:15:17.814917 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931] TypeError: 'NoneType' object is not subscriptable
[Fri Sep 07 15:15:17.814949 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9931] 
[Fri Sep 07 15:15:17.895627 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9929] mod_wsgi (pid=17884): Exception occurred processing WSGI script '/home/nikos/public_html/main.py'.
[Fri Sep 07 15:15:17.895851 2018] [wsgi:error] [pid 17884] [remote 46.103.174.201:9929] OSError: Apache/mod_wsgi failed to write response data: Broken pipe.


Graham Dumpleton

unread,
Sep 7, 2018, 8:23:42 AM9/7/18
to mod...@googlegroups.com
So there is no code mixing now that you have separated apps into separate processes.

Now your issue is that it seems your database queries are not returning any results. That is an issue you will need to solve.

One last thing I will say though is that keep in mind that if your code is dependent on environment variables in your personal user account, they will not be seen by the application when running under Apache.

Add debugging code to print out messages validating your database configuration used by the application is correct, and ensure that you aren't ignore errors from the database, and that you are properly validate the results you get. You need to use basic debugging steps now to work this out yourself.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 8:34:35 AM9/7/18
to mod...@googlegroups.com
Database queries are correct dont mind about this fetch error, it always said this months now but the value is being returned.

Yes all 3 wsgi apps use requsts than fetched envirromental variables but that is nto the issue here because if mod_wsgi had probelm returnign them then main.py woudl also fail to laod as well.

Shall i use ProxyPass so to directly all http traffic to flask develpoment server instance to handle the code and send data back to Apache?

Νίκος Βέργος

unread,
Sep 7, 2018, 8:48:54 AM9/7/18
to modwsgi
i renames main.py to web.py and when i tried to run clientele.py scirpt from browser i get:

tail -f ../logs/error_log 
[Fri Sep 07 15:45:05.455295 2018] [wsgi:info] [pid 18657] mod_wsgi (pid=18657): Exiting process 'web'.
[Fri Sep 07 15:45:05.611418 2018] [wsgi:info] [pid 18981] mod_wsgi (pid=18981): Attach interpreter ''.
[Fri Sep 07 15:45:05.621563 2018] [wsgi:info] [pid 18983] mod_wsgi (pid=18983): Attach interpreter ''.
[Fri Sep 07 15:45:05.646347 2018] [wsgi:info] [pid 18981] mod_wsgi (pid=18981): Imported 'mod_wsgi'.
[Fri Sep 07 15:45:05.646440 2018] [wsgi:info] [pid 18981] mod_wsgi (pid=18981, process='downloads', application=''): Loading Python script file '/home/nikos/public_html/downloads.py'.
[Fri Sep 07 15:45:05.654268 2018] [wsgi:info] [pid 18982] mod_wsgi (pid=18982): Attach interpreter ''.
[Fri Sep 07 15:45:05.656422 2018] [wsgi:info] [pid 18983] mod_wsgi (pid=18983): Imported 'mod_wsgi'.
[Fri Sep 07 15:45:05.656504 2018] [wsgi:info] [pid 18983] mod_wsgi (pid=18983, process='web', application=''): Loading Python script file '/home/nikos/public_html/web.py'.
[Fri Sep 07 15:45:05.702511 2018] [wsgi:info] [pid 18982] mod_wsgi (pid=18982): Imported 'mod_wsgi'.
[Fri Sep 07 15:45:05.702629 2018] [wsgi:info] [pid 18982] mod_wsgi (pid=18982, process='clientele', application=''): Loading Python script file '/home/nikos/public_html/clientele.py'.


[Fri Sep 07 15:45:19.194047 2018] [wsgi:error] [pid 18983] [remote 188.165.200.217:28837] /usr/lib64/python3.6/site-packages/pymysql/cursors.py:170: Warning: (1265, "Data truncated for column 'browser' at row 1")
[Fri Sep 07 15:45:19.194133 2018] [wsgi:error] [pid 18983] [remote 188.165.200.217:28837]   result = self._query(query)
[Fri Sep 07 15:45:27.754748 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246] [2018-09-07 15:45:27,753] ERROR in app: Exception on /clientele.py [GET]
[Fri Sep 07 15:45:27.754783 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246] Traceback (most recent call last):
[Fri Sep 07 15:45:27.754787 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
[Fri Sep 07 15:45:27.754790 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     response = self.full_dispatch_request()
[Fri Sep 07 15:45:27.754793 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
[Fri Sep 07 15:45:27.754797 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     rv = self.handle_user_exception(e)
[Fri Sep 07 15:45:27.754800 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
[Fri Sep 07 15:45:27.754803 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     reraise(exc_type, exc_value, tb)
[Fri Sep 07 15:45:27.754806 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
[Fri Sep 07 15:45:27.754809 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     raise value
[Fri Sep 07 15:45:27.754812 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
[Fri Sep 07 15:45:27.754815 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     rv = self.dispatch_request()
[Fri Sep 07 15:45:27.754818 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/usr/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
[Fri Sep 07 15:45:27.754821 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     return self.view_functions[rule.endpoint](**req.view_args)
[Fri Sep 07 15:45:27.754824 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]   File "/home/nikos/public_html/web.py", line 338, in index
[Fri Sep 07 15:45:27.754827 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246]     pagehit = cur.fetchone()[0]
[Fri Sep 07 15:45:27.754832 2018] [wsgi:error] [pid 18983] [remote 46.103.174.201:10246] TypeError: 'NoneType' object is not subscriptable


Although i'am hitting other scripts web.py tried to load instead.
Why it keeps wanting to load web.py when i clearly give

http://superhost.gr/clientele.py or
http://superhost.gr/downloads.py

I mean even the precedence in conf file is correct. I have web.py last.

Graham Dumpleton

unread,
Sep 7, 2018, 8:50:08 AM9/7/18
to mod...@googlegroups.com

On 7 Sep 2018, at 10:34 pm, Νίκος @ SuperHost <nikos.at....@gmail.com> wrote:

Database queries are correct dont mind about this fetch error, it always said this months now but the value is being returned.

Yes all 3 wsgi apps use requsts than fetched envirromental variables but that is nto the issue here because if mod_wsgi had probelm returnign them then main.py woudl also fail to laod as well.

According to that last error, it is your main.py which is failing. Look closely at the pid values.

As I said, add debug print statements to your code. Print out the values of the environment variables to prove they are correct etc. Just keep adding any debug print statements after that to verify things.

Νίκος @ SuperHost

unread,
Sep 7, 2018, 8:52:31 AM9/7/18
to mod...@googlegroups.com
chekc my new post where iam renaming main.py to web.py.

Νίκος Βέργος

unread,
Sep 7, 2018, 9:49:28 AM9/7/18
to modwsgi
Okey i have corrected 1 error about the database and remoevd entirely a line that trired to load a wsgi script from within another one.

Now web.py runs normally but the 2 thers script give no more error but in borwser they cannot be found.

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Reply all
Reply to author
Forward
0 new messages