1

After help, I have come to a proj.conf of this:

<VirtualHost *:80>
    WSGIScriptAlias /f_app /home/4rsenal/f_proj/f_proj/wsgi.py

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustumLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static/ /home/4rsenal/f_proj/static
    <Directory /home/4rsenal/f_proj/static>
            Require all granted
    </Directory>

    <Directory /home/4rsenal/f_proj/f_proj>
            <Files wsgi.py>
                    Requier all granted
            </Files>
    </Directory>
    WSGIProcessGroup f_proj
    WSGIDaemonProcess f_proj python-home=/home/4rsenal/f_proj/f_projenv python-path=/home/4rsenal/f_proj   
</VirtualHost>

<VirtualHost *:80>
    WSGIScriptAlias /m_app /home/4rsenal/m_proj/m_proj/wsgi.py

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustumLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static/ /home/4rsenal/m_proj/static
    <Directory /home/4rsenal/m_proj/static>
            Require all granted
    </Directory>

    <Directory /home/4rsenal/m_proj/m_proj>
            <Files wsgi.py>
                    Requier all granted
            </Files>
    </Directory>
    WSGIProcessGroup m_proj
    WSGIDaemonProcess m_proj python-home=/home/4rsenal/m_proj/m_projenv python-path=/home/4rsenal/m_proj
</VirtualHost>

With the new alias', if I type in http://[MYIPADDRESS]/f_app/f_app/ I'm good to go with that site, but if I type in http://[MYIPADDRESS]/m_app/m_app/ I get a Not Found error. Why does one alias work but not the other? (I can fix the stupid looking urls later once I get these to both work).

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
4rsenal
  • 41
  • 8
  • You are aliasing both of them to the root. Where do the `/f_app` and `/m_app` components of the URL come from? By the way, you have a typo in `Require all granted`. – Paulo Almeida Aug 16 '17 at 18:45
  • @Paulo Almeida Within my django project. My f_proj/urls.py includes the urls from f_proj/f_app/urls.py. Fixed type (wasn't in actual conf file) – 4rsenal Aug 16 '17 at 18:48
  • Ok, but you'll have to change the way you do that. If you have different `WSGIScriptAlias`es pointing to the same place, the first one will match and the second one will never be seen. – Paulo Almeida Aug 16 '17 at 18:51
  • You can see that in the links you posted. In the first one they have different aliases, in the second they are on different ports and in the third they specifically talk about that problem, under Ordering of WSGIScriptAlias directives. – Paulo Almeida Aug 16 '17 at 18:59
  • Makes sense, the only thing is that if I change the WSGIScriptAlias' to different things (lets say fproj and mproj) what else would have to change? Asking because it seems that if I just changed the blank / alias to /mproj they are now pointing to different things and that should work? I tried and it does not. – 4rsenal Aug 16 '17 at 19:00
  • Not much, you'd just have to adjust your `urls.py` to make sure you don't end up with two different levels of `/f_app`. If you play a bit with it with `DEBUG = True` I think it'll be fairly easy. – Paulo Almeida Aug 16 '17 at 19:06
  • Well, you picked the wrong one :) If you have a sub-URL it must come before, otherwise the `/` will still match first. – Paulo Almeida Aug 16 '17 at 19:16
  • Very confused haha. Will update the question to my new concerns – 4rsenal Aug 16 '17 at 19:23
  • Hard to say with the available information. I'd check the Apache logs and double check that there are no typos anywhere in the configuration files, although it shouldn't be something like permissions, since you said the sites were both running before, alternately. – Paulo Almeida Aug 16 '17 at 20:07
  • I figured it out. In seperate conf files I have one running on port 8080 and the other not. I changed the WSGIScriptAlias to / for both and all is fine. (I could have sworn I tried this already) Thanks for help I definitely appreciate it. WIll delete this post in the next few mins – 4rsenal Aug 16 '17 at 20:28
  • No problem, glad you got it working. – Paulo Almeida Aug 16 '17 at 20:29

1 Answers1

2

The basis of the problem if your configuration was accurate was that you had two VirtualHost definitions but neither had a ServerName. This meant name based host name matching couldn't be applied and so it would always use the first VirtualHost.

If you had intended them to be both under the same host name, the configuration should all be in the one VirtualHost.

This sort of problem along with others related to running multiple Django applications at the same time are explained in the blog post:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • Good point, I hadn't thought about the problem with two VirtualHosts. The question was edited, the first version actually included the link to that blog post. – Paulo Almeida Aug 16 '17 at 21:15