We can first configure vhost and then install TYPO3 as well.
Here i am using Apache as a Web Server.
In Ubuntu i've set web drectory (WWW) to /home/nirmalya/Public/ instead of /var/www/html/
So i will explain the configuration steps accordingly.
Say, my TYPO3 installation is here in /home/nirmalya/Public/t7610.local where "t7610.local" is root directory of TYPO3.
i.e. In browser http://localhost/t7610.local/ should be http://t7610.local/
For better understanding and to remember i've divided this into 4 steps. I'll try to concise it as well.
To edit files i've used gedit instead of nano editor.
1. Create & Update Conf file for Apache:
Execute this command from your Shell to crate a new configuration file for thw sub-domain.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/t7610.local.conf
After copying the default conf file we need to edit this conf file with this command
sudo gedit /etc/apache2/sites-available/t7610.local.conf
Add the necessary configuration lines inside this file.
At the end it should look like
-------------------
<VirtualHost *:80>
ServerAdmin myemail@gmail.com
ServerName t7610.local
DocumentRoot /home/nirmalya/Public/t7610.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
-------------------
2. Symlink the conf file for Apache:
Now i'll create a symlink to t7610.local.conf file by executing command like this
sudo a2ensite t7610.local.conf
or
sudo ln -s /etc/apache2/sites-available/t7610.local.conf /etc/apache2/sites-enabled/t7610.local.conf
3. Update in hosts file:
Update the hosts file with the new domain entry
So execute this command from your Shell
sudo gedit /etc/hosts/
and add the line below at the end of the file
127.0.0.1 t7610.local
Considering that 172.0.0.1 is your local IP Address.
Never ever forget to Re-start the Apache web server ;)
So, please execute this Shell command
sudo service apache2 restart
Now in your browser type http://t7610.local/ and your website will now available in this sub-domain.