How to Run two django projects in one server

I am using python 2.7,django 1.4,and Apache2.2.21, I am able to run one project on Apache server, I want to use the same Apache and same server to run my second project.

I am using the below for my first project

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "product.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

and in Apache httpd.conf file using below code

LoadModule wsgi_module modules/

At last of the file

WSGIScriptAlias / C:/Python27/Lib/site-packages/django/bin/product/product/

WSGIPythonPath /C:/Python27/Lib/site-packages/django/bin/product

<Directory C:/Python27/Lib/site-packages/django/bin/product/media>

Order allow,deny

Allow from all


<Directory C:/Python27/Lib/site-packages/django/bin/product>

Order allow,deny

 Allow from all


<Directory  "C:/Python27/Lib/site-packages/django/contrib/admin/media">

Order deny,allow

Allow from all


Alias /static/admin/  C:/Python27/Lib/site-packages/django/contrib/admin/media/ 

Please help me out how can run the second project with path as / C:/Python27/Lib/site-packages/django/bin/second/product/product/ on same Apache server.

Why does Dropbox break my Drupal site?

I'm using Apache 2.4 on Ubuntu 14.04 and Drupal 7. I wanted an easy remote backup for my Drupal site, so I tried putting it in Dropbox. Then, something happened, and Apache started giving 403 errors ("You don't have permission to access / on this server.") for the site.

I recovered from an old backup, but I still can't figure out what happened. I diffed the Dropbox directory and the backup, and they're the same. I reset all the permissions in the Dropbox directory to match the backup, but the version in Dropbox still won't work. I also tried copying the files from the Dropbox directory into the location of the backup, and that still didn't work.

I'm a bit at a loss as to what went wrong. Does anyone have ideas as to what Dropbox might have broken?

.htaccess infinite loop, appends / to URL until redirect loop

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied

<Directory /usr/share>
        AllowOverride None
        Require all granted

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

<Directory /var/www/html/portal>
        Options +SymLinksIfOwnerMatch
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !(/$:\.)
        RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ dashboard.php?url=$1 [L]

The last directory definition is resulting in an infinite loop, / is appended to the URL around 10 times before Chrome fires a redirect loop error.

I'm not sure why this is happening as I used the same set up on another server and it worked fine. Is there anything wrong with this? All I'm trying to do is append a single / after the requested URL if one is not already present.

Any ideas why this is looping?

Hadoop namenode shut down

My hadoop version is The namenode running on my hadoop clulser was shut down. I checked the logs, and found the error message only in the secondary name logs:

2014-09-27 22:18:54,930 WARN org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Checkpoint done. New Image Size: 29552383
2014-09-27 22:19:42,792 INFO org.mortbay.log: [email protected] JVM BUG(s) - injecting delay2 times
2014-09-27 22:19:42,792 INFO org.mortbay.log: [email protected] JVM BUG(s) - recreating selector 2 times, canceled keys 38 times
2014-09-27 23:18:55,508 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Number of transactions: 0 Total time for transactions(ms): 0Number of transactions batched in Syncs: 0 Number of syncs: 0 SyncTimes(ms): 0 
2014-09-27 23:18:55,508 FATAL org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Fatal Error : All storage directories are inaccessible.
2014-09-27 23:18:55,509 INFO org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: SHUTDOWN_MSG:

There was anonther error message apprears in one of my datanodes:

