Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

apache2 and python ?

Here you can discuss every aspect of Debian. Note: not for support requests!
Post Reply
Message
Author
1885
Posts: 127
Joined: 2014-06-05 04:23

apache2 and python ?

#1 Post by 1885 »

I'm looking for a guide to run some python script using apache2
I am doing this as a learning experience not for development.
With eventual connection to mariadb.

There are a lot of guides but I have not found an easy to follow debian guide.

Please throw me a bone.

doduckgo give the following:
https://duckduckgo.com/?q=debian+python ... t=h_&ia=qa

arzgi
Posts: 1185
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: apache2 and python ?

#2 Post by arzgi »

Code: Select all

aptitude search python | grep apache
p  libapache2-mod-python - Python-embedding module for Apache 2
p  libapache2-mod-python-doc - Python-embedding module for Apache 2 - documentation
p  python-certbot-apache - Apache plugin for Certbot
p  python-certbot-apache-doc - Apache plugin documentation for Certbot
Python is a programming language, apache web server. Neither is Debian spesific.

1885
Posts: 127
Joined: 2014-06-05 04:23

Re: apache2 and python ?

#3 Post by 1885 »

arzgi wrote:

Code: Select all

aptitude search python | grep apache
p  libapache2-mod-python - Python-embedding module for Apache 2
p  libapache2-mod-python-doc - Python-embedding module for Apache 2 - documentation
p  python-certbot-apache - Apache plugin for Certbot
p  python-certbot-apache-doc - Apache plugin documentation for Certbot
Python is a programming language, apache web server. Neither is Debian spesific.
thank you.
I understand that . I was hoping to get spoon fed a bit more (Laughing)
I'm a bit lazy with this.

I'll look at how to implement the following with my current *.conf sites-enabled file:

# apt-cache search python | grep apache
libapache-directory-jdbm-java - ApacheDS JDBM Implementation
libapache2-mod-auth-tkt - lightweight single-sign-on authentication module for Apache
libapache2-mod-python - Python-embedding module for Apache 2
libapache2-mod-python-doc - Python-embedding module for Apache 2 - documentation
libapache2-mod-wsgi - Python WSGI adapter module for Apache
libapache2-mod-wsgi-py3 - Python 3 WSGI adapter module for Apache
python-certbot-apache - Apache plugin for Certbot
python-certbot-apache-doc - Apache plugin documentation for Certbot

arzgi
Posts: 1185
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: apache2 and python ?

#4 Post by arzgi »

http://www.diveintopython.net / http://www.diveintopython3.net were the first manuals I read when I started studying python, those I can recommend. https://docs.python.org/3/ has more good docs.

Apache I have not used, but it is so popular, that I would think there are manuals written for it too.

jibberjabber
Posts: 162
Joined: 2016-01-10 16:58

Re: apache2 and python ?

#5 Post by jibberjabber »

Lesson #115 Giving the Dog a bone

I'm looking for a guide to run some python script using apache2
I am doing this as a learning experience not for development.
A good learning experience, is include learning how to read the results in a search.
To enhance that experience, and learn even more, start experimenting with some scripts,
python, or whatever, and try some .
Please throw me a bone.
There you go, there is the bone, fetch it.
I understand that . I was hoping to get spoon fed a bit more (Laughing)
I'm a bit lazy with this.
Lazy dogs never get off the porch, if you are to lazy to go hunt for something that has
actual meat, stay on the porch, and chew the bones that get thrown to you.
was hoping to get spoon fed a bit more (Laughing)
You will need to ask your mommy or daddy to do that, or ask them to hire a nanny to do the spoon feeding. :mrgreen:
Hope this was a good learning experience. :mrgreen:
P.S. What does this have to do with configuring a Debian system ? ,.. we do have a off topic, and general discussion boards for this kind of thing. For help with a python script maybe programming ?
written by HelpBot#8453
Alias jibberjabber
I am sorry, my english is not that good, and I sometimes have other problems,so my response might not be perfect.
N5RLX > "Jibber jabber ,all day and all night, jibber jabber jibber jabber"

1885
Posts: 127
Joined: 2014-06-05 04:23

Re: apache2 and python ?

#6 Post by 1885 »


User avatar
GarryRicketson
Posts: 5644
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: apache2 and python ?

#7 Post by GarryRicketson »

I will give a couple of tips here, and also noticed the OP's report, I would move the topic, but us "spam hunters" are not supposed to do that, a moderator will need to. Of course if the moderators feel this is the appropriate board, then they will leave it here.

Any way, the tips (hints) are : To start simple, with a simple python script, like the one shown here:
https://www.linux.com/blog/configuring- ... on-scripts
part only : The first step, which in my PHP experience I never had to do, is not mentionned in the guides above is to enable CGI processing in apache.

Code: Select all

sudo a2enmod cgi 
Further down, there is even a simple example python script:

Code: Select all

   #!/usr/bin/env python
    # -*- coding: UTF-8 -*-# enable debugging
    import cgitb
    cgitb.enable()    print("Content-Type: text/html;charset=utf-8")
    print()    print("Hello World!")
Once you have the website working and able to run a python script ( a simple one)
Then you are ready to start trying with more advanced scripts.

It is not clear if your server is even up and running, but for Debian, I suggest reading:
Some of the documentation specific to Debian

Code: Select all

/usr/share/doc/apache2/README 
https://wiki.debian.org/Apache
Installing the "Mariadb", on Debian, is not very hard, either.
You should now have something to start with, but you do need to get "off the porch", and start learning to do more on your own.

1885
Posts: 127
Joined: 2014-06-05 04:23

Re: apache2 and python ?

#8 Post by 1885 »

Thanks GarryRicketson,

I've read this link and liked the content.
https://www.linux.com/blog/configuring- ... on-scripts

I've been using Apache for years and never bothered to look : /usr/share/doc/apache2/

I appreciate the help. I've written a lot of php with mariadb and would like to see how python works apache.
We are currently working with simple python web servers in our lab and have successfully implement a a scoring chroot base for fbctf that uses a simple python web server to post who has control of the base, (https://github.com/facebook/fbctf) . it's fun.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: apache2 and python ?

#9 Post by debiman »

^ a python server would not require apache2.
1885 wrote:I'm looking for a guide to run some python script using apache2
so this script does not include the server?
in any case, i find this description incredibly vague, i can't even begin to point out all that is missing here.

apparently the answer is "yes, this is possible", but it seems you dismissed that saying "i knew that already, please throw me more".
how about you throw us a bone first?

1885
Posts: 127
Joined: 2014-06-05 04:23

Re: apache2 and python ?

#10 Post by 1885 »

debiman wrote:^ a python server would not require apache2.

apparently the answer is "yes, this is possible", but it seems you dismissed that saying "i knew that already, please throw me more".
how about you throw us a bone first?
I'm going to follow this path and try to run python script from a directory inside my apache2 document root.
I can run another python webserver on another port.

thanks

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: apache2 and python ?

#11 Post by debiman »

1885 wrote:run python script from a directory inside my apache2 document root.
to what end?
talking about servers, i assume you want the result of the script to be served - somehow?

Post Reply