15 February 2013

Convert localhost to domain name for your project in Ubuntu/Mint

20 comments

Hello friends today Iam going to show you how you can convert http://localhost/your_project_name to http://your_domain_name in ubuntu. If you are working on some project then it will be easier to open your project using http://domain_name rather than typing http://localhost/your_project_name each and every time you view it in your browser.It is very easy to map your project directory to domain name. Lets get started...

Note: Iam assuming that you have Apache 2 installed on your machine.

Assumption: Let my current project is /var/www/mvc_project and I want to open it by domain name sjframework.com in my browser.

converting localhost to domain name in ubuntu


Step 1: Go to /etc/apache2/sites-enabled/

$ cd /etc/apache2/sites-enabled/

Step 2: Make copy of 000-default file.

$ sudo cp 000-default myproject

Step 3: Now open your newly created file i,e. myproject with your favorite text-editor and make following changes and save it.

$ sudo vim myproject

<VirtualHost *:80>
     ServerAdmin webmaster@localhost
     #add servername
     ServerName any_name_you_want
     #add domain name
     ServerAlias domain_name_you_want
     
     #specify your project directory
     DocumentRoot  /var/www/your_project_directory
     <Directory />
       Options FollowSymLinks
       AllowOverride All
    </Directory>

    <Directory  /var/www/your_project_directory>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>


apache sites-enabled file

Here is my 000-default and myproject files

apache configuration file in ubuntu

Step 4: Now open /etc/hosts file and add following line and save it.

$ sudo vim /etc/hosts

127.0.0.1 your_domain_name

ubuntu /etc/hosts file

Step 5: Restart apache server.

$ sudo service apache2 restart

Now open your project with your specified domain name

how to add domain name in apache2

Note : You can specify different domain name for different projects by creating different files in /etc/apache2/sites-enabled directory.

Note : This domain name is only local.

Hope you Enjoyed the Article :).


If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

20 comments:

  1. Thank you! It is advanced but simplify our works. And damn cool!

    ReplyDelete
  2. The same thing I wanted to learn, which you shared with us, really inspiring! http://www.lowhosting.com/bluehost-review/

    ReplyDelete
  3. How i can do the same with windows and xampp system?

    ReplyDelete
  4. This information is very helpful for me because you have shared great points about this concept. iPage Review

    ReplyDelete
  5. seems outdated cant find it in my version Apache 2.4.18

    ReplyDelete
  6. This post is great. What shall I do if I want this to be non-local and as decentralised as it can be?

    ReplyDelete
  7. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    python interview questions and answers
    python tutorials
    python course institute in electronic city

    ReplyDelete
  8. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    rpa training in chennai

    ReplyDelete
  9. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, keep on updates
    honor service centres in chennai
    honor service center velachery
    honor service center in vadapalani

    ReplyDelete
  10. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, keep on updates

    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

    AWS online training

    ReplyDelete
  11. Thanks for Sharing a Very Informative Post & I read Your Article & I must say that is very helpful post for us.
    Best RPA Training in Pune

    ReplyDelete
  12. I read this blog,Thanks for sharing this information.

    Machine learniing classes in Pune

    ReplyDelete
  13. very informative article.thank you for sharing.kepp up the good workAngular training in Chennai

    ReplyDelete
  14. Thanks for Sharing a Very Informative Post & I read Your Article & I must say that is very helpful post for us.
    Point cloud to 3D Model London
    Point cloud to 3D Model
    Reverse Engineering Services in London

    ReplyDelete
  15. Powerful paris dedicated server offering blazing speed, robust security, and 24/7 support for your online ventures. Elevate your server experience!

    ReplyDelete