PDA

View Full Version : NameVirtualHost CentOS 6



haringsrob
09-30-2011, 02:28 AM
Hello,

I'm setting up my verry first server with centos and DA.

Now i have one issue wich i cant resolve.



Starting httpd: [Fri Sep 30 11:20:37 2011] [error] (EAI 2)Name or service not known: Could not resolve host name : -- ignoring!
[Fri Sep 30 11:20:39 2011] [error] (EAI 2)Name or service not known: Could not resolve host name : -- ignoring!



I have tried a few things. But nothing seems to work.

I'm only have One ip.

Any help is welcome.
Rob

SeLLeRoNe
09-30-2011, 02:54 AM
post output for:


cat /etc/hosts


hostname

Regards

haringsrob
09-30-2011, 05:32 AM
post output for:


cat /etc/hosts


hostname

Regards

Have solved this problem.

Now when i add a domain in my user level of directadmin and i go to this domain only:

Apache is functioning normally

shows up.

Tried a few things but noting seems to work.

SeLLeRoNe
09-30-2011, 05:35 AM
Try manually restart apache.

Check also if in

/usr/local/directadmin/data/users/USERNAME/httpd.conf

there is a correct configuration.

Seems or that apache isnt restart or that the new httpd.conf is not loaded (or not craeted).

Regards

haringsrob
09-30-2011, 05:45 AM
This is my httpd.conf file of my user:

##MYIP## is my public ip


<VirtualHost ##MYIP##:80 >


ServerName www.y0o.nl
ServerAlias www.y0o.nl y0o.nl
ServerAdmin webmaster@y0o.nl
DocumentRoot /home/admin/domains/y0o.nl/public_html
ScriptAlias /cgi-bin/ /home/admin/domains/y0o.nl/public_html/cgi-bin/

UseCanonicalName OFF

SuexecUserGroup admin admin
CustomLog /var/log/httpd/domains/y0o.nl.bytes bytes
CustomLog /var/log/httpd/domains/y0o.nl.log combined
ErrorLog /var/log/httpd/domains/y0o.nl.error.log

<Directory /home/admin/domains/y0o.nl/public_html>
Options +Includes -Indexes

php_admin_flag engine ON
<IfModule !mod_php6.c>
php_admin_flag safe_mode OFF
</IfModule>
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f admin@y0o.nl'


php_admin_value open_basedir /home/admin/:/tmp:/var/tmp:/usr/local/lib/php/


</Directory>



</VirtualHost>



This is output of
service httpd restart



Stopping httpd: [ OK ]
Starting httpd:


I noticed that starting httpd is not showing OK ?

Thank you for helping so far

SeLLeRoNe
09-30-2011, 05:48 AM
Actually hide an ip and leave the host visible have no sense.. but ok...

check if apache is running

or


/etc/init.d/httpd status

or


ps aux | grep httpd

Let me know

haringsrob
09-30-2011, 05:52 AM
Ye didnt think about that :p

Httpd (pid 3510) is running...

SeLLeRoNe
09-30-2011, 05:55 AM
Check the httpd logs and directadmin logs for errors in /var/log please

Let me know if you find any error or something wrong

haringsrob
09-30-2011, 05:58 AM
Access log shows the following:

###ip### - - [30/Sep/2011:14:55:57 +0200] "GET / HTTP/1.1" 200 394

Error log show this:

