django windows apache tell if apache is working

2018-06-29 Thread thebobbobsled

Hi,

I'm new to this group, and also new to Python, and Django.  Seems like lots 
of good info for django on this group.

Sorry for long, detailed descriptions, below, but I am stuck trying to 
verify wamp, apache and django are working as a production server on a 
Windows 7, 32-bit machine.

I am hung on last mile part (way below), or how to see something in the 
browser using apache, not the dev runserver.  The dev server seems to work 
fine at this point showing default django startup page.

I'm not sure how to proceed with verifying apache is working as a 
production server.  If all is working, should apache show the same Python 
default start page as the dev server?  Or what simple web pages should I 
implement to verify the apache connection is actually working on the server?

Wamp is also working fine with it's own www directory and local webpages 
etc. using apache.


Wampserver 3.0.6 32bit, with apache2.4.23
---
PYTHON AND APACHE:

Python 3.6.5 32bit, with Django 2.0.6

Tried following Eastwood description for Django setup for Wamp
https://ericeastwood.com/blog/3/django-setup-for-wamp
---
MOD_WSGI:

Could not pip install mod_wsgi, and needed to download VisualStudio build 
tools and upgrade framework to 4.7.1.

Downloaded mod_wsgi-4.5.24+ap24vc14-cp36-cp36m-win32.whl
https://www.lfd.uci.edu/~gohlke/pythonlibs/
to work with apache 2.4.23, VC++14, and python3.6

then did >> pip install 
C:\Users\Administrator\Downloads\mod_wsgi-4.5.24+ap24vc14-cp36-cp36m-win32.whl. 
 
Did not get mod_wsgi.so in apache modules folder, but did get a .pyd in: 
c:/users/administrator/appdata/local/programs/python/python36-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win32.pyd

Could then run mod_wsgi-express.

>From cmd prompt in apache bin dir used >httpd -t -D DUMP_MODULES to show 
wsgi_module (shared) is present.
---
VIRTUALENV:

Per Eastwood description (above), inside c:/wamp created a new directory 
www-src next to www which is where our other wamp sites are located. Inside 
c:\wamp\www-src ran >virtualenv django_project, then 
django_project\Scripts\activate.  See (django_project) as prefix to cmd 
prompt. With virtual environment active did >pip install django.  Then 
(django_project_ c:\wamp\www-src > django-admin.py startproject 
django_project .  to setup up project in current or www-src directory.

c:\wamp\www-src\django_project
c:\wamp\www-src\static
c:\wamp\www-src\db.sqlite3
c:\wamp\www-src\manage.py

and in c:\wamp\www-src\django_project have settings.py, urls.py, and 
wsgi.py, etc.
---
SETTINGS.PY

in settings.py change STATIC_URL to:

STATIC_ROOT = 'C:/wamp/www-src/static'
STATIC_URL = 'http://XXXmyipXXX/static/'


also added localhost, and my local IP to ALLOWED_HOSTS in settings.py
---
MIGRATIONS:

then from c:\wamp\www-src run
(django_project) c:\wamp\www-src >manage.py makemigrations
then
(django_project) c:\wamp\www-src >manage.py migrate

also ran >(django_project) c:\wamp\www-src >manage.py collectstatic
although static dir is empty at this point.
---
DEVELOPMENT SERVER:

(django_project) c:\wamp\www-src >manage.py runserver 0.0.0.0:8000

>From the browser > http://localhost:8000 this initially caused windows 
firewall error to appear but an exception was added to allow it to continue.

Can see python default page, and also localhost:8000\admin too on Dev 
server.  Dev server can be seen by other machines on the network too.

CONFIGURE APACHE:
for production server using wamp instead of dev server.

using mod_wsgi-express settings in httpd.conf.
Apache httpd.conf is in:
C:\wamp\bin\apache\apache2.4.23\conf\httpd.conf

Apache httpd-vhosts.conf is in:
C:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf

added to httpd.conf:
LoadFile 
"c:/users/administrator/appdata/local/programs/python/python36-32/python36.dll"
LoadModule wsgi_module 
"c:/users/administrator/appdata/local/programs/python/python36-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win32.pyd"

WSGIPythonHome 
"c:/users/administrator/appdata/local/programs/python/python36-32"
WSGIScriptAlias /django-project 
"C:/wamp/www-src/django_project/wsgi.py:C:/wamp/www-src/django_project/wsgi_app.py"
WSGIPythonPath 
"C:/wamp/www-src/django_project/:C:/wamp/www-src/django_project/Lib/site-packages"



Order deny,allow
Require all granted


Order deny,allow
Require all granted




added to httpd-vhosts.conf:

Alias /static c:/wamp/www-src/static

Require all granted



...restarted apache


CONFUSED FROM HERE...or last mile to verify production server can run 
django from virtual environment.

If try localhost:8000 in browser see ERR_CONNECTION_REFUSED.
If try localhost/wsgi and have wsgi_app.py in django_project, see requested 
URL not found.

wsgi_app.py

def application(environ, start_response):
status = '200 OK'
output = 'Hello World from djang

Re: django windows apache tell if apache is working

2018-06-30 Thread Jason
appreciate the detailed report :-)

