I know in Apache, there are virtual hosts. When a request is given, it goes and search between these virtual hosts to see if there are server name like request. It takes its option back like document root and others I have this file in /etc/httpd/sites-enabled
:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com/html
ErrorLog /var/www/example.com/log/error.log
CustomLog /var/www/example.com/log/requests.log combined
</VirtualHost>
I defined all directories as well like /var/www/example.com/html
and after all that, I have a file named /etc/httpd/conf
at its last line I added this code:
Include sites-enabled/*.conf
After that when I restart httpd it performs complete with no errors, but it doesn’t work and it goes to its default root. Where is the problem?
2
Answers
i solve it just with replacing star with my local ip in linux in virtualhost tag
after too many examination it works finally.there was no problem in other places.
Once you create a virtual host configuration file, in your example,
/etc/apache2/sites-available/example.com.conf
You need to use the command as super user
And then restart Apache:
You can tell what virtual hosts are up and running by the command: