1

After PC reboot, apache2 fails to start cause of missing directory /var/log/apache2/. And php doesn't work because '/var/log/suphp/` folder missing too.

So after reboot /var/log/ refreshes or something like that. How i can solve this?

What patch, update i should install, and how to avoid this commands after each PC reboot:

sudo mkdir /var/log/suphp/
sudo mkdir /var/log/apache2/

Update:

It is fresh Ubuntu Trusty install.

$ ls -l /var/
total 36
drwxr-xr-x  2 root root     4096 лис 14 03:54 backups
drwxr-xr-x 20 root root     4096 лис 13 23:52 cache
drwxrwsrwt  2 root whoopsie 4096 лис 14 17:44 crash
drwxr-xr-x 79 root root     4096 лис 14 18:32 lib
drwxrwsr-x  2 root staff    4096 кві 11  2014 local
lrwxrwxrwx  1 root root        9 лис 13 00:49 lock -> /run/lock
drwxr-xr-x  7 root root      320 лис 17 08:21 log
drwxrwsr-x  2 root mail     4096 лип 23 00:57 mail
drwxrwsrwt  2 root whoopsie 4096 лип 23 01:22 metrics
drwxr-xr-x  2 root root     4096 лип 23 00:57 opt
lrwxrwxrwx  1 root root        4 лис 13 00:49 run -> /run
drwxrwxrwt  4 root root       80 лис 17 08:12 spool
drwxrwxrwt  2 root root       40 лис 17 08:22 tmp
drwxr-xr-x  3 root root     4096 лис 13 23:37 www
$ ls -l /var/log
total 488
-rw-r--r-- 1 root root    216 лис 17 08:11 alternatives.log
-rw-r--r-- 1 root root   5666 лис 17 08:11 boot.log
drwxr-x--- 2 root lp      100 лис 17 08:12 cups
-rw-r--r-- 1 root adm   59843 лис 17 08:11 dmesg
-rw-r--r-- 1 root root      0 лис 17 08:11 dmesg.0
-rw-r--r-- 1 root root    910 лис 17 08:11 dpkg.log
-rw-r--r-- 1 root root   1626 лис 17 08:11 gpu-manager.log
drwx--x--x 2 root root    100 лис 17 08:11 lightdm
-rw-r--r-- 1 root root   2141 лис 17 08:11 pm-powersave.log
drwxr-xr-x 3 root root    160 лис 17 08:11 samba
-rw-r--r-- 1 root root 358058 лис 17 08:11 udev
-rw-r--r-- 1 root root  53242 лис 17 08:15 Xorg.0.log

Apache2 restart output

$ sudo service apache2 restart
[sudo] password for cosname: 
 * Restarting web server apache2                                         [fail] 
 * The apache2 configtest failed.
Output of config test was:
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /opt/cosname/conf/apache2/virtual-hosts.conf:1
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /etc/apache2/sites-enabled/000-default.conf:1
AH00014: Configuration check failed
Action 'configtest' failed.
The Apache error log may have more information.

After sudo mkdir /var/log/apache2/ && sudo service apache2 restart

$ cat /var/log/apache2/error.log 
[Mon Nov 17 08:18:41.263776 2014] [mpm_prefork:notice] [pid 4483] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Mon Nov 17 08:18:41.263845 2014] [core:notice] [pid 4483] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 17 08:18:45.027406 2014] [:error] [pid 4487] [client 127.0.0.1:49086] IOException in API_Linux_Logger.cpp:79: Could not open logfile /var/log/suphp/suphp.log
[Mon Nov 17 08:18:45.027471 2014] [core:error] [pid 4487] [client 127.0.0.1:49086] End of script output before headers: index.php

suPHP is enabled, and hasn't own log directory again after reboot. sudo mkdir /var/log/suphp/ solves it for current PC session

2 Answers 2

2

Normally, you should not need to create directories for logging as the loggers should take care of creating those directories automatically. Try reinstalling apache2 as a root. I am not sure about why PHP complains.

Update (after reading updated question):

The problem is not permissions as I doubted. It resembles with the one in here: http://pcduino.com/forum/index.php?topic=3838.0. Also has a solution in it.

Add the entry to recreate those directories in /etc/rc.local file. Hope it resolves your problem.

4
  • The thing is it erases those directories after reboot. Why? Re-install didn't helped. Nov 16, 2014 at 12:05
  • Are the files / folders in the /var/log directory not owned by root? Can you show the output of "ls -l /var/log"?
    – Horizon
    Nov 16, 2014 at 17:48
  • I just updated the question. Please review. Nov 17, 2014 at 6:24
  • Actually adding start commands in rc.local (or anywhere else where it can be) will help. So i mark is as a resolve. Though i don`t use apache directly anymore. Viva containers and automation tools. ;D Dec 7, 2016 at 1:04
0

Change the owner of /var/log/apache2 as you are logged in as root.

chown -R $USER:$USER /var/log/apache2

That will do the trick.

1
  • I cant use chown` on folder that is not existing. Dec 7, 2016 at 1:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .