Tuesday, August 30, 2022

[SOLVED] Apache default root doesn't change for my domain in linux server

Issue

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?


Solution

i solve it just with replacing star with my local ip in linux in virtualhost tag

<VirtualHost ip:80>

after too many examination it works finally.there was no problem in other places.



Answered By - sina-sharifi
Answer Checked By - Marilyn (WPSolving Volunteer)