LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Apache Root/Home Directory and setting up FTP for home directories? (https://www.linuxquestions.org/questions/linux-newbie-8/apache-root-home-directory-and-setting-up-ftp-for-home-directories-197594/)

Mankind75 06-25-2004 09:27 AM

Apache Root/Home Directory and setting up FTP for home directories?
 
I am currently planning to set up a web server and I have a fresh install of Mandrake 10 with Apache 2 running. I now want to add content to my web server but I don't know where to put the files. Does content go into /var/www/html? Also I wanted to set up FTP access so people can upload pages to home directories. I noticed that some servers are configured to have a public_html directory in the home dir but how would I set up Apache and FTP etc. to do this?

Donboy 06-25-2004 09:54 AM

Most of that is done in the httpd.conf file. You need to look in /etc/httpd/conf/httpd.conf or if you can't find it there, you should serch your machine for httpd.conf.

You need to change the DocumentRoot which defines the physical path on your machine where files are served from. Right now it's probably set for /var/www/html, but you can change this to whatever you want.

In my case, I'm doing it with /home/username/www/html. And yes, you can use either public_html or just html, or whatever you want, really.

I recommend setting up your system with user accounts created using "useradd" (the typical way you add users to your system) and use something like ProFTPd which will jail users to their home directories as defined in the /etc/passwd file. In your apache config file, you can setup virtual hosts with the document roots as I described earlier with /home/username/html or /home/username/www/html or whatever you want to do.

Mankind75 06-25-2004 10:26 AM

Wow that was a quick reply. More important things start making sense now. Thanks! Will let you know how I get on.

gbrewste 06-25-2004 11:49 AM

Man, I love this board. I was just going to try to search for an answer to a similar question and found this thread right away which gets me about 75% of the way to my solution.

I think I can figure out the other 25%

THANKS DONBOY :D

Mankind75 06-28-2004 04:23 AM

cgi-bin settings
 
Okay I have both Apache and FTP set up but another question came up. I am planning to install an Image Gallery which requires a cgi-bin directory (it is written in Perl). Is it enough to create a directory named 'cgi-bin' in the users home directory and upload the Perl scripts in there or are there any other changes I would need to make?

Donboy 06-28-2004 06:39 AM

You'll need this (located anywhere you want) in the config file...

Code:

<Directory "/home/*/www/html/cgi-bin">
        Options +ExecCGI
</Directory>

Just replace the path above with the path to your actual cgi-bin. The important part is the +ExecCGI which adds this functionality to the directory you've chosen.

That's it, really. Also be aware that asterisk's work here just like they do at the shell. which means, the example I'm showing above will activate ExeCGI for all paths on your server that match this string. In my case, I've got a whole bunch of users who have accounts setup the same way, so I can enable cgi-bin's on all of their accounts using this simple statement and I don't need to make seperate ones for each account, which becomes a pain everytime I need to add another user.

And yes, you'll need to create this directory.

Also, another nugget that may be important for you...

If your cgi script will be creating any new files (like if you had a message board that writes new files all the time) those files will be written with "apache" as the owner. This becomes a real pain when you want to have the admin for that website able to FTP into their account and manipulate those files. They will not be able to delete those files because they are not the owner of the files! Unless you have them logging in as the apache user, which is a bad idea because what happens when you want to let other people login using FTP? You can't have everyone logging in via FTP as the apache user!

The solution here is to use "suexec" which allows a virtual host to run as a specified user. So in the vhost stanza, you have the following line...

Code:

SuexecUserGroup user group
Where "user" is the user you want apache to run as, and "group" is the group you want apache to run as. What happens now is... when files are created by a cgi script anywhere under that document root, they are created with the user/group you specify. This way, when people login using FTP, they are able to manipulate those files because they are the owner of the files that were written.

Hope that helps.

jonty_11 07-23-2006 02:37 PM

Apache on FC5 (2.6.17-1.2157_FC5)- Forbidden Error
Access provided via User Directories: here is relevant portion of httpd.conf (Same httpd.conf file works fine on another FC5 machine - 2.6.16-1.2096_FC5):

#UserDir disable UK

#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#UK
UserDir public_html

</IfModule>

#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#UK
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
#UK
########################################################################
I have following at the end of the httpd.conf file. But when I try to access the User Directory via HTTP (http://<ip of m/c>/~karihalo/vocal, I get error - 403.

########################################
## Added by allinoneconfigure
## vocalkey: html v1.1
########################################
Alias /vocal "/home/karihalo/public_html/vocal"
<Directory "/home/karihalo/public_html/vocal">
AllowOverride None
Order allow,deny
Allow from all
</Directory>
########################################
## vocalkeyend: html v1.1
########################################
########################################
## Added by allinoneconfigure
## vocalkey: cgi v1.4
########################################
ScriptAlias /vocalconf/ "/home/karihalo/public_html/vocalconf/"
<Directory "/home/karihalo/public_html/vocalconf">
AllowOverride All
Options +ExecCGI
AddHandler cgi-script cgi pl pm
Order allow,deny
Allow from all
</Directory>
<Directory "/home/karihalo/public_html/vocalconf">
AllowOverride None
Options +ExecCGI
AddHandler cgi-script cgi pl pm
Order Deny,Allow
#Deny from all
Allow from 127.0.0.1
</Directory>
########################################
## vocalkeyend: cgi v1.4
########################################


All times are GMT -5. The time now is 02:11 AM.