so, have you set up the django tutorial project?  that application method 
in wsgi doesn't make any sense.  you should have urls and views set up in 
your project

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django windows apache tell if apache is working

2018-06-30 Thread Bob Bobsled
Hi,
Thanks.
Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
the point where I realized I needed to do more with the last mile, so to
speak working on setup of the production server part on Windows and wamp.
Seems most tuts end at manage.py runserver, or start into deployment from
dev to production.  I can't seem to locate a good uptodate tut for wamp
that shows how to test everything is working properly in a simple manner
for the wsgi part.

I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py) is
working with apache, before spending too much more time building a site.

On Sat, Jun 30, 2018 at 2:54 AM, Jason  wrote:

> appreciate the detailed report :-)
>
> so, have you set up the django tutorial project?  that application method
> in wsgi doesn't make any sense.  you should have urls and views set up in
> your project
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/-eJaLuJ85KE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALWZDaPoCygU8hSSYcsEpQnHGE%2B52EUxAyOko3kPRhR12t6HCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django windows apache tell if apache is working

2018-06-30 Thread Jason
I meant the tutorial at 
https://docs.djangoproject.com/en/2.0/intro/tutorial01/

That said, there's a few different ways you can actually deploy, but 
digitalocean has some good resources for starting out.

https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04

This one shows how to use apache on ubuntu, and you should be able to 
extrapolate to use wamp.

what I would do is just set up a simple view to return a http response 
saying "working", and map that to the root.  Something like 

app/views

def index(request):
return HttpResponse("Working!")

app/urls

from app.views import index
urlpatterns = [
path('', index), 
]

and hit localhost.  That'll be all you need.

Hi,
> Thanks.
> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to 
> the point where I realized I needed to do more with the last mile, so to 
> speak working on setup of the production server part on Windows and wamp.
> Seems most tuts end at manage.py runserver, or start into deployment from 
> dev to production.  I can't seem to locate a good uptodate tut for wamp 
> that shows how to test everything is working properly in a simple manner 
> for the wsgi part.
>
> I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py) 
> is working with apache, before spending too much more time building a site. 
>  
>
> On Sat, Jun 30, 2018 at 2:54 AM, Jason > 
> wrote:
>
>> appreciate the detailed report :-)
>>
>> so, have you set up the django tutorial project?  that application method 
>> in wsgi doesn't make any sense.  you should have urls and views set up in 
>> your project
>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/django-users/-eJaLuJ85KE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f5e5996-a85e-4eb6-b5e4-804f7379a2b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django windows apache tell if apache is working

2018-07-02 Thread Bob Bobsled
Hi,
I'm still stuck on getting Apache to verify as working with wsgi.
Wondering what I might be doing incorrectly.
I'm reading lots of tuts, but it's a jungle out there.

I changed the folder hierarchy for the project and app so
venv, django_project, and  django_app are all on the same level as manage.py
thus:
c:/wamp/www-src/django_project
c:/wamp/www-src/django_app
c:/wamp/www-src/venev
c:/wamp/www-src/manage.py

In wamp create folder named www-src alongside the www folder.
cd into www-src.

created a virtual environment:
Inside www-src run > virtualenv venv

ACTIVATE and DEACTIVATE:

then activate by
> venv\Scripts\activate

if that works see (venv) as a prefix to the command line.  To deactivate
type:
>venv\Scripts\deactivate.bat.
...or can also just use
(venv) c:\wamp\www-src >deactivate
-

DJANGO PROJECT, APP, and VENV:
Then with the virtual environment active, install Django with the local
instance of pip by typing: >pip install django

then created a new django project >python django-admin.py startproject
django_project

and on the same level as manage.py type
>django-admin.py startapp django_app

Should have django_app folder, django_project folder, venv folder, and
manage.py all on the same level.

SETUP SQLITE DATABASE:

in the top level folder (the one with manage.py in it), type this in:
> python manage.py migrate


START RUNSERVER:
> python manage.py runserver

see success...so far.
-
Trying to get Apache production server working...

SETUP STATIC files location:

in settings.py

SETTINGS.PY:

in settings.py change STATIC_URL to:

STATIC_URL = os.path.join(BASE_DIR, "static/")

...also set
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

then run
>(venv) c:\wamp\www-src>manage.py collectstatic

(should see new static dir under www-src)
---

MIGRATIONS:

then from c:\wamp\www-src run
(venv) c:\wamp\www-src >manage.py makemigrations
then
(venv) c:\wamp\www-src >manage.py migrate

SETTINGS.PY

in settings.py change STATIC_URL to:

STATIC_URL = os.path.join(BASE_DIR, "static/")

...also set
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

then run
>(venv) c:\wamp\www-src>manage.py collectstatic

(should see new static dir under www-src)
--
...per Jason's suggestion for simple view and url...

in DJANGO_APP/VIEWS.PY

def index(request):
return HttpResponse("Working!")

