Yet Another Can't get static files to show up in shared linux website on Godaddy

43 views
Skip to first unread message

Anthony Percy

unread,
Apr 10, 2017, 7:37:31 AM4/10/17
to Django users
Hi all,
Sorry to ask this question but I cant get my static files in Mezzanine to show up on a Godaddy hosted site e.g http://www.murraybridge.co
I have had to use "pip install flup" and "pip install django-fastcgi-server" as Godaddy seems to have the fcgi module active on the apache webserver which I understand is now deprecated.
The .htaccess file is in ~/public_html is ;

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mezproject.fcgi/$1 [QSA,L]

My "mezproject.fcgi" file in ~/public_html is;

#!/home/vk2acp/code/mez/bin/python
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home/vk2acp/code/mezproject")
# Switch to the directory of your project. (Optional.)
os.chdir("/home/vk2acp/code/mezproject")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "mezproject.settings"
from django_fastcgi.servers.fastcgi import runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
wsgi_application = get_internal_wsgi_application()
runfastcgi(wsgi_application, method="prefork", daemonize="false", minspare=1, maxsp
are=1, maxchildren=1)

The "static" dir exists in the mezproject dir after I did "python manage.py collectstatic"
I have tried copying  static dir to the public_html dir with no effect.
Obviously I cant add the "Alias" directive as I have no control over the http.conf file.
It seems a pity to get this far and run into this brick wall!!!
Do I have to run the whole mez project from the public_html dir???
Any suggestions?

Best Regards

Anthony

Camilo Torres

unread,
Apr 10, 2017, 11:22:38 AM4/10/17
to Django users
Hi
You may want to review:
https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/

You may also want to make sure your server supports wsgi deployments:
https://docs.djangoproject.com/en/1.11/howto/deployment/

René Fleschenberg

unread,
Apr 12, 2017, 6:59:03 AM4/12/17
to django...@googlegroups.com
Hi,

Do *not* put your project into the webserver's document root. Doing so
will likely expose secret data (your source code including the database
password and SECRET_KEY).

Your STATIC_ROOT must be a location that your webserver serves under
STATIC_URL. If you cannot configure your webserver to do this, you can
use http://whitenoise.evans.io/en/stable/.

However, you will probably run into the same limitation when you want to
serve user-uploaded files ("media"), and whitenoise cannot help you
there. You will have to serve your media files from an external server,
such as Amazon S3.

I recommend deploying to an environment with WSGI support, btw. FCGI is
not supported anymore:
https://docs.djangoproject.com/en/1.8/howto/deployment/fastcgi/. If you
do not want to setup your own server, PythonAnywhere and Heroku are
popular choices.

Regards,
René


On 04/10/2017 07:47 AM, Anthony Percy wrote:
> Hi all,
> Sorry to ask this question but I cant get my static files in Mezzanine
> to show up on a Godaddy hosted site e.g http://www.murraybridge.co
> <http://www.murraybridge.co/>
> I have had to use "pip install flup" and "pip
> install django-fastcgi-server" as Godaddy seems to have the fcgi module
> active on the apache webserver which I understand is now deprecated.
> The .htaccess file is in ~/public_html is ;
>
> AddHandler fcgid-script .fcgi
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ mezproject.fcgi/$1 [QSA,L]
>
> My "mezproject.fcgi" file in ~/public_html is;
>
> /#!/home/vk2acp/code/mez/bin/python/
> /import sys, os/
> /# Add a custom Python path./
> /sys.path.insert(0, "/home/vk2acp/code/mezproject")/
> /# Switch to the directory of your project. (Optional.)/
> /os.chdir("/home/vk2acp/code/mezproject")/
> /# Set the DJANGO_SETTINGS_MODULE environment variable./
> /os.environ['DJANGO_SETTINGS_MODULE'] = "mezproject.settings"/
> /from django_fastcgi.servers.fastcgi import runfastcgi/
> /from django.core.servers.basehttp import get_internal_wsgi_application/
> /wsgi_application = get_internal_wsgi_application()/
> /runfastcgi(wsgi_application, method="prefork", daemonize="false",
> minspare=1, maxsp/
> /are=1, maxchildren=1)/
>
> The "static" dir exists in the mezproject dir after I did "python
> manage.py collectstatic"
> I have tried copying static dir to the public_html dir with no effect.
> Obviously I cant add the "Alias" directive as I have no control over the
> http.conf file.
> It seems a pity to get this far and run into this brick wall!!!
> Do I have to run the whole mez project from the public_html dir???
> Any suggestions?
>
> Best Regards
>
> Anthony
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a38ab714-1903-4c92-a5d0-0b1455c29a75%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a38ab714-1903-4c92-a5d0-0b1455c29a75%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

--
René Fleschenberg

Am Stadtgarten 28, 45276 Essen, Germany
Phone: +49 1577 170 7363
E-Mail: re...@fleschenberg.net
Reply all
Reply to author
Forward
0 new messages