Friday, October 30, 2015

How to create name based subdomain in apache2 conf.

Create name based subdomain in apache2 conf.:

Some or many time we need to set the same document root for all or almost
each sub domains to a same document root, we can simply do it with apache virtual host  setting as following.

For say if we want that all sub domains of example.com should be hosted on same server and share the same document root then we can use apache web server's ServerAlias Directive as follows

Open this file: /etc/apache2/sites-enabled/000-default.conf

and set this code:


<VirtualHost *:80>
ServerName example.com
ServerAlias server server2.domain.com server2
ServerAlias *.example.com
</VirtualHost>
 

Thanks

Friday, October 23, 2015

How to deploy an ionic app on heroku?

Deploy an ionic app on Heroku:

For deploy your project on heroku as a serving host we can do the following

steps:

1:- At first create a heroku account and install Heroku Toolbelt on your ubuntu system as  directed in following link

https://toolbelt.heroku.com/debian

2. Now initialize a git repository and commit all code to it

as following

git init



3. add heroku remote as following

heroku login

heroku create appname

it gives you back a git and heroku serve url on successful creation.


4. Now go to your terminal and reach to project root you want to deploy on

heroku install any dependencies needed to deploy for example if it a ionic app

as per my case we need to do as follows

npm install express --save

and create the following files

a app.json and write the following code

{

    "name": "app name",

    "description": "App description",

    "repository": "heroku serve url",

    "keywords": ["Keyword1", "Keyword2", "Keyword3"]

}


and a server.js and write the following code to serve node application

var express = require('express'),

    app = express();

app.use(express.static('www'));

app.set('port', process.env.PORT || 5000);

app.listen(app.get('port'), function () {

    console.log('Express server listening on port ' + app.get('port'));

});

and some other dependencies as well should be installed first.

5. Now do the following

git commit -am"comment for version"

git push heroku master

as heroku is the remote name by default created by heroku on app creation

and master is the default git branch.

Got to tour app serve url and check for it.

Thanks

Friday, October 16, 2015

Route Model Binding using laravel 5.1

Route Model binding using Laravel 5.1:

What is Route Model Binding in laravel?
Ans: Laravel model binding provides a convenient way to inject class instances into  routes. For example, instead of injecting a user's ID, you can inject the entire User class instance that matches the given ID.

1. Open route.php and write following code .

Route::model('users', 'User');
Route::bind('users', function($value, $route) {
    return App\Task::whereSlug($value)->first();
)};
Route::resource('users', 'UsersController');

 Note: where User is Model name 

2. use users/{slug} as url instead of users/{id}

3. use controller method update({slug}) instead of update({id})

Thanks

Friday, October 9, 2015

How to send email through terminal in ubuntu?

Send email through terminal in ubuntu:

Hi everybody,

In this blog we will cover email sending through terminal in ubuntu.

1. For send a email through terminal firstly install the postfix using this

sudo apt-get install postfix
 
2. Now go to this file

sudo nano /etc/postfix/main.cf

and change

myhostname = example.com

3. Put in name of your domain into myhostname.

4. If you want to have mail forwarded to other domains, replace alias_maps with virtual_alias_maps and point it to /etc/postfix/virtual.

virtual_alias_maps = hash:/etc/postfix/virtual

5. The rest of the lines are set by default. Save, exit, and reload the configuration file to put your changes into effect:

sudo /etc/init.d/postfix reload

6. Now run this for checking through terminal

sendmail sample-email@example.org