2014-09-27 01:03:58,535 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: DatanodeRegistration(, storageID=DS-532990984-, infoPort=50075, ipcPort=50020):DataXceiver
org.apache.hadoop.util.DiskChecker$DiskOutOfSpaceException: No space left on device
        at org.apache.hadoop.hdfs.server.datanode.DataNode.checkDiskError(
        at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.receivePacket(
        at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.receiveBlock(
        at org.apache.hadoop.hdfs.server.datanode.DataXceiver.writeBlock(

Not sure whether this is the root cause of the namenode shutting down issue?

New error raised when I was trying to restart the namenode?

2014-09-28 11:25:06,202 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed. Incorrect data format. logVersion is -31 but writables.length is 0. 
        at org.apache.hadoop.hdfs.server.namenode.FSEditLog.loadFSEdits(
        at org.apache.hadoop.hdfs.server.namenode.FSImage.loadFSEdits(
        at org.apache.hadoop.hdfs.server.namenode.FSImage.loadFSImage(
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(
        at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(
        at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(

Is there anyone knows about it ?  Is it possible to fix the imagne and editor files as I don't want to lose the data?

Secure HTTP Streaming Plugin with FlowPlayer always says "Stream Not Found"

I think I have everything configured correctly, but I can not stream any video with flowplayer and this plugin actived.

The structure of the files is:

--video.mp4 <-- Mi video (2.4 MB)

(All files and dirs set with 755 permission)

In index.php:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- A minimal Flowplayer setup to get you started -->

    include flowplayer JavaScript file that does  
    Flash embedding and provides the Flowplayer API.
  <!-- flowplayer depends on jQuery 1.7.1+ (for now) -->
  <script src=""></script>
  <script type="text/javascript" src="flowplayer/flowplayer-3.2.13.min.js"></script>
    $(document).ready(function() {

      $f("player", "flowplayer/flowplayer-3.2.18.swf", {
        plugins: {
          secure: {
            url: "flowplayer/flowplayer.securestreaming-3.2.9.swf",
            timestampUrl: "sectimestamp.php"
        clip: {
          baseUrl: "secure",
          url: "video.mp4",
          autoPlay: false,
          urlResolvers: "secure",
          scaling: "fit",


<div id="player"></div>



echo time();


$hash = $_GET['h'];
$streamname = $_GET['v'];
$timestamp = $_GET['t'];
$current = time();
$token = 'sn983pjcnhupclavsnda';
$checkhash = md5($token . '/' . $streamname . $timestamp);

if (($current - $timestamp) <= 2 && ($checkhash == $hash)) {
  $fsize = filesize($streamname);
  header('Content-Disposition: attachment; filename="' . $streamname . '"');
  if (strrchr($streamname, '.') == '.mp4') {
    header('Content-Type: video/mp4');
  } else {
    header('Content-Type: video/x-flv');
  header('Content-Length: ' . $fsize);
  header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
  header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
  header('Pragma: no-cache');
  $file = fopen($streamname, 'rb');
  print(fread($file, $fsize));
} else {
  header('Location: /secure');


RewriteEngine on
RewriteBase /secure

RewriteRule ^(.*)/(.*)/(.*)$ video.php?h=$1&t=$2&v=$3

RewriteRule ^$ - [F]
RewriteRule ^[^/]+\.(flv|mp4)$ - [F]

Mod Rewrite is enabled in apache.

Server info:

PHP Version 5.6.0-1 Apache/2.4.10 (Debian)

Test URL

What is my problem? Thanks in advance.

Ps. Sorry for my bad english.

Need advice on UK web hosting

I'm nearly finished with my website. I need some advice to help with getting it live.

Do all servers with web hosting companies use apache? Or does it vary? Reason I ask is because I'm using a command specific to apache that treats a html page as a php file. I don't want to choose a host, upload the site and find that it's not supported.

I'm really unsure of the whole process with getting a website live. I know I need a domain and a hosting server. Are there any recommendations for good UK hosting companies? I'm considering a few atm:

Anyone have any experience with any of those?

I'm completely open to recommendations, so please do tell me if you have a good experience with a specific company.

Do I get the domain name separately? Or does it depend on the company I go with. I know that some offer a domain name with the hosting service.

Thanks in advance for any help.

PHP: make a folder’s files accessible, only after a successful login

Right now, in my website, i have managed to redirect the user, after successful login, to a page by using something like this on my page:

if( login was successful)

The folder named, contains an .htaccess file,

 # This file prevents that your .php view files are accessed directly from the outside
 <Files ~ "\.(htaccess|php)$">
 order allow,deny
 deny from all

which is causing all .php files in the protected_files folder to give users a 403 error, when they type in their browser

Which is where the function include('protected_files/anyphpfile.php') comes in handy.

Now, i am trying to figure out how to redirect the user from protected_files/phpfile1.php to protected_files/phpfile2.php from a menu bar.

<a href="">page2</a> is not working (error 403), because it belongs in the protected_files folder, which has the .htaccess file, and it makes it not aaccessible from a url.

My solution to this matter, was something like:

//code in ``
if ($_GET['page'] == "phpfile2") {
} else {    

Which means that after a successful login, users would be taken to by default (since $_GET['page'] == "")

Now, the user is in phpfile1.php and he can click on an link <a href="?page=phpfile2">phpfile2</a> to go to phpfile2.php. While doing that, his browser at first shows and after he clicks on the link , it shows

What i am trying to do is not show in the url , when the user is in the phpfile2.php page , but to show the actual file path, which is

How can i achieve that in this particular case?

Could i possibly change the .htaccess so that protected_files becomes reachable (no more error 403) after a successful login ? Should i change the way i made this site completely ?

Basically, in the end, i want to have a folder, named protected_files, which contains .php files that are available to the user, only after a successful login.

`AddType application/json json php` does not work

We want to create some kind of api where the json formatted results are generated using .php files.

The web folder looks like

├── .htaccess
└── foo
    ├── bar.php
    └── baz.php

Where bar.php and baz.php are php files generating json-formatted replies on the queries.

Such files (bar.php) look like:


$id = $_GET['id'];

echo json_encode(some_function($id));

Of course one should specify a header header("Content-type: application/json");. We however want to set the .htaccess to do this, such that one never forgets to set the content-type, that if additional headers are required, we can modify this easily, etc. We don't want to write header(...) in every file.

.htaccess look like:

#All php files return JSON formatted text.
AddType application/json json php

But the generated result has still mime-type: text/html.

What can cause this?

How to know Apache2 modules usage statistics?

Due to high memory & CPU usage for instances, I wonder if there's any way to get the statistics of Apache2 module usage (e.g. count on enabled module calls from http requests) so I could disable modules not being used. For example, suppose I have an instance with following Apache2 module enabled:


The expected output (might be a static log or in real time; all ok):

From 2014/09/29 07:54:00 UTC+8

777777 mod_expire
555555 mod_rewrite
222222 mod_proxy
11     mod_ssl
33333  mod_status