20 Dec
Virtual hosting can be useful if you want to host multiple websites and domains from a single physical server or VPS. Follow the following steps for creating the virtual host in Ubuntu.
Step 1: Navigate to Apache folder sudo cp /etc/apache2
Step 2: In sites-available folder create conf file with your host name for eg: myVhost.conf
Step 3: Edit your conf file with below code:
<VirtualHost *:80> ServerName myVhost.test ServerAlias www.myVhost.test ServerAdmin [email protected] DocumentRoot /var/www/html/Laraval/abcproject <Directory /var/www/html/Laraval/abcproject> Options -Indexes +FollowSymLinks AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/myVhost.test-error.log CustomLog ${APACHE_LOG_DIR}/myVhost.test-access.log combined </VirtualHost>
Step 4: Add below line in hosts file
sudo nano /etc/hosts
127.0.0.1 www.myVhost.test
save and close
Step 5: Enable site and the rewrite mode:
$sudo a2enmod rewrite $sudo a2ensite myVhost.conf
Step 6: Restart the server:
$sudo service apache2 restart
Step 7: Open the browser:
http://www.myVhost.test:8000
or any other specified port.
Latest posts by Amit Yadav (see all)
- 7 Simple Steps to Create Apache Virtual Host in Ubuntu - December 20, 2021