I have installed a django application with django-tinymce and django-filebrowser. In my machine every thing works fine. when I deployed the application to the production, filebrowser fails to upload file and it shows me the error message Failed
Here is my settings
MEDIA_ROOT = '/srv/www/staticFiles/APCC/'
MEDIA_URL = '/static/APCC/'
STATIC_ROOT = '/srv/www/staticFiles'
STATIC_URL = '/static/'
and here is my apache configs
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE APCC.settings
PythonDebug Off
PythonOption django.root /srv/APCC
PythonPath "['/srv/APCC/'] + sys.path"
</Location>
Alias "/static/" "/srv/www/staticFiles/"
<Location "/static">
SetHandler None
Order deny,allow
Allow from all
</Location>
</VirtualHost>
I have make sure that the MEDIA_ROOT directory is created and the uploads folder required by the filebrowser is also created under it.
Also the MEDIA_ROOT directory and the uploads directories have write permissions.
I believe the problem is in my apache configuration or file structure. where would be the problem? also is there any logs specific for tinycme or filebrowser to check?
Related
I am having a problem with deployment of Django application using AWS Lightsail referring to this video.
The static file is not being loaded.
The static url and directory in my settings.py are as mentioned below:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
The static folder is in the base directory named as /static/.
and the httpd-app.conf file in the conf folder has:
Alias /static/ "/opt/bitnami/apps/django/django_projects/Project/static"
<Directory opt/bitnami/apps/django/django_projects/Project/static>
Require all granted</Directory>
Alias /media/ "/opt/bitnami/apps/django/django_projects/Project/media"
<Directory opt/bitnami/apps/django/django_projects/Project/media>
Require all granted
</Directory>
I have run python3 manage.py collectstatic command and the static files are loaded in static directory but the site does not load it.
my deployed Django project can't access the static files, I get 403 for all of them when inspecting in Chrome.
I added the following to my 000-default.conf where I also have the WSGIScriptAlias etc.:
Alias /static/ /home/budget/static/deploy/
<Directory /home/budget/static/deploy>
Required all granted
</Directory/
The static files exist in the budget/static/deploy folder. Should this not give the required permissions? What do I have to change to get rid of the 403?
It is running on Ubuntu 16.04.
Edit:
settings.py:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
#os.path.join(BASE_DIR, 'budget/static'),
os.path.join(BASE_DIR, "static"),
)
STATIC_ROOT = os.path.join(BASE_DIR, "static/deploy/")
There may be a couple of different things that cause your configuration not to work. First of all, I would make sure that you are indeed modifying the proper Apache configuration file. You can run this command to check this:
/usr/sbin/apachectl -V | grep SERVER_CONFIG_FILE | awk '{split($0,a,"="); print a[2]}' | sed s/\"//g
Then, to delegate other API requests to django through WSGI, you should also give the correct permissions to your wsgi file (maybe this is not absolutely required for mere static serving to work):
<Directory /path/to/django/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Next, set the process information to be used by Apache as well as your binding url for your project.
WSGIDaemonProcess myproject python-path=/path/to/django/project python-home=/path/to/your/venv
WSGIProcessGroup mydjangoproject
WSGIScriptAlias /binding/url /path/to/django/project/project/wsgi.py
Lastly, you may need to set up some permissions to allow www-data to read your media and static files and you should be all set. Don't forget to restart Apache to apply the modifications.
I've been a django developer for years now, yet a small practice project with 1.7 is giving me a great headache when it comes to serving static files.
I've set STATIC_ROOT
STATIC_ROOT = '/var/www/mydomain/static'
I've set STATIC_URL
STATIC_URL = '/static/' #as default
I'm not using STATICFILES_DIRS since I have one app called 'pages' and it's in INSTALLED_APPS. On localhost the static files are served correctly
I'm using Ubuntu 14.4 and Apache/2.4.7
My apache conf is
<VirtualHost *:80>
ServerName mydomain.net #I own the domain and pointed it correctly in GoDaddy
ServerAlias www.mydomain.net
Alias /static/ /var/www/mydomain/static
<Directory /var/www/mydomain/static>
Require all granted
</Directory>
WSGIScriptAlias / /var/www/mydomain/mydomain/wsgi.py
<Directory /var/www/mydomain/mydomain>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess mydomain.net python-path=/var/www/mydomain:/var/www/mydomain/venv/lib/python2.7/site-packages
WSGIProcessGroup mydomain.net
</VirtualHost>
I've run collectstatic and confirmed all static files are in /var/www/mydomain/static/*.
The site loads, but I get a 404 on all css and js files.
All debugging efforts have failed. I've removed the STATIC_ROOT dir to expect a 403, but still getting a 404. I've chown'd all files/folder to root for testing; nothing. I created a deploy user and chown'd all files/folders to it; nothing. I've chown'd all files/folders to www-data; nothing!!
Is there a new config in Apache 2.4+ that's throwing me off?
What you can do is check your /var/www/mydomain path and look for the folder. I think its not there yet. If not then copy your folder to this place so that apache can serve it.
That will be worth looking
(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
As you can see, I have a directory called "media" under my Django project.
I would like to delete this line in my urls.py and instead us Apache to serve my static files. What do I do to my Apache configs (which files do I change) in order to do this?
By the way, I installed Apache2 like normal:
sudo aptitude install apache2
I would read Django's official static files docs and apache mod_python documentation.
This example sets up Django at the
site root but explicitly disables
Django for the media subdirectory and
any URL that ends with .jpg, .gif or
.png:
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
</Location>
<Location "/media">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png)$">
SetHandler None
</LocationMatch>
I'm a complete newbie to Django. I've been trying to get it working on my Ubuntu server.
everytime someone my server, it redirects to the "Congratulations on your first Django-powered page." It completely ignores the index.html file in the www directory. Why is that? Is there a away to make it so that it only goes to the django page when I goto a subdomain /testproject instead?
here is what I got
python version: 2.5.2
Django version 1.2 b1
I'm using mod_python. here is my apache http.conf file
MaxRequestsPerChild 1
<location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE testproj1.settings
PythonPath "['/root/django/django_projects'] + sys.path"
PythonDebug On
</location>
<location "/admin_media">
SetHandler None
</location>
<location "/media">
SetHandler None
</location>
<LocationMatch "\.(jpg|gif|png)$">
SetHandler None
</LocationMatch>
SetHandler None
Thanks!
"It completely ignores the index.html
file in the www directory. Why is
that?"
Because you installed django and django takes over from that point. You should probably change the <Location> path to "testproject" instead of "/" as obviously the latter means root/homepage. Though I'm not sure this will quite workout properly because I'm not sure it will take over the entire testproject directory like it would to the root, I could be wrong.
If you have access to, you can instead setup a subdomain as it's probably not feasible to set it up in /testproject/.