17

I have just upgraded my Ubuntu 13.10 and apache2 is not working. When I try to start the apache2 server it is printing following errors:

 * Starting web server apache2
 * The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 263 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/conf.d/: No such file or directory
Action 'configtest' failed.
kiri
  • 28,246
  • 16
  • 81
  • 118
Sundar Elumalai
  • 171
  • 1
  • 1
  • 3

8 Answers8

13

It was the same for me. After I created the conf.d folder still Apache 2 won't start. I was able to solve like this:

Replacing this line

LockFile ${APACHE_LOCK_DIR}/accept.lock

with this one

Mutex file:${APACHE_LOCK_DIR} default

in /etc/apache2/apache2.conf solved the problem.

(source)

David Foerster
  • 36,264
  • 56
  • 94
  • 147
reloj
  • 131
  • Same problem, but not sure it was after the update or adding Xfce environment, also worked for me. Thanks. – mins Apr 02 '14 at 19:34
9

When creating symbolic links make sure to use absolute paths

Instead of:

ln -s ./conf-available/mysite.conf ./conf-enabled/mysite.conf

You should use :

ln -s /etc/apache2/conf-available/mysite.conf /etc/apache2/conf-enabled/mysite.conf
David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • 1
    A relative path from the available directory does it as well (and is how Apache sets up the initial symlinks itself): cd conf-enabled, then ln -s ../conf-avialable/mysite.conf mysite.conf – Martin Ender Oct 22 '15 at 16:18
5

Perform a mkdir -p /etc/apache2/conf.d/. So the folder conf.d is created. Your apache2.conf file includes all files in this folder into the configuratin, and if this folder doesn't exist it run into an error. See:

user@host:~$ grep conf.d /etc/apache2/apache2.conf
Include conf.d/
chaos
  • 27,506
  • 12
  • 74
  • 77
2

For me there was and invalid shortcut inside the sites-enabled folder. Once I deleted that I could easily restart/reload apache.

eVagabond
  • 282
0

Here is my full answer to the error :

  • Restarting web server apache2 [fail]
    1. The apache2 configtest failed. Output of config test was: apache2: Syntax error on line 214 of /etc/apache2/apache2.conf: Could not open c onfiguration file /etc/apache2/httpd.conf: No such file or directory Action 'configtest' failed. The Apache error log may have more information.
  1. Run command sudo mkdir conf.d
  2. Run command sudo touch httpd.conf
  3. Run command sudo vi apache2.confand replace

LockFile ${APACHE_LOCK_DIR}/accept.lock

by

Mutex file:${APACHE_LOCK_DIR} default

  1. Save and restart apache

Many thanks to all for you very good advice

Best regards

Dunbo

Dunbo
  • 1
0

I also had this same problem with apache.
apache2: Syntax error on line 220 of /etc/apache2/apache2.conf: Could not open file configuration /etc/apache2/sites-enabled/000-default.conf: No such file or directory

Any consideration we are in the /etc/apache2

I solved this:
1- Knowing sites-enabled/000-default.conf is a link that points to site-available/000-default.conf, I went to check the content of sites-availables file; And to my surprise, 000-default.conf is replaced by 000-default.conf ~ (because of gedit which always creates a backup)

2- Automatically I copy the file
$ sudo cp -v-default.conf 000 ~ 000-default.conf

3- Restart apache2
$ sudo /etc/init.d/apache2 restart

4- My server is started

yanko
  • 105
0

Please use the below commands

sudo mkdir /etc/apache2/conf.d

Reinstall the packages.

Create symbolic links

ln -s /etc/websvn/apache.conf /etc/apache2/conf-available/websvn.conf

Enable the websvn configuration using below command.

sudo a2enconf websvn.conf

Enable the dav and dav_svn modules

sudo a2enmod dav
sudo a2enmod dav_svn
sudo service apache2 reload
dufte
  • 13,272
  • 5
  • 39
  • 43
0

I know this is an old thread, but I ran into this today and had forgotten how I fixed it a few years ago.

In addition to replacing:

LockFile ${APACHE_LOCK_DIR}/accept.lock

with

Mutex file:${APACHE_LOCK_DIR} default

in the /etc/apache2/apache2.conf file, I also had to manually create the httpd.conf file in the /etc/apache2/ directory.

David Foerster
  • 36,264
  • 56
  • 94
  • 147