Django 1.6 not loading css files - django-admin

Im using Django 1.6 version over apache webserver on windows.
Im not able to load the css file when accesisng the
DJango admin panel ,once i login also im not able to load the css file
href="/static/admin/css/base.css"
PROJECT_ROOT = 'D:/DjangoProjects/firstproject/firstproject'
STATIC_ROOT = os.path.join(PROJECT_ROOT,'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
# empty
)
Am i missing anything?

Run
python manage.py collectstatic
to add the admin files to static.
You should set a static url different than the static folder name - not required, but recommended
STATIC_URL = '/public/'
STATIC_ROOT = os.path.join(PROJECT_ROOT,'static')
Create an alias on the virtualhost (/etc/apache2/sites-avaliable/you_site.conf) for the STATIC_ROOT
Alias /public /var/www/public_html/your_project/static
<Directory /var/www/public_html/your_project/static>
Order allow,deny
Allow from all
</Directory>
Restart apache

Related

Cannot start ruby on rails application on server but works locally, wrong environment path

I've encountered an issue that is preventing me from starting my Ruby on Rails application on our Production server despite it running correctly on both Development and Staging environments. The error message is as follows:
[ E 2021-04-26 14:53:39.4216 14896/T11 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /path/to/application: The application encountered the following error: No such file to load -- /path/to/application/app/config/environment.rb (LoadError)
For some reason Passenger is attempting to find the config/environment.rb inside of an app folder when instead it should just be looking for:
/path/to/application/config/environment.rb
Passenger is being configured using Apache and the site config can be seen below:
<VirtualHost *:80>
# PassengerFriendlyErrorPages on
# PassengerStartTimeout 90
ServerAdmin email#example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DocumentRoot /path/to/application/public
<Directory /path/to/application/public>
AllowOverride None
Options -Multiviews
Require all granted
</Directory>
</VirtualHost>
PassengerPreStart http://localhost
PassengerAppEnv production
PassengerLogFile ${APACHE_LOG_DIR}/passenger.log
The server is running Ubuntu 18.04. I've included what I think are the relevant versions below:
Ruby - 2.5.1
Ruby on Rails - 5.2.5
Passenger - 6.0.7
Does anyone know what config I may be missing that is causing Passenger to be looking in the wrong place?
look .. i read about passenger , i am beginner to ruby ;"beginner"= when i remember about ruby,python i download them and i try to compile them to exe to find out if they changed things = .exe smaller or for the another alternative of compilers i usually use ..
today's test was in ruby + apache + php 8.1 as testing a output from a http://localhost/test/ and without any compilation (this isn't the answer to your question but if anyone needs this new point of view and you use php and ruby always ..)
in windows with apache ,php ,.. and ruby installed , in your htdocs create test folder and put these into it:
index.php
<?php
// Highest priority
proc_nice(-20);
echo shell_exec('index.rb');
//system('index.rb');
?>
index.rb
#puts "Content-type: text/html\r\n"
puts "Hello World" + "<br>"
time1 = Time.new
puts "Current Time : " + time1.inspect + "<br>"
# Time.now is a synonym:
time2 = Time.now
puts "Current Time : " + time2.inspect + "<br>"
now open the browser and go to http://localhost/test/
then if you click refresh or you hit f5 key(refresh) in your bowser after the first results then the time shoul display the refresh values

configuring .htaccess file with multiple subdomains Justhost

Situation is like this :
I have hosting company justhost.com
There I have main domain and two subdomains. First subdomain is with PHP
based webpage, but second is newly created and based on ruby on
rails.
I want such thing, before I am sure that newly created application on RoR is functioning well, keep old one up and running. But somehow when I want modify .htaccess file with code for RoR (source- https://my.justhost.com/cgi/help/rails#access ).
main htacces file located on root_page :
DirectoryIndex index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm home.htm default.htm index.fcgi default.html
# -FrontPage-
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthUserFile /home/ecotec11/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ecotec11/public_html/_vti_pvt/service.grp
ErrorDocument 404 /404.shtml
AuthName ecotechno.lv
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
htacces file for RoR application:
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Change to your environment
RailsEnv production
RailsBaseURI /$HOME/$USER/eco
SetEnv GEM_HOME /
This is what I get :
http://gyazo.com/291394024c60284e315b04b3b91128f4 :
It seems that project can't find installed gems or valid rails installation. I tried to update rails installation, but now when it succeded there is no change at all.
Thanks

Wamp Server : Path of uploaded files

Hi I have a WAMP server where some files are upload into an specific path.
C:\wamp\www\upload\
in this case. However could it be possible to upload these files into for example
D:\Documents\User\upload ?
Upload.php specifies the path where the files are stored but I haven´t the way of changing to another path.
Thanks in advance,
Katherine
Edit: upload.php
Here is the upload_file.php
<?php
$target_path = "c:\\";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "El fichero ". basename( $_FILES['uploadedfile']['name'])." ha sido enviado";
} else{
echo "Hubo un error, inténtalo de nuevo!";
}
?>
Katherine,
In WAMP, Apache is setup ( as it should be for security reasons ) so that Apache will not allow access to the root folder of the C:\
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
**Deny from all**
</Directory>
This stops hackers that successfully break into your site from being allowed to cause REALLY SERIOUS DAMAGE.
So I would expect to see an error message in either your Apache error log or your Php error log. I would also expect to see and error on the screen from XDEBUG unless you have disabled that feature. Maybe you should re-enable it as these error messages are really useful while you are developing!!!
change php.ini
display_errors = On
Now it is possible to open up specific folders outside the normal website folder structure like this
This is an excerpt from the httpd.ini without all the comments
<Directory "d:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Alias /my_other_upload_folder_alias "c:/some_other/folder/my_other_upload_folder"
<Directory "c:/some_other/folder/my_other_upload_folder">
AllowOverride All
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
</Directory>
</Directory>
You then use 'my_other_upload_folder_alias' as the folder name in your php code.
PS. You look like you are placing your site into c:\wamp\www this is a bad idea!
Create subfolders for your sites like this
c:\wamp\www\site1
c:\wamp\www\site2
And think about create one virtualHost per site.

Different php ini files by directory or alias in lighttpd

Take 2 domains: www.domain.com and sub.domain.com. Each hosted on the same server at /home/www and /home/sub respectively and using a different php.ini file through vhost configuration within lighttpd.
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php5-cgi -c /home/www/php.ini"
))
)
$HTTP["host"]=="sub.domain.com" {
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php5-cgi -c /home/sub/php.ini"
))
)
}
Is it possible to enable www.domain.com/sub to serve the content of sub.domain.com while still using the appropriate php.ini?
The major difference in the php.ini files we are using is the include_path. Is there an alternative way to alter this through the server config by directory or alias? Or within a single php.ini?
The motivation for this is that we only have an SSL certificate for the main www domain, but wish to serve sub content via SSL on the primary domain path.
Using lighttpd on debian.
Don't know if it's still valid, but I followed this a few years ago... sadly I don't use lighttp where I work right now so can't verify it will still work.
http://www.cyberciti.biz/tips/custom-phpini-file-for-each-domain-user.html

Getting Django Admin Site Formatted Under Apache

My question is how can I get my Django admin site to be formatted (all pretty) under Apache the way it is under runserver? I can bring it up and log into it, but it is not all nicely formatted.
There is nothing special about my urls.py file
from django.conf.urls.defaults import *
from django.contrib import admin
from amr.views import hello
admin.autodiscover()
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
('^hello/$', hello),
# Example:
# (r'^amr/', include('amr.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
Here's my apache config.
<Location />
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonOption django.root /home/amr/django/amr
PythonPath "['/home/amr/django', '/home/amr/django/amr', '/usr/local/lib
/site-packages/django'] + sys.path"
PythonDebug On
</Location>
You're likely missing the CSS/JS for ADMIN_MEDIA. This setting is in the settings.py. I usually set it to:
ADMIN_MEDIA_PREFIX = '/adminmedia/'
I then add the following to my Apache conf (modify for your actual path):
Alias /adminmedia /usr/lib/python2.6/site-packages/django/contrib/admin/media/
This serves the default Django admin media files.
You can then override the admin templates as described here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Resources