Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a dedicated server on which I have a site http://www.example.com

I need to create a user and:


  1. How do I provide ftp access to him?
  2. How do I setup public_html and all necessary details so that he can access html file from the internet? I want him to be able to execute php scripts as well (which I dont think should be a problem as the website on this site can do it already).

I don't have cPanel. I am running RHEL5/CentOS


Edit1

In httpd.conf I added this:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName www.example.com
  DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *:80>
  ServerName david.example.com
  DocumentRoot /home/david/public_html
</VirtualHost>

<VirtualHost *:80>
  ServerName matthew.example.com
  DocumentRoot /home/matthew/public_html
</VirtualHost>

And made sure the corresponding folders existed with 755 permissions.

I have the main site accessible now, but not the subdomain.example.com ones.

share|improve this question
1  
This is entirely dependant on what FTP server you are using and what Web Server you are using. –  Sam Jan 24 '11 at 11:56
    
@Sam - Redhat Linux, Apache, and dunno about the ftp server... –  matt74tm Jan 24 '11 at 15:30
    
well you are going to need to find out if you want to give him FTP access. You will either need to know how to configure a user in that FTP software, or use a control panel that will help you do that. –  Sam Jan 24 '11 at 15:52
    
@Sam - okay, forget about that for the time being... can you help out with how to setup public_html properly? –  matt74tm Jan 24 '11 at 17:06
add comment

1 Answer

You use mod_userdir to set up public_html and directories that allow users to have websites on your machine.

If you only need this for one user you can also set up a plain virtual host to that directory. EG:

Listen 80
NameVirtualHost *

<VirtualHost *>
  ServerName www.yourdomain.com
  DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *>
  ServerName subdomain.yourdomain.com
  DocumentRoot /home/username/public_html/
</VirtualHost>

If you have multiple usernames you want to create VirtualHosts for, you have a few options. The first is to write them out explicitly in your httpd.conf. The second is to use mod_rewrite to look for unknown hostnames and translate them to the default user directory http://yourhostname.com/~username/.

That takes care of the Web aspect of it. For the FTP aspect a daemon such as ProFTPd's DefaultRoot takes care of user directory FTP access. For DNS you could create a wildcard A entry to point the *.yourdomain.com to your server's IP address.

As a side note, please edit this question with the information your provided on your question on StackOverflow (and was eventually ported to ServerFault) so that we do not have duplicate questions floating around. Thanks!

share|improve this answer
    
Hi @Dave - thank you for responding... I dont think your instructions are fully accurate. I did get part of it working - the main site works again, but not the subdomains. See edit1. –  matt74tm Jan 25 '11 at 3:06
    
do I need to change the DNS settings in the /etc/hosts file? –  matt74tm Jan 25 '11 at 4:42
    
/etc/hosts does not affect anything other than local DNS resolution on the machine. You will need to add the correct records to the DNS server who is authoritive for yourdomain.com. –  Dave Drager Jan 25 '11 at 17:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.