Setting up Apache Properly
Posted: February 17th, 2009 | Author: admin | Filed under: linux, software, web | Comments OffSo we should have just installed the apache package using apt-get. Apache will run by itself automatically and by rights shouldn’t need anything doing to it. However, when we restart, the read-only file system will cause Apache to fail as it cannot write to it’s log files. Apache will also through up another error:
Could not reliably determine the fully qualified domain name...
Both of these problems can be fixed relatively easily. Lets look at the log files first.
Changing the log file
Voyage is set up pretty well, it has a small read/write portion that can be used and log files will work if they are in the /var/log folder. They have to be in this folder and not inside another folder within /var/log. By default the apache log files are as follows:
ErrorLog /var/log/apache2/error.log
/etc/apache2
We can use nano to edit the following files; apache2.conf & sites-available/default. Within these files we need to search for all cases of .log as there are more than one type! Nano can search by typing [ctrl]+[w]. Search for .log and replace any occurrences (I had three!) The replacement strings are below:
In apache2.conf
ErrorLog /var/log/apache2error.log
In sites-available/default
ErrorLog /var/log/apache2error.log CustomLog /var/log/apache2access.log combined
That should fix the error log problem, now for the fqdm (Fully Qualified Domain Name) issue.
Setting up hosts
The first thing we need to do whilst we are still in the apache2 folder, nano httpd.conf then we need to add a couple of lines:
ServerSignature Off ServerTokens production ServerName RobotYacht
The first two lines tighten up Apache’s security and make sure it doesn’t give out too much information. The last line tells apache what the server is called which seems to make it much happier!
Now we need to edit or create a hosts file. My installation of voyage didn’t include a hosts file so i needed to make one! The hosts file lives in /etc so we need to change directory. Then we create or edit the existing file by typing
nano hosts
We now just need to add a couple of lines (replace robotyacht with the hostname you set!)
localhost.robotyacht localhost 127.0.0.1 localhost.robotyacht localhost
Now just save and next time you reboot, apache should run like a dream!