Finally, I solved the problem of installing php5 and libapache2-mod-php5 as follows: sudo apt-get install php5 libapache2-mod-php5 - @ziiweb
The error you received is usually caused by missing or corrupt configuration files.
The operation for apache2.service failed because the management process failed with an error code. See "Systemctl status apache2.service" and "journalctl -xe" for details.
You can use the journalctl command for more information.
$ journalctl | tail AH00526: Syntax error on line 5 of /etc/apache2/sites-enabled/mydomain-wsf.lan.conf
You can also run the Apache configuration test.
$ apachectl configtest Syntax OK $ sed -i 's/SetEnv/SetEnvFoobar/' /etc/apache2/sites-enabled/test.conf $ apachectl configtest AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/test.conf: Invalid command 'SetEnvFoobar', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed. The Apache error log may have more information.
The apachectl graceful also very useful. It restarts Apache, but first runs configuretest "before starting the restart, to make sure Apache is not dying.
apachectl graceful
Gracefully restarts the Apache httpd daemon. If the daemon is not running, it starts. This differs from a normal restart in that currently open connections are not interrupted. A side effect is that old log files will not be closed immediately. This means that if used to rotate the log of a script, a significant delay may be required to ensure that old log files are closed before being processed. This command automatically checks the configuration files as in configtest before starting the restart to make sure Apache is not dying. This is equivalent to apachectl -k graceful
- Apache Docs
Reinstalling the software may work as it fixes any missing configuration files.
$ apt-get install
Another alternative mentioned here is to clean and then install. It is very important to know that purge is a destructive command, meaning that it will delete all existing configuration files. This is pretty much the equivalent of a new installation.
$ apt-get purge libapache2-mod-php5 php5 $ apt-get install libapache2-mod-php5 php5
source share