--
in DJANGO_APP/URLS.PY

from django_app.views import index
urlpatterns = [
path('', index),
]

-
APACHE HTTPD.CONF

#---mod_wgi-express config for location in python ---
LoadFile
"c:/users/administrator/appdata/local/programs/python/python36-32/python36.dll"
LoadModule wsgi_module
"c:/users/administrator/appdata/local/programs/python/python36-32/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win32.pyd"

WSGIPythonHome
"c:/users/administrator/appdata/local/programs/python/python36-32"
WSGIScriptAlias /django-project "C:/wamp/www-src/django_project/wsgi.py"
#WSGIPythonPath
"C:/wamp/www-src/django_project/:C:/wamp/www-src/venv/Lib/site-packages"
WSGIPythonPath "C:/wamp/www-src:C:/wamp/www-src/venv/Lib/site-packages"



Order deny,allow
Require all granted




APACHE HTTPD-VHOSTS.CONF


ServerName localhost
ServerAlias localhost
DocumentRoot c:/wamp/www

Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
#Require local
Require all granted




Alias /static c:/wamp/www-src/static

Require all granted



---

restart APACHE

...but what is the correct URL to test here?

tried localhost:8000 all pointing to various folders but nothing connects
so far.



On Sat, Jun 30, 2018 at 10:08 AM, Jason  wrote:

> I meant the tutorial at https://docs.djangoproject.
> com/en/2.0/intro/tutorial01/
>
> That said, there's a few different ways you can actually deploy, but
> digitalocean has some good resources for starting out.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
>
> This one shows how to use apache on ubuntu, and you should be able to
> extrapolate to use wamp.
>
> what I would do is just set up a simple view to return a http response
> saying "working", and map that to the root.  Something like
>
> app/views
>
> def index(request):
> return HttpResponse("Working!")
>
> app/urls
>
> from app.views import index
> urlpatterns = [
> path('', index),
> ]
>
> and hit localhost.  That'll be all you need.
>
> Hi,
>> Thanks.
>> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
>> the point where I realized I needed to do more with the last mile, so to
>> speak working on setup of the production server part on Windows and wamp.
>> Seems most tuts end at manage.py runserver, or start into deployment from
>> dev to production.  I can't seem to locate a good uptodate tut for

Re: django windows apache tell if apache is working

2018-07-03 Thread Bob Bobsled
Hi,
I think I see the problem now.

WAMP is a special case for aliases, and it's root directory default setup
in c:wamp\www for ex..  I need to do some more work on, say for ex. using
Django Tut 01, setting up mysite as an alias in wamp, and then putting the
polls app in it.  I believe apache might start to work then with django if
the wamp alias is setup correctly.

I also found this vid tut:  really good, but for XAMPP, not WAMP...but it
shows how to get the mod_wsgi.so from a renamed and extracted .whl file.
And using the mod_wsgi.so with apache simplifies things a bit, so this is
good too.

XAMPP
This shows how to create a mod_wsgi.so from the .pyd extracted from the
.whl file
https://www.youtube.com/watch?v=VnR5O4IjmOs

Regards


On Sat, Jun 30, 2018 at 10:08 AM, Jason  wrote:

> I meant the tutorial at https://docs.djangoproject.
> com/en/2.0/intro/tutorial01/
>
> That said, there's a few different ways you can actually deploy, but
> digitalocean has some good resources for starting out.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04
>
> This one shows how to use apache on ubuntu, and you should be able to
> extrapolate to use wamp.
>
> what I would do is just set up a simple view to return a http response
> saying "working", and map that to the root.  Something like
>
> app/views
>
> def index(request):
> return HttpResponse("Working!")
>
> app/urls
>
> from app.views import index
> urlpatterns = [
> path('', index),
> ]
>
> and hit localhost.  That'll be all you need.
>
> Hi,
>> Thanks.
>> Yes, I went thru the Mozilla library tutorial on a fedora dev machine to
>> the point where I realized I needed to do more with the last mile, so to
>> speak working on setup of the production server part on Windows and wamp.
>> Seems most tuts end at manage.py runserver, or start into deployment from
>> dev to production.  I can't seem to locate a good uptodate tut for wamp
>> that shows how to test everything is working properly in a simple manner
>> for the wsgi part.
>>
>> I'm just trying to verify the plumbing (httpd.conf, settings.py wsgi.py)
>> is working with apache, before spending too much more time building a site.
>>
>>
>> On Sat, Jun 30, 2018 at 2:54 AM, Jason  wrote:
>>
>>> appreciate the detailed report :-)
>>>
>>> so, have you set up the django tutorial project?  that application
>>> method in wsgi doesn't make any sense.  you should have urls and views set
>>> up in your project
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/django-users/-eJaLuJ85KE/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/6d241c04-55be-4524-959e-09630a7bc21f%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/-eJaLuJ85KE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/6f5e5996-a85e-4eb6-b5e4-804f7379a2b4%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALWZDaNY4miqCqxy%3DLvH4417%3DP4XGOuHAOepCBT2tPpg0wqkrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.