Hello everyone,
I have set up a Wordpress 1-click app on a Ubuntu droplet (16.04). I have installed a simple Django project (works on http://localhost:8000) and configured it with VirtualHost to reach it a http://localhost/backend. It does not work : on this url I got a 404 error page from Wordpress.
I would like to know if it possible first ? (from that post it seems possible https://www.digitalocean.com/community/questions/django-and-wordpress-on-wp-one-click-installation-ubuntu, but is it on the same url ?)
Here are the steps I have already done:
You can find here my django virtual host config file.
<VirtualHost *:80>
WSGIDaemonProcess django_backend \
python-path=/home/samuel/django_backend:/home/samuel/.virtualenvs/django_backend/lib/python2.7/site-packages
WSGIProcessGroup django_backend
Alias /static/ /home/samuel/django_backend/collected_static/
<Directory /home/samuel/django_backend/collected_static>
Require all granted
</Directory>
WSGIScriptAlias /backend /home/samuel/django_backend/django_backend/wsgi.py
<Directory /home/samuel/django_backend/django_backend>
Order allow,deny
Allow from all
</Directory>
<Directory /home/samuel/django_backend/django_backend>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
# ServerName
ServerAdmin webmaster@localhost
# DocumentRoot /home/samuel/django_backend/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/python-django_error.log
CustomLog ${APACHE_LOG_DIR}/python-django_access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
Thank you in advance ! Samuel
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
@samuelgirardin
If Django is running on Port 8000, 8080, or another port, you won’t be able to access it on Port 80 without setting up Apache as a reverse proxy.
As a reverse proxy, what happens is a request comes in on Port 80 and internally, Apache will serve
http://localhost:8000
. Without setting up a reverse proxy, you’d be limited to attaching the port to the end of each request.You can check the guide below for details on how to use Apache as a Reverse Proxy, which should help you configure your VirtualHost for the Django app.
https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04