PDA

View Full Version : [ubuntu] How to set ServerName in Apache2?



zhanjh
May 9th, 2009, 11:38 AM
I've added these in the file /etc/apache2/httpd.conf

<VirtualHost *>
ServerName zhanjh_server
DocumentRoot /var/www
<Directory /var/www>
AllowOverride All
Options All
</Directory>
</VirtualHost>

But when I reload or restart the apache2 I still got this:

* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName

Thank you!

spiderbatdad
May 9th, 2009, 12:10 PM
also put ServerName above the document root section in /etc/apache2/sites-available/default...or whatever virtual host you are using.

zhanjh
May 9th, 2009, 12:33 PM
I added the servername in the /etc/apache2/sites-available/default.But still not working.

/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster@localhost

ServerName zhanjh_server
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
.....
</VirtualHost>

windependence
May 9th, 2009, 12:48 PM
Make sure your /etc/hosts has an entry for itself. Also, make sure your box name IS what you are trying to set it to in Apache. What is the return of the hostname command with no parameters?

-Tim

zhanjh
May 9th, 2009, 03:31 PM
Thank you Spiderbatdad and Windependence.Without your help I cannot resolve it.

But I got a new problem. I found the error message in /var/log/apache2/error.log:
[Sat May 09 22:27:58 2009] [notice] caught SIGTERM, shutting down
[Sat May 09 22:27:59 2009] [notice] Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch configured -- resuming normal operations

-------------------------------------------------------------
PS:
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster@localhost

ServerName zhanjh.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
....
</VirtualHost>

/etc/hosts:
127.0.0.1 zhanjh.com localhost.localdomain localhost
127.0.1.1 zhanjh.com

/etc/hostname:
zhanjh.com

daboroe
May 9th, 2009, 05:32 PM
Thank you Spiderbatdad and Windependence.Without your help I cannot resolve it.

But I got a new problem. I found the error message in /var/log/apache2/error.log:
[Sat May 09 22:27:58 2009] [notice] caught SIGTERM, shutting down
[Sat May 09 22:27:59 2009] [notice] Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch configured -- resuming normal operations

-------------------------------------------------------------
PS:
/etc/apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin webmaster@localhost

ServerName zhanjh.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
....
</VirtualHost>

/etc/hosts:
127.0.0.1 zhanjh.com localhost.localdomain localhost
127.0.1.1 zhanjh.com

/etc/hostname:
zhanjh.com

How I took some replies it should be this but I might be misunderstanding them as well



ServerName zhanjh.com
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
....
</VirtualHost>

zhanjh
May 10th, 2009, 01:02 AM
Hello daboroe, do you mean put the "ServerName" at the top of the file "/etc/apache2/sites-available/default". I've tried it ,the result turned out to be no differences.

:o I thought the first problem have already be fixed. But I got another new one.

This is the error message in the /var/log/apache2/error.log:



[Sat May 09 22:27:58 2009] [notice] caught SIGTERM, shutting down
[Sat May 09 22:27:59 2009] [notice] Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch configured -- resuming normal operations

should I just ignore it?

ktritty
May 11th, 2009, 03:10 AM
I had a similar problem. I changed /etc/hosts so that the IP address matched that of my server. Then, I had to tweak the ufw too.

$sudo ufw allow from 0.0.0.0/0 to ip.add.of.server port 80

See if it will work when you replace your domain name with IP addresses only, as a start (that is how I got mine up and running)

immeëmosol
January 12th, 2011, 12:32 AM
I hope you've all resolved this by now, but for the sake of reference, those last two messages referred to, are *notices*.

They tell that the server has been restarted.

wgroth2
October 28th, 2012, 06:47 PM
All I had to do was update hosts and the Virtual host entry and default. Thanks for all the info.

br