I have a Pi 3 and just installed Apache and PHP via this link
sudo apt-get install apache2 -y
sudo apt-get install php5 libapache2-mod-php5 -y
The Apache server turned on with no problems and I was able to load PHP pages. Very good. Normally when I go through these tutorials to setup a webserver they also suggest how to add the web server to the startup on reboot. (I am more used to running web servers on top of VM's)
This tutorial didn't suggest anything like that so I assume it was included in the process of the installation commands above.
So I reboot the Pi and apache doesn't load.
I checked this out:
sudo service --status-all
And got:
[ - ] apache2
I then decided to make sure it wasn't a load on boot error, but check to see if it can load at all.
So I run this:
sudo /etc/init.d/apache2 start
And get:
[....] Starting apache2 (via systemctl): apache2.serviceJob for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details.
failed!
It doesn't matter if I run sudo /etc/init.d/apache2 stop
beforehand either.
So it looks like I cannot start up apache2 at all. It's pretty much a blank copy of Raspbian that I downloaded yesterday.
I looked online and most of the issues with starting Apache2 seem to be because of misconfigured virtual hosts.
My virtual hosts look ok, I think, they worked first time after Apache2 installed and I made no changes to them.
/etc/apache2/sites-available $ ls
000-default.conf default-ssl.conf
000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
And then I tried this:
$ tail /var/log/syslog
Apr 23 10:12:23 darkstar systemd[1]: Failed to start LSB: Apache2 web server.
Apr 23 10:12:23 darkstar systemd[1]: Unit apache2.service entered failed state.
Apr 23 10:13:14 darkstar rsyslogd-2007: action 'action 17' suspended, next retry is Sat Apr 23 10:13:44 2016 [try http://www.rsyslog.com/e/2007 ]
Apr 23 10:13:14 darkstar systemd[1]: Stopped LSB: Apache2 web server.
Apr 23 10:13:20 darkstar systemd[1]: Stopped LSB: Apache2 web server.
Apr 23 10:17:01 darkstar rsyslogd-2007: action 'action 17' suspended, next retry is Sat Apr 23 10:17:31 2016 [try http://www.rsyslog.com/e/2007 ]
Apr 23 10:17:01 darkstar CRON[2398]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Apr 23 10:17:36 darkstar systemd[1]: Starting Cleanup of Temporary Directories...
Apr 23 10:17:36 darkstar rsyslogd-2007: action 'action 17' suspended, next retry is Sat Apr 23 10:18:06 2016 [try http://www.rsyslog.com/e/2007 ]
Apr 23 10:17:36 darkstar systemd[1]: Started Cleanup of Temporary Directories.
EDIT 1
It seems that this error is because of the log folder being mounted to tmpfs
. I setup tmpfs
during the installation steps yesterday as a way to stop SD card rot.