Wamp tmp redirect - wamp

I would like to redirect my tmp files to another drive instead of C:/wamp/tmp I would like to redirect tmp files to D:/tmp or do I have to reinstall wamp on the D drive.

Found the way, went in the php.ini file and changed the c:/wamp/tmp to d:/wamp/tmp.

Related

Write permission nginx gunicorn

In my django/python code I have the following lines:
f = open(os.path.join(DIRECTORY, filname), 'w')
f.write(filecontent)
f.close()
when I have DIRECTORY='/tmp/' it all works fine, the file.txt is saved with owner=root and group=www-data. However, when I want to save the file in a subdirectory of my django-project, for example DIRECTORY='/project/subfolder' the file doesn't appear, although I have that subfolder set to the same owner/group.
I suspect that it is a permission problem with nginx or gunicorn. Any suggestions?
I tried to solve my problem by just mounting the /tmp/ directory to the docker container where I use the file afterwards. But I ran into the problem, that files in the /tmp/ directory do not appear in docker, while as when I mount another folder like /project/subfolder/, these files do appear in docker. So either way, half works, but never both.
Did you check what kind of permissions your subfolder has?
I also tried saving some files in my project subdirectory.
For example i had a "log" subfolder in my project folder and i had to change permissions using:
chown -R www-data:www-data /var/www/test/myproject/log
Update:
Because of your relative path, django can't save it. You must specify the absolute path.
Therefore in you settings create a variable:
BASE_DIR = Path(__file__).resolve().parent.parent
This is the absolute path location to you project.
You have to import BASE_DIR to your py file and than you can use it like before:
f = open(os.path.join(BASE_DIR, filname), 'w')
f.write(filecontent)
f.close()

Problem with static folder IIS for Django

I have a static folder set in django to a network path
STATICFILES_DIRS = [
"//SERVER/Shared1/FOLDER_210121/",
]
and I have 2 pages that have links to this static subfolders
link1: http://server2:8044/static/folder1/COINS_LIVE_OU164/user1310200781810167.tif
link2: http://server2:8044/static/folder2/COINS_LIVE_OU164/user2310200781810167.tif
however link1 works perfectly but link 2 gives me an error as file not found
but the file does exist, and from IIS I have set a virtual directory aliased as "static" with the root folder that contains the subfolder from where I get the files.
I can navigate from the virtual directory to both files, the virutal directory was created with the defaultAppPool user.
is there something else I could check?
(if I run the manage.py runserver command and I use localhost I can download both files, the issue is when using it from the IIS).
if I print the value of static in a label the path is ok, so I'm guessing permission, but where can I be missing the configuration?
Thank you.
Adding a bit more info:
the issue affects a subfolder inside the "static" folder, 1 can enter without probelms, the other can't.
I'm getting crazy. I deleted all, created again, and the issue still occurs.
I was able to solve my particualr problem, it was fixed by putting the static handler module mapping alone with the Django FastCGI (custom) module in the website IIS

How to hide the full directory when serving static files with Apache

I am using Django and Apache.
I am serving the static files with Apache. It works well, the problem is, when a user go to the url http://urlOfMySite.com/static, he can see the whole directory and navigate in it.
I'm using : Alias /static /var/www/MySite/app/app/static in Apache VirtualHost to serve static files.
Is there any way to hide it from user? (make the static files accessible, but not the full directory browsable).
Thanks
Your problem is about the apache server itself, you need to disable indexing for that folder with "Options -Indexes" inside the "directory" clause to specify which folder you want to apply this command. More info:https://wiki.apache.org/httpd/DirectoryListings#Directory_Listings
Btw, this is odd, by default, when I deploy using Apache, I don't need this =/.

Serving static admin files for Django 1.5 in a shared hosting environment

I'm trying to get a fresh installation of Django 1.5 running on an Apache-Server. The WebServer is situated on a shared hosting platform called uberspace.de
which means I have no access to the Apache configuration itself I can however write .htaccess files if that's any help at all. Django is deployed via fast-cgi which is working as expected.
Whats not working however is the access to static files on the server like the .css files and graphics for the Django administration interface.
As mentioned in the official docs I used the following command to copy the static Files into my ~/html/static directory.
manage.py collectstatic
And these are the values from my settings.py:
STATIC_ROOT = '/home/bier/html/static/'
STATIC_URL = '/static/'
All I get is the infamous django 404 page when I try to access any of these Files.
I also followed the 'How to install and deploy Django' guide on my Webhosters Website to the letter. (sorry its only available in german I believe)
I already contacted the webhosters support but they don't know whats wrong.
All the solutions I've come up with so far suggest setting some sort of Alias in the Apache configuration. Which I can not do.
I'm thankful for any ideas you might have.
Try using a full address instead.
STATIC_ROOT = '/home/bier/html/static/'
STATIC_URL = 'http://www.mysite.com/static/'
Edit: Perhaps you could ask your host to setup /static/ in your Apache config:
sudo nano /etc/apache2/sites-enabled/mysite.com and add:
Alias /static/ /home/bier/html/static/
I've had a situation before where I've had to upload /static/ files manually because of a highly restrictive host (permissions). Perhaps you need to download a copy of django to your desktop and then upload the static admin file set into your /static/ directory manually?
Lastly, have you added the static files to your urls?
url(r'^static/(?P<path>.*)$','django.views.static.serve',{'document_root': '/home/bier/html/static'}),
I have more simpler solution. you need to create a directory named, let's say 'x' in "public_html" or similar location from which server serves the files by default.
Then upload all static files in directory x. (this can be done by running collectstatic locally and then upload all contents of directory STATIC_ROOT to x)
Then, change your STATIC_URL and STATIC_ROOT as follows:
STATIC_URL = '/x/'
STATIC_ROOT = os.path.join(BASE_DIR, '../public_html/x') # Path to folder

Run Django project using wsgi

Hi i am trying to host the django site using WSGI app.My project resides in /opt/labs and the contents of this are django/ labs_site/ content/ home/
labs_site was the initial project that was derived from startproject and from labs_site/urls.py i link to content,home and other modules
i have followed the documentation in https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/ till renaming labs_site/wsgi.py as os.environ.setdefault("DJANGO_SETTINGS_MODULE", "labs_site.settings")
So after this what is the next step that i should follow.I want to run the project without the runserver
modify your apache settings now. If setting up wsgi file was your first step, then next step should be modifying your apachee config to point towards that file.
The link you posted points towards this page: https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
that has all the necessary information. You can just choose between putting all that into http.conf file or creating site file for it under sites-available & sites-enabled folders in /etc/apache.
After that - restart your apache server by /etc/init.d/apache2 or service apache2 restart - whichever works.
Then since its your first time, youll see some errors in your /var/log/apache2/error.log. Fix them... and try again :)
Good luck.