Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 8th March 2009, 16:25
sparky87 sparky87 is offline
Junior Member
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apache changing /etc/hosts?

i would like to make something like creating subdomains on my Apache server.
it can only work, when i create a config file for every subdomains, or i add to httpd-vhosts something like this
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/www/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>

but what i have to do too, is, change the /etc/hosts file.
add something like, for example: 127.0.0.1 dummy-host2.example.com

the question is, how can i do this from some php script? when the user comes, wants to registrate himself -> by this registration i have to do those things written above, and he will have his subdomain. but, i cannot change /etc/hosts file, because it is owned by root, and php scripts are running under some apache user.

i dont know, if this is possible to make with suid and how is it possible...
pls, how can i do this?

thanks for answers
Reply With Quote
Sponsored Links
  #2  
Old 9th March 2009, 16:00
matey matey is offline
Member
 
Join Date: Feb 2009
Posts: 93
Thanks: 13
Thanked 3 Times in 3 Posts
Default

I think may be you can chmod the files or the whole directory under /etc/ to include reg. users?!
I had to do this once using Zope (although zope makes its own user in proc. of installation)...

I am not sure it is such a good idea, and I am not sure if you have access as root yourself?
May be someone who knows more than me can help you?
good luck
Reply With Quote
  #3  
Old 9th March 2009, 17:10
id10t id10t is offline
Senior Member
 
Join Date: Nov 2008
Posts: 242
Thanks: 2
Thanked 22 Times in 22 Posts
Default

You don't need to modify /etc/hosts when you add a virtual host... as long as DNS points to your IP apache will respond with the content for that name.

BTW - recommend putting each vhost in its own config under /etc/apache2/sites-available and then putting a link to it in /etc/apache2/sites-enabled

Also while I know how to hand create all the needed files for domain hosting (dns, web, email) I've found great joy in relaxing and just using ispconfig ...
Reply With Quote
  #4  
Old 9th March 2009, 17:35
sparky87 sparky87 is offline
Junior Member
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to matey:
thanks, i can chmod the files under /etc/ and it will work, of course. but i am not really sure, if it is secure and good to do it so. what do you think? i don't know...

to id10t:
well, i put each vhost in its own config -> these files are saved in /www/conf/vhosts and in file /www/conf/extra/httpd-vhosts.conf is this: Include conf/vhosts, what says, where apache has to look for vhosts config files. -> but i have to modify /etc/hosts too, like i wrote above...
but you say, i don't need to modify /etc/hosts. in fact, i dont understand this very well. the problem is, i don't have any DNS system so i cannot use A records. this system works only on my localhost - in this case i need to modify /etc/hosts . or is it possible to do it without that????
Reply With Quote
  #5  
Old 9th March 2009, 19:16
matey matey is offline
Member
 
Join Date: Feb 2009
Posts: 93
Thanks: 13
Thanked 3 Times in 3 Posts
Default

sparky87;

As I said I had this problem with Zope but I am using this machine all by myself so no one else has any access to it therefore I do not know what happens?
I made it work though but again I made a mistake when I set up zope and installed it under /root directory!?
then I had to do chmod +x /root/zope/ to give the zope user the access...

so if you are in a situation where a lot of others (human users) have access to your machine then I would not do that, or just copy the (config) files you want to try (not the whole folder) to a safe location so you can later move them back in case some thing happened.
It's always a good thing to copy files for safe-keeping any way
Good Luck.
Reply With Quote
  #6  
Old 9th March 2009, 22:12
sparky87 sparky87 is offline
Junior Member
 
Join Date: Mar 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

to matey:
ok, thanks for your advices. when i won't find out any another way hot do it, i will do, what you say.

but when someone has some another idea, just let me know
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
chgrp error new user DKA General 15 28th July 2008 18:45
Changing the Apache user. Baggus Installation/Configuration 1 15th May 2008 09:40
CENTOS 5 Ping Problem gAnDo Server Operation 11 28th March 2008 21:58
Centos 4.4 32bit Hangs, High Server load 3cwired_com Server Operation 11 16th November 2006 16:47
Problem with the installation of Dokeos (LMS) in ISPConfig jofranco General 4 28th April 2006 01:45


All times are GMT +2. The time now is 05:17.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.