0

This question already has an answer here:

My Task : The domain www.mynewsite.lk is configured and hosted in a hosting server with the IP address 192.168.1.100. Another domain called www.mysite.lk should also be configured with the same content without any duplication. Here I want to configure the Apache server with name-based virtual hosting.

First of all I Created directory which contains the file of my site and add 'home.html' file.

sudo mkdir /var/www/website
sudo vim /var/www/website/home.html

After I created new virtual host file as default.conf in /etc/apache2/sites-available folder and it is look like

<VirtualHost 192.168.1.100>
     ServerAdmin webmast@new.lk
     DocumentRoot /var/www/website
     DirectoryIndex home.html
     ServerName www.mynewsite.lk
     Serveralias www.mysite.lk
     ErrorLog /var/log/error/website/error.log
     CustomLog combined
</VirtualHost>

Next I created directories to hold 'Error.log'

    sudo mkdir /var/log/error
    sudo mkdir /var/log/error/website

Then I set the DNS using sudo vim /etc/hosts and I added following line that file

    192.168.1.100 www.mysite.lk www.mynewsite.lk

After I enabled the default.conf file that I created using sudo a2ensite default.conf command

Then I run the this command

sudo ifconfig vmnet0: 192.168.1.100 netmask 255.255.255.0 up

And last I reloaded the apache server using sudo /etc/init.d/apache2 reload command

I had an error as Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.

what do I do to make this error...? Please help me to complete my task. Is there an any error I created .conf <VirtualHost> ...?

marked as duplicate by Eric Carvalho, Videonauth, saji89, Wild Man, Luís de Sousa Jul 14 '16 at 15:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I tried using that one. But I can't solve my error... – Nuwan Samarasinghe Jul 7 '16 at 19:52
  • Solution would not be only re-installation of apache2, it might be configuration error. I had also the same issue. Remove & reinstall apache2 didn't solve my problem but when i reinstall libapache2-mod-mono, i got to know that i mis configured one file & it was simple grammatical error. – d a i s y Jul 8 '16 at 3:58
  • Error says itself that See 'systemctl status apache2.service' and 'journalctl -xn' for details. Did you try it? – d a i s y Jul 8 '16 at 4:02
0

I was able to solve my error changing default.conf file in /etc/apache2/sites-available folder and creating directories to hold 'Access.log' file.

So I created VirtualHost last line CustomLog combined changed as CustomLog /var/log/access/website/access.log combined

Then default.conf file was as follows...

<VirtualHost 192.168.1.100>
     ServerAdmin webmast@new.lk
     DocumentRoot /var/www/website
     DirectoryIndex home.html
     ServerName www.mynewsite.lk
     Serveralias www.mysite.lk
     ErrorLog /var/log/error/website/error.log
     CustomLog /var/log/access/website/access.log combined
</VirtualHost>

And I made directories to hold 'Access.log'

sudo mkdir /var/log/access
sudo mkdir /var/log/access/website 

Then I could 'reload/start' my apache server without any errors. And I was able to run my home.html file using www.mynewsite.lk and www.mysite.lk which I created 'Virtual Host' links.

Not the answer you're looking for? Browse other questions tagged or ask your own question.