[Fri Sep 30 14:55:00 2011] [error] [client ###ip### ] File does not exist: /var/www/html/~y0o.nl
[Fri Sep 30 14:55:00 2011] [error] [client ###ip### ] File does not exist: /var/www/html/404.shtml

The rest of logs seem normal.

SeLLeRoNe
09-30-2011, 06:05 AM
mmmmmh...

try remove the domain from directadmin and re-add it...

Let me know

haringsrob
09-30-2011, 06:07 AM
Before we go to that, i did have on thing that didnt work troughtout the installation, sorry but i totally forgot about this.

You can automate this process with:
cd /usr/local/directadmin/data/templates/custom
cp ../dns_a.conf .
and add:
|?IP=192.168.1.2|
to the top of the custom/dns_a.conf file.

There is no such file as dns_a.conf

Once again sorry

SeLLeRoNe
09-30-2011, 06:17 AM
Why you need to add that line?

haringsrob
09-30-2011, 06:27 AM
Hello,

I need to add it becouse i'm using a nat rule to get to my server.

I managed to get my website working

had to edit my users httpd.conf file IP to my local ip then i can access it.

However when i delete my domain and recreate it, it still takes my public ip.

Any experience on how to edit that it always uses my local ip?

Thanks in advance.

SeLLeRoNe
09-30-2011, 06:33 AM
Ok, now you gave the real needed information.

For do that you need to do this:


cp /usr/local/directadmin/data/templates/virtual_host2* /usr/local/directadmin/data/templates/custom/



Once you did this edit all virtual_host2* file in custom directory and change IP with the internal IP.

Regards

haringsrob
09-30-2011, 06:48 AM
For now its working, going to try add other packages and domains now.


Thanks alot for your help!

SeLLeRoNe
09-30-2011, 06:50 AM
NP, btw for change the IP with your internal IP i meant change the variable |IP| with your 192.168.1.x ip

Regards

haringsrob
09-30-2011, 06:54 AM
NP, btw for change the IP with your internal IP i meant change the variable |IP| with your 192.168.1.x ip

Regards


Yes i have done that. :)

haringsrob
09-30-2011, 08:12 AM
One more issue.

I have addad a second domain to my admin user, user level.

When i visit that domain it goes to the first domain i have added roots directory

(it show y0o.nl's welcome screen instead of other domains)

SeLLeRoNe
09-30-2011, 09:43 AM
post the httpd.conf for that user.

Regards

haringsrob
10-01-2011, 01:01 AM
Hello, and good morning.

These are the file contents.




<VirtualHost 192.168.12.250:80 >


ServerName www.y0o.nl
ServerAlias www.y0o.nl y0o.nl
ServerAdmin webmaster@y0o.nl
DocumentRoot /home/admin/domains/y0o.nl/public_html
ScriptAlias /cgi-bin/ /home/admin/domains/y0o.nl/public_html/cgi-bin/

UseCanonicalName OFF

SuexecUserGroup admin admin
CustomLog /var/log/httpd/domains/y0o.nl.bytes bytes
CustomLog /var/log/httpd/domains/y0o.nl.log combined
ErrorLog /var/log/httpd/domains/y0o.nl.error.log

<Directory /home/admin/domains/y0o.nl/public_html>
Options +Includes -Indexes

php_admin_flag engine ON
<IfModule !mod_php6.c>
php_admin_flag safe_mode OFF
</IfModule>
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f admin@y0o.nl'


php_admin_value open_basedir /home/admin/:/tmp:/var/tmp:/usr/local/lib/php/


</Directory>



</VirtualHost>



<VirtualHost 192.168.12.250:80 >


ServerName www.vrouwenkapsel.nl
ServerAlias www.vrouwenkapsel.nl vrouwenkapsel.nl
ServerAdmin webmaster@vrouwenkapsel.nl
DocumentRoot /home/admin/domains/vrouwenkapsel.nl/public_html
ScriptAlias /cgi-bin/ /home/admin/domains/vrouwenkapsel.nl/public_html/cgi-bin/

UseCanonicalName OFF

SuexecUserGroup admin admin
CustomLog /var/log/httpd/domains/vrouwenkapsel.nl.bytes bytes
CustomLog /var/log/httpd/domains/vrouwenkapsel.nl.log combined
ErrorLog /var/log/httpd/domains/vrouwenkapsel.nl.error.log

<Directory /home/admin/domains/vrouwenkapsel.nl/public_html>
Options +Includes -Indexes

php_admin_flag engine ON
<IfModule !mod_php6.c>
php_admin_flag safe_mode OFF
</IfModule>
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f admin@vrouwenkapsel.nl'


php_admin_value open_basedir /home/admin/:/tmp:/var/tmp:/usr/local/lib/php/


</Directory>



</VirtualHost>

SeLLeRoNe
10-01-2011, 01:03 AM
try remove:

/home/admin/domains/vrouwenkapsel.nl/public_html/index.html

and let me know if you still see the page.

Regards

haringsrob
10-01-2011, 01:07 AM
It remains

Welcome to the home of y0o.nl

SeLLeRoNe
10-01-2011, 01:11 AM
Thats curios, have you tryed restart apache?

haringsrob
10-01-2011, 01:48 AM
When i restart httpd i get the following:



Starting httpd: [Sat Oct 01 10:46:41 2011] [warn] VirtualHost 192.168.12.250:80 overlaps with VirtualHost 192.168.12.250:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Sat Oct 01 10:46:41 2011] [warn] VirtualHost 192.168.12.250:80 overlaps with VirtualHost 192.168.12.250:80, the first has precedence, perhaps you need a NameVirtualHost directive

SeLLeRoNe
10-01-2011, 02:14 AM
Those are just non important warnings.

Actually ive no more ideas.. is curios...

haringsrob
10-01-2011, 02:18 AM
Could it be a problem with my dns setting?

My domains records all point to my public IP.

SeLLeRoNe
10-01-2011, 02:31 AM
No, a shared hosting usually point multiple domains to single ip, doesnt look to me as a dns problem but on apache something is wrong, cause point you to the wrong directory while the httpd.conf seems to be correctly redirected for each domain to his own domain home... i dont get what is wrong there.. but im about sure that is apache issue...

haringsrob
10-01-2011, 02:40 AM
Hi,

I managed to resolve this problem bij adding:

NameVirtualHost 192.168.12.250:80

To my httpd.conf file.

After that i restarted httpd service, error (or warnings) are gone. Everything works fine.

Hope its solved now.

Thanks for your help!

SeLLeRoNe
10-01-2011, 03:11 AM
Ok, again now i understand the problem.

Remove that line from httpd.conf and add the 192.168.2.250 ip into directadmin.

Directadmin doesnt know about that ip so he dont tell apache to listen on that aswell.

That should solve your problem definitly

Regards

haringsrob
10-01-2011, 03:16 AM
Where in DA exactly?

IP 192.168.12.250 already exists on eth0

SeLLeRoNe
10-01-2011, 04:39 AM
on ip management on admin lever

You shouldnt see the ip in ip list, when you add it it say alraedy exist, once you done the ip is in the list and the problem should be solved

Regards

haringsrob
10-01-2011, 04:56 AM
Okay, its working now.
Thanks alot again!