1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Issue configuring apache2

Discussion in 'Apache' started by metaing, Jul 20, 2016.

  1. #1
    Hello everyone!
    I deployed 2 applications on an EC2 instance: 1) A Python application developed with Django 2) A web site

    First I deployed my Python application and it worked correctly, as I could invoke a REST API with a GET on <ip>/rest/combo and I could also access static resources. Then I deployed my website both were working correctly, as I could access my website at the IP and at the same time I could invoke my REST API as before, as well as I could access static resources. Last step was to set the DNS records on GoDaddy to let my domain name point to my website. After this was done, an I am finding an issue on my Python application: REST APIs gives me a 404 error both on <ip>/rest/combo and <domain-name>/rest/combo, while static resources keep being served.

    I created two configuration files in /etc/apache2/conf-enabled:

    1) For Python:

    WSGIScriptAlias / /home/ubuntu/MyPythonApplication/MyPythonApplication/wsgi.py
    WSGIPythonPath /home/ubuntu/MyPythonApplication
    <Directory /home/ubuntu/MyPythonApplication/MyPythonApplication>
    <Files wsgi.py>
    Order deny,allow
    Require all granted
    </Files>
    </Directory>

    Alias /media/ /home/ubuntu/MyPythonApplication/media/
    Alias /static/ /home/ubuntu/MyPythonApplication/static/

    <Directory /home/ubuntu/MyPythonApplication/static>
    Require all granted
    </Directory>

    <Directory /home/ubuntu/MyPythonApplication/media>
    Require all granted
    </Directory>​

    One for my website:

    Alias / /home/ubuntu/MyWebsite/

    <Directory /home/ubuntu/MyWebsite>
    Require all granted
    </Directory>​

    I understand that the issue is on the Alias as both configuration files refer / (if I change it on my website configuration file, rest APIs work again).

    I don't have an domain name for the rest APIs. How can I fix this?
     
    metaing, Jul 20, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Why do you need the / alias? I'm just wondering, since I've never used it. The default root (/) is the directory defined in the <Directory>part, isn't it?
     
    PoPSiCLe, Jul 22, 2016 IP
  3. metaing

    metaing Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #3
    Actually, I am not sure I need all that piece of configuration. This is my first Django deploy experience, so when it worked I just stopped changing things.
    So, maybe I just don't need the alias?
     
    metaing, Jul 25, 2016 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    I don't think you do. This isn't Django-related, though, this is Apache related. Django shouldn't bother with these specifics at all.
     
    PoPSiCLe, Jul 28, 2016 IP