Pages

Sunday 21 April 2013

Utmost things to do with your new vps

Firstly, update and upgrate your installation

   apt-get update
  apt-get upgrade
Secondly, create new user and prevent root ssh login , to enhance security of your vps

Mysql2 installation and password reset


MySQL is a powerful database management system used for organizing and retrieving data.

To install MySQL, open terminal and type in these commands:

         sudo apt-get update
         sudo apt-get install mysql-server

Apach2 : complete removal


sudo apt-get --purge remove apache2
sudo apt-get remove apache2
sudo  apt-get purge apache2
sudo apt-get autoremove
sudo apt-get remove apache2*
sudo  dpkg --purge apache2.2-common

Sunday 14 April 2013

EHCP: opensource hosting control panel


Installing ehcp
  Go to their site and follow their simple, easy to follow instruction.
  1. Download tar
  2. run install script
     And follow instructions that pop on your screen.
After installing, launch your browser and load this page:  http://yourIP/ehcp
Enter your username(admin) and password(1234). You are ready to use ehcp cpanel

Saturday 13 April 2013

Nginx: Next generation server--Super light, Super fast

Nginx Conf file


Add the server information in the nginx file


     server {
listen 80 default_server;
server_name localhost
        location / {
            root   /home/deployer/www;
 #          index  index.html index.htm;
        }
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
   }



    listen 80;
    server_name domain.com;
    charset utf-8;
    root /www/domain.com/public_html;
    passenger_enabled on;
    passenger_base_uri /blog;
    rails_spawn_method smart;
    rails_env production;




Now, you have server listening on port :80 and it's root location is set to /home/deployer/www.
For rails project, your application /public directory should be present there :Create a symlink in www, so that the app is viewable via the web.

 ln -s /home/deployer/www/media_analysis/public /home/deployer/www/media


Nginx start/stop/restart commands:

  • sudo /etc/init.d/nginx stop 
  • sudo /etc/init.d/nginx start 
  • sudo /etc/init.d/nginx restart

Errors:
   404 Not Found Error:
Make sure,  you have "passenger_enabled  on", if multiple server blocks:
                         If you already have passenger_root and passenger_ruby in your nginx.conf, but having this error, you must have some location blocks. Then you must specify passenger_enabled on; inside each location block.

Deploying to a sub URI


                      You already have your server(vhost) configured and you want your Ruby on Rails application to be accessible from the URL http://www.myDomain.nl/rails.
To do this, make a symlink in the virtual host’s document root, and have it point to your Ruby on Rails application’s public folder. For example:

ln -s /webapps/newApp/public /websites/myDomain/rails

Next, set 'passenger_enabled on' and add a 'passenger_base_uri' option to the server block:

http {
    ...

    server {
        listen 80;
        server_name www.myDomain.nl;
        root /websites/myDomain;
        passenger_enabled on;        # <--- These lines have
        passenger_base_uri /rails;   # <--- been added.
    }

    ...
}



References:

  1. http://techoctave.com/c7/posts/16-how-to-host-a-rails-app-with-phusion-passenger-for-nginx
  2. http://www.modrails.com/documentation/Users%20guide%20Nginx.html#deploying_a_ror_app
  3. http://alexpearce.me/2012/06/setting-up-a-vps/