-2

I have created apache virtual host as in the link:

 [set up apache virtual hosts ][1]
 https://www.youtube.com/watch?v=Vd2aLTZDLQg

But i am not able access the web page from google . I tried out following link also but it also didnt worked

 [how to create virtual host on apache][1]
 https://www.youtube.com/watch?v=PaEs4-3Rrok

Please suggest what i do wrong why the virtual host not working

Learner
  • 453
  • 13
  • 29

1 Answers1

0

I'm trying to help you by giving a resume of steps you need to do to make your virtual host working. Make your own changes to adapt it with your project (name, location...etc)

  • I suppose that you have a running website which you can access it using http://127.0.0.1/example.com

  • I suppose that you want to create a virtual host to access it using http://example.dev

  • I suppose that the folder "example.com" is under "/var/www/"

  • I suppose that you are working on Ubuntu (or using a Windows 10 Ubuntu Bash)

Step 1

sudo nano etc/apache2/sites-available/example.com.conf

Copy/paste the following content inside it:

<VirtualHost *:80>
    ServerName www.example.dev
    ServerAlias example.dev
    ServerAdmin changeThisWithYourEmail
    DocumentRoot /var/www/example.com/
    DirectoryIndex index.php
    <Directory "/var/www/dev">
        Options Multiviews FollowSymLinks
        MultiviewsMatch Any
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined
</VirtualHost>

Step 2

sudo a2ensite example.com.conf

Step 3

sudo nano /etc/hosts

and then add this line at the end of the file:

127.0.1.1   example.dev

Step 4

sudo service apache2 restart

Step 5

Check if http://example.dev is showing the same result as http://example.com

Ala Eddine JEBALI
  • 7,033
  • 6
  • 46
  • 65