Hello. I can't understand why the default site (index file) opens / var / www / html. I created my own config of the domain.name.conf type, here are these settings in it

 <VirtualHost *:80> ServerName domain.name ServerAlias www.domain.name ServerAdmin admin@example.com DocumentRoot /home/user/domain.name/public_html/public <Directory /home/user/domain.name/public_html/public> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined 

Then I turned it on sudo a2ensite domain.name.conf restarted Apache sudo service apache2 restart went by ip and the default site opens with 000-default.conf. Why? How to fix it?

  • one
    Disable default site: sudo a2dissite 000-default.conf - aleks.andr
  • one
    I go by ip - and it is necessary by name: http://domain.name - aleksandr barakin
  • @ aleks.andr thanks. Now I will try - Alex_01
  • @alexander barakin domain is not yet bound to server. By ip should also go the same - Alex_01
  • 2
    and this is a completely different question, which has been asked many times right on this site. // actually, the current question was asked many times, just everyone is too lazy to find a duplicate and mark. - aleksandr barakin

1 answer 1

This means that the configuration above already has VirtualHost for the IP and port you are accessing. Which one is higher is the priority.

Options: remove other virtual hosts if you do not need them; move the current above the rest (or corresponding to the Include directive, if it is so connected); contact by specific name, not by IP.