I have ubuntu 12.04 with apache. The localhost was working fine. But today I wanted to setup a virtual host. After setting virtual host I just made restart server by doing this command sudo /etc/init.d/apache2 restart it showed me error like

    apache2: Syntax error on line 237 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/testsite.com: No such file or directory
    Action 'configtest' failed.

The Apache error log may have more information.

I don't know whats the error I have tried to solve the error by going through google. But I can't solve this.

Here is the default file for apache2 configuration located in (/etc/apache2/sites-available) ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
    Options FollowSymLinks
    AllowOverride All
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride All
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from ::1/128

Now when I am opening localhost on my browser then it is showing Oops! Google Chrome could not connect to localhost

  • Sorry by why do you add the default file from sites-enabled when it is "line 237 of /etc/apache2/apache2.conf" that is complaning about "/etc/apache2/sites-enabled/testsite.com" and a "testconfig" option? I would believe those to be more interesting? – Rinzwind Jul 28 '14 at 9:43

You'll have to remove the what appears to be a bogus link from your /etc/apache2/sites-enabled file.

You can do this with:

$ sudo rm /etc/apache2/sites-enabled/testsite.com
| improve this answer | |

I would suggest removing the site (sudo a2dissite testsite.com), then restart apache, then enable the site (sudo a2ensite testsite.com), and restart again. (sudo service apache2 restart)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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