Mera Byte

A Byte of My World

3 notes

Development Environment on Linux

Ok so we are going to create our own development environment. What this basically means is our own site on localhost. Let’s call our site http://mysite/ Within this file will contain all our files (index.hml). Follow the following steps to achieve this.

  • Firstly, you need to edit your hosts file. The hosts file on linux located in your etc folder. Start your terminal and type the following code. Open the file in a text editor. I am using vim.
    vim /etc/hosts. and then enter the following line in the file.
    127.0.0.1 mysite
  • Now you need to enter your site that you entered in your apache config. Create a file within the
    vim /etc/apache2/sites-available/mysite
    This will create a mysite file. Now enter the following code within it. Before doing this, create a folder within the
    /var/www/mysite/
    Within this folder, create a index.html and enter anything.
<VirtualHost *:80>
        ServerAdmin your@email.com
        ServerName mysite

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

</VirtualHost>

This site is now registered in your apache. Now just enable the site and restart apache by the following code.

me@me:~$ a2ensite mysite
me@me:~$ service apache2 restart

That is it. Oh and btw if you want to setup a develop a similar environment on Windows. Check this post.

For removing such a similar environment

First, remove the line that contains the domain name you want to remove from the
vim /etc/hosts

Second, you need to delete the apache config file by using the following command
rm -rf /etc/apache2/sites-available/mysite. This will remove the configs for the specified domain name. Then, you need to disable the site like
me@me:~$ a2dissite mysite
and then finally restart apache
me@me:~$ service apache2 restart
That’s it for removing a domain.

Filed under linux apache

  1. wactbprot reblogged this from vivekipedia
  2. vivekipedia posted this