changing Servername on Apache

Asked by Kinuthia

Hi,
I have installed Apache2.2. I want to change the servername but apparently I cannot. What I am doing is editing the file /etc/apache 2/sites-enabled/000-default and adding www.my_name.com:80 as an argument to NameVirtualHost. When I restart the server it responds by 'No Address associated with hostname. Could not resolve hostname www.my_name.com '. When I try to add an address it says Namevirtualhost takes only one argument, a numeric address or a hostname !
Somebody to the rescue ?
  Thanks in advance!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Kinuthia
Solved:
Last query:
Last reply:
Revision history for this message
Bhavani Shankar (bhavi) said :
#1

Hello kinuthia...

Edit the file httpd.conf with a text editor.

Its under /etc/apache2 directory

sudo gedit /etc/apache2/apache2.conf

(ubuntu equivalent of httpd.conf)

First search the file for a ServerName field by the following command in a terminal:

grep -nr 'ServerName' /etc/apache2

There are several places (I think) will need to be changed, so scroll down slowly, and everywhere you see
the incorrect server name, change it to the correct server name

Hope this helps.

Bhavani Shankar.

Revision history for this message
Kinuthia (qmuchane) said :
#2

Bhavani,

Hello, we meet yet again and firstly, I would like to thank you for
sparing your time to help.I am very grateful.

For one, there is nothing to edit in /etc/apache2/httpd because it is
EMPTY. The README of the apache2-doc confirms that.The main
configuration file it says is /etc/apache2/apache2.conf which does not
contain any ServerName, it only has includes which point to among other
things the virtual host configuration
file /etc/apache2/sites-enbaled/000-default. This is the file I am
trying to edit the NameVirtualHost to include www.kinuthia.com:80.
When I make other changes in the file they work,like changing the
default site is working well.Hmmmmm... but the ServerName ,I am still
stuck with 127.0.0.1...

Thanks.

On Tue, 2008-04-08 at 11:46 +0000, Bhavani Shankar wrote:
> Your question #29217 on Ubuntu changed:
> https://answers.edge.launchpad.net/ubuntu/+question/29217
>
> Status: Open => Answered
>
> Bhavani Shankar proposed the following answer:
> Hello kinuthia...
>
> Edit the file httpd.conf with a text editor.
>
> Its under /etc/apache2 directory
>
> sudo gedit /etc/apache2/apache2.conf
>
> (ubuntu equivalent of httpd.conf)
>
> First search the file for a ServerName field by the following command in
> a terminal:
>
> grep -nr 'ServerName' /etc/apache2
>
> There are several places (I think) will need to be changed, so scroll down slowly, and everywhere you see
> the incorrect server name, change it to the correct server name
>
> Hope this helps.
>
> Bhavani Shankar.
>

Revision history for this message
M Hickford (hickford) said :
#3

kinuthia, create and either the file /etc/apache2/httpd.conf or /etc/apache2/apache2.conf

and find/add a line
ServerName ma123.trin.private.cam.ac.uk

if this the address of your server. the servername directive is not required, it is acceptable to leave it empty, and apache will get it from context
see
http://httpd.apache.org/docs/2.0/mod/core.html#servername

Matt

Revision history for this message
Kinuthia (qmuchane) said :
#4

Matt,

Call me silly billy but I did not get exactly what you said.
I am rummaging through the documentation but I cannot not seem to be
able to change the ServerName.
Thanks,
Kinuthia.
On Tue, 2008-04-08 at 13:35 +0000, Matt H wrote:
> Your question #29217 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/29217
>
> Status: Open => Answered
>
> Matt H proposed the following answer:
> kinuthia, create and either the file /etc/apache2/httpd.conf or
> /etc/apache2/apache2.conf
>
> and find/add a line
> ServerName ma123.trin.private.cam.ac.uk
>
> if this the address of your server. the servername directive is not required, it is acceptable to leave it empty, and apache will get it from context
> see
> http://httpd.apache.org/docs/2.0/mod/core.html#servername
>
> Matt
>

Revision history for this message
Bhavani Shankar (bhavi) said :
#5

+1 Matt H

Create a file if you dont have one.. and put in the server name and save the file....

Revision history for this message
Kinuthia (qmuchane) said :
#6

Bhavani,

Hello...
I edited the /etc/apache2/httpd.conf to :

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
 ServerName www.kinuthia.com
 ServerAlias kinuthia.com
 ServerAdmin <email address hidden>
 DocumentRoot /home/kinuthia/www/

 <Directory />
  Options FollowSymLinks
  AllowOverride None
 </Directory>

 <Directory /home/kinuthia/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
 </Directory>
</VirtualHost>

When I restart the server through sudo /etc/init.d/apache2 restart it
responds:

* Restarting web server apache2
        apache2: apr_sockaddr_info_get() failed for tchane
        apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
        apache2: apr_sockaddr_info_get() failed for tchane
        apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                                                 [ OK ]
        'tchane' is the name I gave the computer.

Thanks!
Kinuthia.

>
On Wed, 2008-04-09 at 01:48 +0000, Bhavani Shankar wrote:
> Your question #29217 on Ubuntu changed:
> https://answers.edge.launchpad.net/ubuntu/+question/29217
>
> Status: Open => Answered
>
> Bhavani Shankar proposed the following answer:
> +1 Matt H
>
> Create a file if you dont have one.. and put in the server name and save
> the file....
>

Revision history for this message
M Hickford (hickford) said :
#7

Kinuthia

I believe the following options are global, and belong outside the <virtualhost> element.

 ServerName www.kinuthia.com
 ServerAlias kinuthia.com
 ServerAdmin <email address hidden>
 DocumentRoot /home/kinuthia/www/

Revision history for this message
Kinuthia (qmuchane) said :
#8

I managed to get it finally. I created a file under sites -available called kinuthia_site. This is the one I linked to sites-enabled with the command a2ensite and I was good to go... but wait a minute, I had to create an alias for the loopback IP in the /etc/hosts file using the very ServerName I used in the kinuthia_site configuration file.

To all those who aided me in one way or other thank you, I could not have done without you...