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 wsgi.py 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/mod_wsgi.so

At last of the file

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

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>

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

Order allow,deny

 Allow from all

 </Directory>

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

Order deny,allow

Allow from all

</Directory>

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

Please help me out how can run the second project with wsgi.py path as / C:/Python27/Lib/site-packages/django/bin/second/product/product/wsgi.py 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>

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

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

<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]
</Directory>

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 0.20.203.0. 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(10.75.6.51:50010, storageID=DS-532990984-10.75.6.51-50010-1343295370699, 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(DataNode.java:770)
        at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.receivePacket(BlockReceiver.java:475)
        at org.apache.hadoop.hdfs.server.datanode.BlockReceiver.receiveBlock(BlockReceiver.java:528)
        at org.apache.hadoop.hdfs.server.datanode.DataXceiver.writeBlock(DataXceiver.java:397)
        at org.apache.hadoop.hdfs.server.datanode.DataXceiver.run(DataXceiver.java:107)
        at java.lang.Thread.run(Thread.java:662)

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.
java.io.IOException: Incorrect data format. logVersion is -31 but writables.length is 0. 
        at org.apache.hadoop.hdfs.server.namenode.FSEditLog.loadFSEdits(FSEditLog.java:542)
        at org.apache.hadoop.hdfs.server.namenode.FSImage.loadFSEdits(FSImage.java:1009)
        at org.apache.hadoop.hdfs.server.namenode.FSImage.loadFSImage(FSImage.java:827)
        at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:365)
        at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:97)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:379)
        at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:353)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:254)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:434)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1153)
        at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1162)

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:

index.php
sectimestamp.php
secure/
--.htaccess
--video.mp4 <-- Mi video (2.4 MB)
--video.php
flowplayer/
--flowplayer-3.2.18.swf
--flowplayer.controls-3.2.16.swf
--flowplayer.securestreaming-3.2.9.swf

(All files and dirs set with 755 permission)

In index.php:

<html><head>
<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="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  <script type="text/javascript" src="flowplayer/flowplayer-3.2.13.min.js"></script>
  <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",
        }
      });
    });
  </script>  


</head><body>

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

</body></html>

sectimestamp.php:

<?php
echo time();
?>

video.php:

<?php
$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);
  session_cache_limiter('nocache');
  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));
  fclose($file);
  exit;
} else {
  header('Location: /secure');
}
?>

.htaccess:

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:

https://www.eukhost.com/

http://brace.io/

https://uk.godaddy.com/

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 www.mysite.com/protected_files/redirect.php page by using something like this on my www.mysite.com/login.php page:

if( login was successful)
{
    include('protected_files/redirect.php');
}

The folder named www.mysite.com/protected_files, 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
 </Files>

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

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="www.mysite.com/protected_files/phpfile2.php">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 `www.mysite.com/redirect.php`
if ($_GET['page'] == "phpfile2") {
include("phpfile2.php");
} else {    
include("phpfile1.php");
}

Which means that after a successful login, users would be taken to www.mysite.com/protected_files/phpfile1.php 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 www.mysite.com/login.php and after he clicks on the link , it shows www.mysite.com/login.php?page=phpfile2.

What i am trying to do is not show www.mysite.com/login.php?page=phpfile2 in the url , when the user is in the phpfile2.php page , but to show the actual file path, which is www.mysite.com/protected_files/phpfile2.php

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

api
├── .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:

<?php
include_once("../../utils.php");

$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:

mod_expire
mod_rewrite
mod_proxy
mod_ssl
mod_status
....

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
....