I am trying to establish a second virtual server. The file /etc/sites-available/000-default.conf left unchanged. Created a test.com.conf file:

 <VirtualHost test.com:80> ServerName test.com ServerAlias www.test.com ServerAdmin jumpjet68@gmail.com DocumentRoot /var/www/test.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

created a directory /var/www/test.com/public_html and in it a simple HTML file with one phrase It's works! Did not forget about the team

 a2ensite test.com.conf 

Added to hosts file -

 127.0.0.1 test.com 

It seems to have done everything, but when I try to go to test.com a standard Apachev stub appears from / var / www / html instead of my page from /var/www/test.com/public_html

What did I forget to correct?

  • one
    $ sudo service apache2 restart not forgot to do? - aleksandr barakin
  • one
    IMHO for logs it is better to start separate files for hosts, for example - ErrorLog $ {APACHE_LOG_DIR} /test.com.error.log - korytoff
  • @alexanderbarakin yes, the restart is done after all changes. What is the difference between this command and service apache2 reload? Without sudo and. What do you need to write in the <VirtualHost *: 80> tag? Some instructions write 127.0.0.1, and some *: 80 - aryndin
  • 1. reload - reread configuration files without restarting processes. in some cases this is not enough. 2. sudo is used to execute a command on behalf of another user (by default - root ). 3. “by the rules” you need to write what is required. see “rules”, i.e., documentation. in your case it would be better to write * , not a domain name. - aleksandr barakin 5:26
  • @alexanderbarakin 2. I meant that service apache2 reload works without sudo, which is strange. By the way, about the problem, it seems the whole thing is that the settings from the hosts do not apply immediately - after a few minutes the page has opened, but now Forbidden on this server. - aryndin

0