Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 20th February 2007, 17:44
Leszek Leszek is offline
Senior Member
 
Join Date: Nov 2006
Location: Poland,Włocławek
Posts: 369
Thanks: 22
Thanked 42 Times in 35 Posts
Send a message via Skype™ to Leszek
Exclamation Adding vhosts to Apache 2 from a website

Hello everyone!

I need to make an interface on a website (the site would be on my server) to let visitors add an account for themselves for free. This would be a registration form, that after submitting would add a virtual hosts file to for example /etc/apache2/vhosts with correct definitions.The worst thing is that i can't work out a way to execute php scripts that would modify those files.
I thought of executing a shell script from php,maybe using Cron for that job but it's too complicated for me at this time. I mean that a user would provide a username and a password by a form and php would save it to a file that would look like a shell script and Cron would execute it from time to time.
Next thing i thought of was mod su_php to execute a php script,which would modify the needed files.I would like to know Your opinion about a way to securely add new vhosts to Apache.I need all info I can get from You more experienced people out there.Thanks in advance.

My OS is Linux (preferrably OpenSuSE).
Reply With Quote
Sponsored Links
  #2  
Old 20th February 2007, 23:29
ctql ctql is offline
Junior Member
 
Join Date: Aug 2006
Posts: 23
Thanks: 1
Thanked 3 Times in 2 Posts
Default

Store each vhost in a separate file (well, not a requirement but seems easier to manage) and put them all in a folder that apache can write to. Make sure apache reads this folder with something in the httpd.conf like:
Include /etc/httpd/conf.d/vhosts/*.conf

Then all you need to do is add a httpd reload script like the one I linked to here:
http://www.howtoforge.com/forums/showthread.php?t=10597

Of course, unless you trust your users a lot you'll want some verification that the data is good and that the newly generated config file can be used. You can do this by doing httpd configtest or reading the results of httpd reload...
Reply With Quote
  #3  
Old 21st February 2007, 15:07
Leszek Leszek is offline
Senior Member
 
Join Date: Nov 2006
Location: Poland,Włocławek
Posts: 369
Thanks: 22
Thanked 42 Times in 35 Posts
Send a message via Skype™ to Leszek
 
Default

Well that's one way of doing this. I'll give it a shot in my free time.
I'm still open for more suggestions.
Thanks ctql!
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
Apache not reading conf? /var/www directory displayed when visiting any ISPC website toodles Installation/Configuration 2 15th February 2007 23:06
Creating image with Systemimager cuongtim HOWTO-Related Questions 3 18th November 2006 13:55
Centos 4.4 32bit Hangs, High Server load 3cwired_com Server Operation 11 16th November 2006 15:47
apache vhosts messed up whitty Installation/Configuration 9 4th June 2006 10:38
Problem with the installation of Dokeos (LMS) in ISPConfig jofranco General 4 28th April 2006 00:45


All times are GMT +2. The time now is 14:55.


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