Since you don't have Apache installed and functionally working, you don't need the /etc/apache2
directory where all the configuration files are stored.
You also mentioned that you used touch
to create an apache.conf
file. That is very problematic because there are defaults and settings that need to be specified in the conf
file, which is missed by creating a blank file.
Apache will work when installed from the repository. It will create all the necessary files and actually start the server when installed.
Remove what you have, then perform a fresh install from the repository.
Remove and purge the current installation:
$ sudo apt-get remove --purge apache2 libapache2-mod-php
$ sudo apt autoremove
$ sudo apt-get remove --purge apache2 libapache2-mod-php
You may have to cycle through those two commands more than once. It'll be clean when the last command's output resembles:
apollo@testnode2:~$ sudo apt-get remove --purge apache2 libapache2-mod-php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'libapache2-mod-php' is not installed, so not removed
Package 'apache2' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Now remove faulty configuration files that may not be overwritten in a fresh install. Remove or rename the /etc/apache2
folder:
$ sudo mv /etc/apache2/ /etc/apache2.old
Now install Apache2 fresh with:
$ sudo apt-get install apache2 libapache2-mod-php
If you have settings from your old settings that you want to incorporate into the new installation, you can copy the difference to the new /etc/apache2
directory. Making step-by-step changes might help you to identify where you went wrong the first time.
Put your site's configuration files into a VirtualHost
Also, I recommend that you leave the /etc/apache2/sites-available/000-default.conf
file intact. Make a new virtual host file to contain your desired configuration. Just copy the 000-default.conf
to a mysite.conf
file, then enable this virtual host with the command:
$ sudo a2ensite mysite.conf
This way if there is a problem with your configuration file, you can just disable it with a2dissite mysite.conf
while you fix it. Apache won't be broken in the meantime. You'll also retain the 000-default.conf
as a template for a working reference.
The key to a virtualhost
configuraiton is the ServerName
directive. Accessing your site by that name will call that specific configuration.
Starting, Stoping, and checking the Apache2 server
You shouldn't try to start the Apache2 server by running the /usr/bin/apache2
command. The server should be started with a script to set all the needed variables.
You can start
, stop
, and check the status
of the Apache2 server with one of these commands:
$ sudo systemctl stop apache2
$ sudo systemctl start apache2
$ sudo systemctl status apache2