Setup Multiple Django Websites on Django One Click Install Image VPS

How To Use the Django One-Click Install Image

Copy the Nginx configuration for your new site:

cp /etc/nginx/sites-available/django /etc/nginx/sites-available/site2
ln -s /etc/nginx/sites-available/site2 /etc/nginx/sites-enabled/site2

Then edit its contents to match where you installed your new Django app:

upstream app_server {
    server 127.0.0.1:9500 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name www.mysite2.com;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/django/new_project/new_app/media;
    }

    # your Django project's static files - amend as required
    location /static {
        alias /home/django/new_project/new_app/static; 
    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;
    }
}

Do the same for the Upstart script used to start gunicorn:

cp /etc/init/gunicorn.conf /etc/init/new_site.conf

And change the port and path for the project:

description "Gunicorn daemon for Django project"

start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]

# If the process quits unexpectedly trigger a respawn
respawn

setuid django
setgid django
chdir /home/django

exec gunicorn \
    --name=new_project \
    --pythonpath=new_project \
    --bind=0.0.0.0:9500 \
    --config /etc/gunicorn.d/gunicorn.py \
    django_project.wsgi:application

You should now be able to start your project with:

service nginx restart
service new_site start

Notice that the way you start the project is determined by the name you give the Upstart script.

Hope this points you in the right direction! Let us know how it goes.

Run two projects on one tomcat in intellij idea

I have two web application in one project configured using pom. i want to run both the application simultaneously using same instance of Tomcat

Solution is:

Go to Run -> Edit configuration
* add a new configuration for your project (give it a jazzy name)
* Select your Application server( in your case tomcat {version} )
* on the server tab -> before launch section -> add build command for both your artifacts
* go to deployment tab -> add both your application war for deployment
* make sure you provide distinct application context (option on the right)
* Select you new configuration for your project
* click on that green play button .

deploy django by git push

The local repository

It doesn’t really matter how the local repository is set up, but for the sake of argument, let’s suppose you’re starting one from scratch.

$ mkdir website && cd website
$ git init
Initialized empty Git repository in /home/ams/website/.git/
$ echo 'Hello, world!' > index.html
$ git add index.html
$ git commit -q -m "The humble beginnings of my web site."

Anyway, however you got there, you have a repository whose contents you want to turn into a web site.

The remote repository

I assume that the web site will live on a server to which you have ssh access, and that things are set up so that you can ssh to it without having to type a password (i.e., that your public key is in~/.ssh/authorized_keys and you are running ssh-agent locally).

On the server, we create a new repository to mirror the local one.

$ mkdir website.git && cd website.git
$ git init --bare
Initialized empty Git repository in /home/ams/website.git/

Then we define (and enable) a post-receive hook that checks out the latest tree into the web server’s DocumentRoot (this directory must exist; Git will not create it for you):

$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive

Note: earlier versions of this howto depended on setting the git config variables core.worktree to the target directory, core.bare to false, and receive.denycurrentbranch to ignore. But these changes are not needed if you use GIT_WORK_TREE (which didn’t work when I first wrote the howto), and the remote repository can remain bare.

Back on the workstation, we define a name for the remote mirror, and then mirror to it, creating a new “master” branch there.

$ git remote add web ssh://server.example.org/home/ams/website.git
$ git push web +master:refs/heads/master

On the server, /var/www/www.example.org should now contain a copy of your files, independent of any .git metadata.

The update process

Nothing could be simpler. In the local repository, just run

$ git push web

This will transfer any new commits to the remote repository, where the post-receive hook will immediately update the DocumentRoot for you.

(This is more convenient than defining your workstation as a remote on the server, and running “git pull” by hand or from a cron job, and it doesn’t require your workstation to be accessible by ssh.)

source: http://toroid.org/ams/git-website-howto

hotfix to nice model in git

git checkout master
git pull
git checkout -b hotfix/${version}
//тут меняем версию
git commit -a -m ‘version changed’
//тут меняем применяем горячий фикс
git commit -a -m ‘hotfix applied’
git checkout develop
git pull
git merge hotfix/${version}
git checkout master
git merge hotfix/${version}
git tag -a ${version}
git push
git push –tags
git branch -d hotfix/{version}
git checkout develop

gitflow in windows

Скачиваем файлы (вибираем бинарники – ищем указаный файл):
getopt.exe – http://gnuwin32.sourceforge.net/packages/util-linux-ng.htm
libintl – http://gnuwin32.sourceforge.net/packages/libintl.htm
libiconv – http://gnuwin32.sourceforge.net/packages/libiconv.htm
Копируем эти файлы(getopt.exe, libintl3.dll, libiconv2.dll) в корень папки гита (напр. C:\Program Files (x86)\Git)

запускаем cmd с правами администратора, идем в папку /gitflow/contrib , исполняем
msysgit-install.cmd “GIT_HOME”(например: C:\Program Files (x86)\Git) )

tail highlight while logging

tail -f -n 3100 /as/jboss/domain/servers/sname/log/server.log |sed ‘s#DEBUG#\x1b[33m&#; s#ERROR#\x1b[31m&#; s#REQUEST URI:#\x1b[32m&#; s#RESPONSE: #\x1b[36m&#; s#INFO#\x1b[37m&#’
$colorFormats = array(
// styles
// italic and blink may not work depending of your terminal
‘bold’ => “33[1m%s33[0m”,
‘dark’ => “33[2m%s33[0m”,
‘italic’ => “33[3m%s33[0m”,
‘underline’ => “33[4m%s33[0m”,
‘blink’ => “33[5m%s33[0m”,
‘reverse’ => “33[7m%s33[0m”,
‘concealed’ => “33[8m%s33[0m”,
// foreground colors
‘black’ => “33[30m%s33[0m”,
‘red’ => “33[31m%s33[0m”,
‘green’ => “33[32m%s33[0m”,
‘yellow’ => “33[33m%s33[0m”,
‘blue’ => “33[34m%s33[0m”,
‘magenta’ => “33[35m%s33[0m”,
‘cyan’ => “33[36m%s33[0m”,
‘white’ => “33[37m%s33[0m”,
// background colors
‘bg_black’ => “33[40m%s33[0m”,
‘bg_red’ => “33[41m%s33[0m”,
‘bg_green’ => “33[42m%s33[0m”,
‘bg_yellow’ => “33[43m%s33[0m”,
‘bg_blue’ => “33[44m%s33[0m”,
‘bg_magenta’ => “33[45m%s33[0m”,
‘bg_cyan’ => “33[46m%s33[0m”,
‘bg_white’ => “33[47m%s33[0m”,
);