Hi, Thank you for your comments. I feel like I'm getting closer to solving this problem with the help.
For the django project and app files (urls.py) I am just using only the first part of https://docs.djangoproject.com/en/2.0/intro/tutorial01/ about setting up a project and app. Mine are just renamed mysite3, and polls3 respectively. I changed DocumentRoot in vhosts below to c:/wamp/www per instructions. The Urls.py files are shown below. I just changed: path('polls/', include('polls.urls')) from the tutorial to be polls3. Since I'm a novice at django and just trying to get the production plumbing, so to speak, setup to work, then the urls.py patterns start to get over my head for how to change those effectively. When I try to make changes from the tutorial ex. and migrate, I get errors. re: urls.py use of urlpattern: url(r'^$', views.post_list, name='post_list'), >python manage.py migrate ... File "c:\wamp\mysite3\polls3\urls.py", line 8, in <module> url(r'^$', views.post_list, name='post_list'), AttributeError: module 'polls3.views' has no attribute 'post_list' ---------- When I enter in the browser: http://mysite3.xxx.xxx.xx.xx.nip.io/admin I see Django administration Username Password Log in ( I have an empty db.sqlite3 in the project but did not do createsuperuser yet) ...but otherwise still seeing 404 error. ex. http://polls3.xxx.xxx.xx.xx.nip.io ================================= //httpd-vhosts.conf------- <VirtualHost *:80> ServerName localhost ServerAlias localhost DocumentRoot c:/wamp/www <Directory "c:/wamp/www/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All #Require local Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerName mysite3.xxx.xxx.xx.xx.nip.io ServerAlias mysite3.xxx.xxx.xx.xx.nip.io DocumentRoot c:/wamp/www WSGIScriptAlias / "C:/wamp/mysite3/mysite3/wsgi.py" <Directory "C:/wamp/mysite3/mysite3/"> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> ===================== //mysite3/mysite3/urls.py from django.contrib import admin from django.urls import include, path urlpatterns = [ path('polls3/', include('polls3.urls')), path('admin/', admin.site.urls), ] -------------------------- //mysite3/polls/urls.py from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), ] -------------------------- //mysite3/polls3/views.py from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse("Hello, world. You're at the polls3 index.") On Tue, Jul 10, 2018 at 11:37 AM, Graham Dumpleton < [email protected]> wrote: > Comments included below. > > On 11 Jul 2018, at 5:20 am, Bob Bobsled <[email protected]> wrote: > > Hi, > Sorry for the detailed info posting below. I tried to follow all > instructions given from above. > > I have changed the django project from the wamp document root > (c:wamp/www/mysite2) to be alongside it (c:/wamp/mysite3), instead, > and reconfigured httpd.conf, and virtual host according to directions > above. > Still getting errors with the .nip.io approach. Not sure how to > continue. > > The goal was to continue to run our non-django wamp sites but also add a > django site using > wamp's apache. > > This works fine without .nip.io approach for django, but buggers all our > non-django sites on port 80. So still trying to get them to > all play nicely together. > > Thank you, > Bob > > > //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" > WSGIPythonPath "C:/wamp/mysite3" > > ================================ > > //httpd-vhosts.conf-------- > > <VirtualHost *:80> > ServerName localhost > ServerAlias localhost > DocumentRoot c:/wamp/www > <Directory "c:/wamp/www/"> > Options +Indexes +Includes +FollowSymLinks +MultiViews > AllowOverride All > #Require local > Require all granted > </Directory> > </VirtualHost> > > <VirtualHost *:80> > ServerName mysite3.xxx.xxx.xx.xx.nip.io > ServerAlias mysite3.xxx.xxx.xx.xx.nip.io > DocumentRoot c:/wamp/mysite3 > > > This is still a problem. You are better off leaving this as: > > DocumentRoot c:/wamp/www > > The application code should not be under any DocumentRoot of any > VirtualHost. > > WSGIScriptAlias / "C:/wamp/mysite3/mysite3/wsgi.py" > <Directory "C:/wamp/mysite3/mysite3/"> > <Files wsgi.py> > Require all granted > </Files> > </Directory> > </VirtualHost> > ================================ > > //settings.py----------- > DEBUG = True > ALLOWED_HOSTS = ["localhost", "xxx.xxx.xx.xx", " > polls3.xxx.xxx.xx.xx.nip.io", "mysite3.xxx.xxx.xx.xx.nip.io"] > > In the browser use URL: http://polls3.xxx.xxx.xx.xx.nip.io > > ERROR: > =============================== > First takes me to the WAMP php config page showing all wamp sites listed. > Then if select > mysite3.xxx.xxx.xx.xx.nip.io, see: > > Page not found (404) > Request Method: GET > Request URL: http://mysite3.xxx.xxx.xx.xx.nip.io/ > Using the URLconf defined in mysite3.urls, Django tried these URL > patterns, in this order: > > polls3/ > admin/ > The empty path didn't match any of these. > > > Which suggests you don't have a URL pattern in your Django setup for > matching the root of the site. > > What does your urls.py file look like? > > An example urls.py would be: > > urlpatterns = [ > url(r'^$', views.post_list, name='post_list'), > url(r'^login/$', auth_views.login, {'template_name': > 'blog/login.html'}, name='login'), > url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'), > url(r'^post/(?P<pk>\d+)/edit/$', views.post_edit, name='post_edit'), > url(r'^post/new/$', views.post_new, name='post_new'), > ] > > Do you have that URL pattern for '^$'? > > What happens in you access: > > http://mysite3.xxx.xxx.xx.xx.nip.io/admin > > Graham > > You're seeing this error because you have DEBUG = True in your Django > settings file. Change that to False, and Django will display a standard 404 > page. > ================================ > ================================ > > > //settings.py----------- > DEBUG = False > ALLOWED_HOSTS = ["localhost", "xxx.xxx.xx.xx", " > polls3.xxx.xxx.xx.xx.nip.io", "mysite3.xxx.xxx.xx.xx.nip.io"] > > > In the browser use URL: http://polls3.xxx.xxx.xx.xx.nip.io > ERROR: > ================================ > First takes me to the WAMP php config page showing all wamp sites listed. > Then if select > mysite3.xxx.xxx.xx.xx.nip.io, see: > > Not Found > The requested URL / was not found on this server. > > > On Mon, Jul 9, 2018 at 3:24 PM, Graham Dumpleton < > [email protected]> wrote: > >> >> >> On 10 Jul 2018, at 10:40 am, Bob Bobsled <[email protected]> wrote: >> >> Hi, >> That's an interesting approach. >> >> I tried with the django project in c:/wamp/www/mysite2, and the placed >> the polls2 app inside the mysite2. >> >> I'm still getting the 404 error when trying >> httpd://polls2.xxx.xxx.xx.xx.nip.io >> >> >> Can't help unless can see whether the 404 is from Apache or Django. >> >> Have you tried setting DEBUG=True in Django settings temporarily to see >> if it is getting through to Django. >> >> It initially asked me to add the url to settings.py, but still no joy. >> >> Not sure what I might be doing wrong. Any help appreciated. >> >> Regards, >> Bob >> >> >> //httpd.conf----------------- >> >> LoadFile "c:/users/administrator/appdata/local/programs/python/python >> 36-32/python36.dll" >> LoadModule wsgi_module "c:/users/administrator/appdat >> a/local/programs/python/python36-32/lib/site-packages/mod_ >> wsgi/server/mod_wsgi.cp36-win32.pyd" >> >> WSGIPythonHome "c:/users/administrator/appdat >> a/local/programs/python/python36-32" >> >> WSGIScriptAlias / C:/wamp/www/mysite2/mysite2/wsgi.py >> WSGIPythonPath C:/wamp/www/mysite2 >> <Directory "C:/wamp/www/mysite2/mysite2/"> >> <Files wsgi.py> >> Order deny,allow >> >> >> You don't need this Order directive in Apache 2.4, only Require all >> granted. >> >> Require all granted >> </Files> >> </Directory> >> >> >> The WSGIScriptAlias and Directory block would usually be inside of the >> VirtualHost where for the application. >> >> //httpd-vhosts.conf---------------------------------- >> >> <VirtualHost *:80> >> ServerName localhost >> ServerAlias localhost >> DocumentRoot c:/wamp/www >> <Directory "c:/wamp/www/"> >> Options +Indexes +Includes +FollowSymLinks +MultiViews >> AllowOverride All >> #Require local >> Require all granted >> </Directory> >> </VirtualHost> >> >> <VirtualHost *:80> >> ServerName polls2.xxx.xxx.xx.xx.nip.io >> ServerAlias polls2.xxx.xxx.xx.xx.nip.io >> DocumentRoot c:/wamp/www >> >> >> You should not put your Django code under the DocumentRoot directory. >> >> <Directory "C:/wamp/www/mysite2/"> >> Options +Indexes +Includes +FollowSymLinks +MultiViews >> AllowOverride All >> Require all granted >> </Directory> >> >> >> Replace this Directory blog with WSGIScriptAlias and Directory blog you >> had above. >> >> </VirtualHost> >> >> On Sun, Jul 8, 2018 at 2:51 PM, Graham Dumpleton < >> [email protected]> wrote: >> >>> When using VirtualHost, and hosting multiple sites all on the same port, >>> you need to access the site through a proper hostname, not an IP address or >>> localhost. When you use localhost or an IP address it will always be >>> handled by the first VirtualHost as there is no hostname it can match >>> against for the VirtualHost ServerName directive. Using localhost or an IP >>> for ServerName doesn't do anything. >>> >>> The easiest thing to do if you don't have a unique hostname to use, is >>> set up up your separate VirtualHost for your Django application and add it >>> last in the file. When adding, specify ServerName inside of that >>> VirtualHost as: >>> >>> ServerName django.A.B.C.D.nip.io <http://django.a.b.c.d.nip.io/> >>> >>> where A.B.C.D is the IP address of the host. >>> >>> You can then access the web site as: >>> >>> http://django.A.B.C.D.nip.io <http://django.a.b.c.d.nip.io/> >>> >>> The 'nip.io' is a special domain name that implements a DNS which will >>> return the IP A.B.C.D for the hostname in that form. So the request will go >>> to your Apache and because you used hostname 'django.A.B.C.D.nip.io >>> <http://django.a.b.c.d.nip.io/>' in the URL, Apache can match that >>> properly against ServerName for that VirtualHost and direct your request to >>> the Django setup within that VirtualHost. >>> >>> Graham >>> >>> >>> On 9 Jul 2018, at 10:42 am, [email protected] wrote: >>> >>> Hi, >>> >>> >>> I'm a novice and slowly working thru a production server problem. >>> >>> >>> Trying to get django and mod_wsgi to play nicely with existing wamp >>> sites on Win7 on a production server. Directions from django users group >>> (google) seems to indicate I can do this by changing default port for >>> mod_wsgi from 80 to something else which doesn't conflict with the existing >>> non-django sites on wamp. >>> >>> >>> I do not have a virtualenv setup at the moment, and am not using deamon >>> mode. I'm basically just testing the plumbing, so to speak, to try to get >>> this working first. >>> >>> >>> I have several configurations of django project/app described below but >>> I'd really prefer to keep it in c:/wamp/www along with all our other sites, >>> but have the django site use a different port so everything will run >>> without 404 error. >>> >>> >>> Since I'm a novice at setting up django and mod_wsgi, I could use some >>> help and direction with perhaps the virtual hosts conf file, if that's the >>> way to go. >>> >>> How would I go about changing the mod_wsgi port from 80 to say :9090 for >>> ex. for a django site in c:/wamp/www/mysite, for ex.? >>> >>> >>> >>> >>> Wampserver 3.0.6 32bit, with apache2.4.23 >>> >>> --------------- >>> >>> PYTHON AND APACHE: >>> >>> >>> Python 3.6.5 32bit, with Django 2.0.6 >>> >>> >>> --------------- >>> >>> 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\Downloa >>> ds\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/python3 >>> 6-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. >>> >>> ---------------- >>> >>> We have several small non-django websites running on wamp. >>> >>> Those projects are in c:/wamp/www/myproject for ex. and are accessed as >>> localhost/myproject or myipxxx/myproject. >>> >>> >>> Under wamp I have tried putting the django project in c:/wamp/apps, in >>> c:/wamp/www, and just in c:/wamp too. They all work fine with apache and >>> mod_wsgi. >>> >>> >>> At least I get a sample "helloworld" message in the webpage when I >>> access the django site as localhost/mydjangosite or myipxxx/mydjangosite. >>> This is basically the simple tut01 or polls app kindof django project. >>> >>> >>> But the django project, wherever I put it in wamp, buggers our other >>> non-django websites. I get a message back from urls.py saying it's been >>> thru all the urls listed and it cannot access our regular (non django >>> sites) in c:/wamp/www when I try to access one as localhost/myproject or >>> myipxxx/myproject from the browser. >>> >>> ----------------- >>> >>> I believe the apache virtual host file is this right now. Sorry doing >>> this a bit patchwork. >>> >>> >>> >>> <VirtualHost *:80> >>> >>> ServerName localhost >>> >>> ServerAlias localhost >>> >>> DocumentRoot c:/wamp/www >>> >>> <Directory "c:/wamp/www/"> >>> >>> Options +Indexes +Includes +FollowSymLinks +MultiViews >>> >>> AllowOverride All >>> >>> #Require local >>> >>> Require all granted >>> >>> </Directory> >>> >>> </VirtualHost> >>> >>> >>> <VirtualHost *:80> >>> >>> Alias /static c:/wamp/www-src/static >>> >>> <Directory c:/wamp/www-src/static> >>> >>> Require all granted >>> >>> </Directory> >>> >>> </VirtualHost> >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/modwsgi. >>> For more options, visit https://groups.google.com/d/optout. >>> >>> >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/modwsgi. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/modwsgi. >> For more options, visit https://groups.google.com/d/optout. >> >> >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/modwsgi. >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. > > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/modwsgi. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
