Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96955 > unrolled thread
| Started by | tropical.dude.net@gmail.com |
|---|---|
| First post | 2015-09-21 11:41 -0700 |
| Last post | 2015-09-22 08:36 +1000 |
| Articles | 11 — 6 participants |
Back to article view | Back to comp.lang.python
Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 11:41 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 sohcahtoa82@gmail.com - 2015-09-21 12:19 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 12:39 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 "Albert Visser" <albert.visser@gmail.com> - 2015-09-21 21:28 +0200
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 12:44 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 John Gordon <gordon@panix.com> - 2015-09-21 19:41 +0000
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 12:47 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 12:51 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 alister <alister.nospam.ware@ntlworld.com> - 2015-09-21 20:29 +0000
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 tropical.dude.net@gmail.com - 2015-09-21 14:36 -0700
Re: Problem configuring apache to run python cgi on Ubuntu 14.04 Chris Angelico <rosuav@gmail.com> - 2015-09-22 08:36 +1000
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 11:41 -0700 |
| Subject | Problem configuring apache to run python cgi on Ubuntu 14.04 |
| Message-ID | <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com> |
Hello everybody,
I installed the LAMP stack on in Ubuntu, but I am having
problems configuring Apache to run python CGI scripts.
I ran:
sudo a2enmod cgi
I added to apache2.conf
<Directory /srv/www/yoursite/public_html>
Options +ExecCGI
AddHandler cgi-script .py
</Directory>
I created index.py:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-# enable debugging
import cgitb
cgitb.enable()
print("Content-Type: text/html;charset=utf-8")
print("Hello World!")
But it is still not working.
Can anybody help me out?
Thanks in advance.
[toc] | [next] | [standalone]
| From | sohcahtoa82@gmail.com |
|---|---|
| Date | 2015-09-21 12:19 -0700 |
| Message-ID | <3304d91e-e707-4b74-a9df-d1a18fe26e3c@googlegroups.com> |
| In reply to | #96955 |
On Monday, September 21, 2015 at 11:41:54 AM UTC-7, tropical...@gmail.com wrote:
> Hello everybody,
>
> I installed the LAMP stack on in Ubuntu, but I am having
> problems configuring Apache to run python CGI scripts.
>
> I ran:
> sudo a2enmod cgi
>
> I added to apache2.conf
> <Directory /srv/www/yoursite/public_html>
> Options +ExecCGI
> AddHandler cgi-script .py
> </Directory>
>
> I created index.py:
> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-# enable debugging
> import cgitb
>
> cgitb.enable()
> print("Content-Type: text/html;charset=utf-8")
> print("Hello World!")
>
> But it is still not working.
>
> Can anybody help me out?
>
> Thanks in advance.
"It isn't working" is about as useful as telling a mechanic "My car doesn't work" without giving details on what exactly is happening.
What exactly isn't working? What error message are you getting?
The first thing I would check is to make sure the permissions on index.py are set to allow execution. It is easy to forget to do that.
[toc] | [prev] | [next] | [standalone]
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 12:39 -0700 |
| Message-ID | <44059d47-ecb9-417e-b68a-caaf73fc6bda@googlegroups.com> |
| In reply to | #96956 |
On Monday, September 21, 2015 at 9:20:22 PM UTC+2, sohca...@gmail.com wrote:
> On Monday, September 21, 2015 at 11:41:54 AM UTC-7, tropical...@gmail.com wrote:
> > Hello everybody,
> >
> > I installed the LAMP stack on in Ubuntu, but I am having
> > problems configuring Apache to run python CGI scripts.
> >
> > I ran:
> > sudo a2enmod cgi
> >
> > I added to apache2.conf
> > <Directory /srv/www/yoursite/public_html>
> > Options +ExecCGI
> > AddHandler cgi-script .py
> > </Directory>
> >
> > I created index.py:
> > #!/usr/bin/env python
> > # -*- coding: UTF-8 -*-# enable debugging
> > import cgitb
> >
> > cgitb.enable()
> > print("Content-Type: text/html;charset=utf-8")
> > print("Hello World!")
> >
> > But it is still not working.
> >
> > Can anybody help me out?
> >
> > Thanks in advance.
>
> "It isn't working" is about as useful as telling a mechanic "My car doesn't work" without giving details on what exactly is happening.
>
> What exactly isn't working? What error message are you getting?
>
> The first thing I would check is to make sure the permissions on index.py are set to allow execution. It is easy to forget to do that.
The error message that I am receiving in my browser is:
403: You don't have permission to access /index.py on this server.
The permissions of index.py is 755
[toc] | [prev] | [next] | [standalone]
| From | "Albert Visser" <albert.visser@gmail.com> |
|---|---|
| Date | 2015-09-21 21:28 +0200 |
| Message-ID | <mailman.45.1442863741.28679.python-list@python.org> |
| In reply to | #96955 |
On Mon, 21 Sep 2015 20:41:13 +0200, <tropical.dude.net@gmail.com> wrote:
> Hello everybody,
>
(...)
>
> I created index.py:
> #!/usr/bin/env python
> # -*- coding: UTF-8 -*-# enable debugging
> import cgitb
>
> cgitb.enable()
> print("Content-Type: text/html;charset=utf-8")
> print("Hello World!")
>
> But it is still not working.
>
> Can anybody help me out?
>
> Thanks in advance.
Which Python are you running? If it's Python 3, change the shebang
accordingly because "python" is assuming Python 2.
--
Vriendelijke groeten / Kind regards,
Albert Visser
Using Opera's mail client: http://www.opera.com/mail/
[toc] | [prev] | [next] | [standalone]
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 12:44 -0700 |
| Message-ID | <cd4589f3-7f1d-4f3e-bfe0-dd493929bce0@googlegroups.com> |
| In reply to | #96957 |
On Monday, September 21, 2015 at 9:30:11 PM UTC+2, Albert Visser wrote:
> On Mon, 21 Sep 2015 20:41:13 +0200, <tropical.dude.net@gmail.com> wrote:
>
> > Hello everybody,
> >
> (...)
> >
> > I created index.py:
> > #!/usr/bin/env python
> > # -*- coding: UTF-8 -*-# enable debugging
> > import cgitb
> >
> > cgitb.enable()
> > print("Content-Type: text/html;charset=utf-8")
> > print("Hello World!")
> >
> > But it is still not working.
> >
> > Can anybody help me out?
> >
> > Thanks in advance.
>
> Which Python are you running? If it's Python 3, change the shebang
> accordingly because "python" is assuming Python 2.
>
> --
> Vriendelijke groeten / Kind regards,
>
> Albert Visser
>
> Using Opera's mail client: http://www.opera.com/mail/
I am running python3.4
[toc] | [prev] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2015-09-21 19:41 +0000 |
| Message-ID | <mtpmgq$sfa$1@reader1.panix.com> |
| In reply to | #96955 |
In <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com> tropical.dude.net@gmail.com writes:
> print("Content-Type: text/html;charset=utf-8")
> print("Hello World!")
As I recall, you must have a blank line between the headers and the
content.
But that may or may not be your problem, as you haven't told us exactly
what is going wrong.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [next] | [standalone]
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 12:47 -0700 |
| Message-ID | <e47b58e6-54a7-47d8-8d83-0490c12a3c44@googlegroups.com> |
| In reply to | #96959 |
On Monday, September 21, 2015 at 9:41:29 PM UTC+2, John Gordon wrote:
> In <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com> tropical.dude.net@gmail.com writes:
>
> > print("Content-Type: text/html;charset=utf-8")
> > print("Hello World!")
>
> As I recall, you must have a blank line between the headers and the
> content.
>
> But that may or may not be your problem, as you haven't told us exactly
> what is going wrong.
>
> --
> John Gordon A is for Amy, who fell down the stairs
> gordon@panix.com B is for Basil, assaulted by bears
> -- Edward Gorey, "The Gashlycrumb Tinies"
I am new to Ubuntu, is there a command so I can find out what the problem is?
[toc] | [prev] | [next] | [standalone]
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 12:51 -0700 |
| Message-ID | <65b9162f-45e0-4ad8-82e9-e4813045c1cd@googlegroups.com> |
| In reply to | #96961 |
On Monday, September 21, 2015 at 9:47:33 PM UTC+2, tropical...@gmail.com wrote:
> On Monday, September 21, 2015 at 9:41:29 PM UTC+2, John Gordon wrote:
> > In <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com> tropical.dude.net@gmail.com writes:
> >
> > > print("Content-Type: text/html;charset=utf-8")
> > > print("Hello World!")
> >
> > As I recall, you must have a blank line between the headers and the
> > content.
> >
> > But that may or may not be your problem, as you haven't told us exactly
> > what is going wrong.
> >
> > --
> > John Gordon A is for Amy, who fell down the stairs
> > gordon@panix.com B is for Basil, assaulted by bears
> > -- Edward Gorey, "The Gashlycrumb Tinies"
>
> I am new to Ubuntu, is there a command so I can find out what the problem is?
The only error I can see right now is forbedden, you don't have permission to access /index.py on this server.
[toc] | [prev] | [next] | [standalone]
| From | alister <alister.nospam.ware@ntlworld.com> |
|---|---|
| Date | 2015-09-21 20:29 +0000 |
| Message-ID | <mtppbd$uks$1@speranza.aioe.org> |
| In reply to | #96962 |
On Mon, 21 Sep 2015 12:51:09 -0700, tropical.dude.net wrote:
> On Monday, September 21, 2015 at 9:47:33 PM UTC+2, tropical...@gmail.com
> wrote:
>> On Monday, September 21, 2015 at 9:41:29 PM UTC+2, John Gordon wrote:
>> > In <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com>
>> > tropical.dude.net@gmail.com writes:
>> >
>> > > print("Content-Type: text/html;charset=utf-8")
>> > > print("Hello World!")
>> >
>> > As I recall, you must have a blank line between the headers and the
>> > content.
>> >
>> > But that may or may not be your problem, as you haven't told us
>> > exactly what is going wrong.
>> >
>> > --
>> > John Gordon A is for Amy, who fell down the stairs
>> > gordon@panix.com B is for Basil, assaulted by bears
>> > -- Edward Gorey, "The Gashlycrumb
>> > Tinies"
>>
>> I am new to Ubuntu, is there a command so I can find out what the
>> problem is?
>
> The only error I can see right now is forbedden, you don't have
> permission to access /index.py on this server.
this is not a linux permissions error it is an error with the apache
configuration you need to check roe acache config files
(you may also want to investigate WSGI as CGI is outdated)
--
Perfection is acheived only on the point of collapse.
- C. N. Parkinson
[toc] | [prev] | [next] | [standalone]
| From | tropical.dude.net@gmail.com |
|---|---|
| Date | 2015-09-21 14:36 -0700 |
| Message-ID | <3a7eff56-10de-4382-aad5-1ebb3bcf6c90@googlegroups.com> |
| In reply to | #96963 |
On Monday, September 21, 2015 at 10:29:48 PM UTC+2, alister wrote:
> On Mon, 21 Sep 2015 12:51:09 -0700, tropical.dude.net wrote:
>
> > On Monday, September 21, 2015 at 9:47:33 PM UTC+2, tropical...@gmail.com
> > wrote:
> >> On Monday, September 21, 2015 at 9:41:29 PM UTC+2, John Gordon wrote:
> >> > In <44e870a7-9567-40ba-8a65-d6b52a8c5d25@googlegroups.com>
> >> > tropical.dude.net@gmail.com writes:
> >> >
> >> > > print("Content-Type: text/html;charset=utf-8")
> >> > > print("Hello World!")
> >> >
> >> > As I recall, you must have a blank line between the headers and the
> >> > content.
> >> >
> >> > But that may or may not be your problem, as you haven't told us
> >> > exactly what is going wrong.
> >> >
> >> > --
> >> > John Gordon A is for Amy, who fell down the stairs
> >> > gordon@panix.com B is for Basil, assaulted by bears
> >> > -- Edward Gorey, "The Gashlycrumb
> >> > Tinies"
> >>
> >> I am new to Ubuntu, is there a command so I can find out what the
> >> problem is?
> >
> > The only error I can see right now is forbedden, you don't have
> > permission to access /index.py on this server.
>
> this is not a linux permissions error it is an error with the apache
> configuration you need to check roe acache config files
> (you may also want to investigate WSGI as CGI is outdated)
>
>
>
> --
> Perfection is acheived only on the point of collapse.
> - C. N. Parkinson
Thank you very much. Can I write .py pages like in PHP or should I
use a framework like Django, Web2py or TurboGears?
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-09-22 08:36 +1000 |
| Message-ID | <mailman.47.1442875011.28679.python-list@python.org> |
| In reply to | #96966 |
On Tue, Sep 22, 2015 at 7:36 AM, <tropical.dude.net@gmail.com> wrote: > Thank you very much. Can I write .py pages like in PHP or should I > use a framework like Django, Web2py or TurboGears? I recommend using WSGI and a framework that uses it (my personal preference is Flask, but the above will also work). Here are a couple of simple sites: https://github.com/Rosuav/Flask1 https://github.com/Rosuav/MinstrelHall You can see them in operation here: http://rosuav.com/1/ http://minstrelhall.com/ Note how URLs are defined in the code, rather than by having a bunch of loose files (the way a PHP web site works). This makes it a lot easier to group things logically, and utility lines like redirects become very cheap. The maintenance burden is far lighter with this kind of one-file arrangement. These sites are really tiny, though, so if you have something a bit bigger, you'll probably want to split things into multiple files. Good news! You can do that, too - it's easy enough to split on any boundary you find logical. ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web