Question

Vhosts does not work

my conf:

<VirtualHost *:80> ServerName test.com DocumentRoot “/var/www/somedir1/” UseCanonicalName Off ErrorLog logs/test.com-error.log CustomLog logs/test.com-access.log combined env=!dontlog </VirtualHost> ############################################################################ <VirtualHost *:80> ServerName test2.com DocumentRoot “/var/www/test2.com/” UseCanonicalName Off ErrorLog logs/test2.com-error.log CustomLog logs/test2.com-access.log combined env=!dontlog </VirtualHost> #############################################################################

and i still get a welcome page, apache 2.4.6


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

this issue was solved, the issue was in cloudflare SSL method.

thanks.

If you’re running a PHP website like Wordpress, then make a configuration like this for each domain.

domain1.com.conf domain2.com.conf

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin webmaster@example.com
  ServerName  example.com
  ServerAlias www.example.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/example.com/public_html
  <Directory /var/www/html/example.com/public_html>
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
  </Directory>
  
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/example.com/log/error.log
  CustomLog /var/www/html/example.com/log/access.log combined
</VirtualHost>

To enable the configuration: sudo a2ensite doamin.com.conf, then restart the apache service.

run this sudo a2enmode rewrite to enable rewrite rules.

Hi @mfadeyev,

Please set the virtualhost for your website test.com like so:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName your_domain
    ServerAlias www.your_domain
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

You’ll need to change the relevant paths. Additionally, please remove UseCanonicalName Off It should work without it properly.

One other thing, have you created separate configuration files for both domains like so sudo nano /etc/apache2/sites-available/your_domain.conf

Where your_domain.conf is your actual domain?

You’ll need to enable the website afterwards as well like so :

sudo a2ensite your_domain.conf

Regards, KDSys