Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Newbie with Apache 2 |
|
Author |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 06 Apr '07 13:24 Post subject: Newbie with Apache 2 |
|
|
Hi.
I am a newbie to Apache 2, and finally got it running on my (old) Dell Server, 1ghz processor, 103gb drive space (8 x 18gb scsi), Windows Server 2003. Its now running Apache 2, MySQL, phpMyAdmin and PHP fine.
What I want to learn is how to set up the server so it allows users to host their web sites off it, its all connected to my router, the virtual server http 80 in my router is redirecting fine, as is the domain name which points to my router.
What I need to do is:
a) set up the server so it maps the url to their folder with their html code, i.e. <www.domain_name>/username/index.html
b) I do have a 250gb caddy with full FTP support which also sits on the router with its own static IP address and the FTP port open for access (using username/password for access), so was wondering if I can get the server to point to that for storing the files?
For example: Server is on home network IP 192.168.0.60, caddy is on 192.168.0.210.
Since I know nothing about setting Apache up for web hosting, any useful tips and help would be great!! |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 06 Apr '07 15:44 Post subject: |
|
|
re: "a) set up the server so it maps the url to their folder with their html code, i.e. <www.domain_name>/username/index.html "If your users all have different host names - you want virtual hosts.
The Apache 2.2 docs for virtual hosts are at http://httpd.apache.org/docs/2.2/vhosts/
If your users all share the same host name, you can just name the subdirectories under \htdocs to match their user names
- or else use the Apache Alias directive to point elsewhere on your system for each user. re: "b) ... can get the server to point to that (ftp server) for storing the files? "You can use the Apache module mod_proxy_ftp to do this.
If you want to serve all requests from your ftp server, you would use directives like this: Code: | LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
...
<IfModule proxy_ftp_module>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ftp://192.168.0.210/
ProxyPassReverse / ftp://192.168.0.210/
</IfModule> | Be sure to read the Apache mod_proxy docs carefully, in order to keep your server secure.
-tom- |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 06 Apr '07 16:22 Post subject: Newbie with Apache 2 |
|
|
tdonovan wrote: | re: "a) set up the server so it maps the url to their folder with their html code, i.e. <www.domain_name>/username/index.html "If your users all have different host names - you want virtual hosts.
The Apache 2.2 docs for virtual hosts are at http://httpd.apache.org/docs/2.2/vhosts/
If your users all share the same host name, you can just name the subdirectories under \htdocs to match their user names
- or else use the Apache Alias directive to point elsewhere on your system for each user.
|
My original plan for the users was to point it to seperate directories so each user cant see the others folders/directories, each web site would run off the main domain name with their user name, but the internal folder structure on the server would be pointing to their own local home/htdocs folder? - How do I do this? - With apache 2.2 in its default config, I have the index.html page in the standard HTDOCs folder, I see from the config file for Apache, there are modules commented out/active, I was trying to work out which modules needed implementing/using and which needed commenting out/where the code goes?
Quote: |
re: "b) ... can get the server to point to that (ftp server) for storing the files? "You can use the Apache module mod_proxy_ftp to do this.
If you want to serve all requests from your ftp server, you would use directives like this: Code: | LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
...
<IfModule proxy_ftp_module>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ftp://192.168.0.210/
ProxyPassReverse / ftp://192.168.0.210/
</IfModule> |
Be sure to read the Apache mod_proxy docs carefully, in order to keep your server secure.
-tom- |
Which seperate file does this go in for this to take effect?
Is this the file in extra called httpd-userdir.conf
In a way I dont really have to worry about users needing FTP access, as the caddy limits only 8 user accounts and has its own password/username records stored internally. So as long as I have them set up as an account on the caddy to their own FTP area, all Apache needs to know is to point to that folder to load the pages. |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Mon 09 Apr '07 2:22 Post subject: |
|
|
tdonovan wrote: | re: "a) set up the server so it maps the url to their folder with their html code, i.e. <www.domain_name>/username/index.html "If your users all have different host names - you want virtual hosts.
The Apache 2.2 docs for virtual hosts are at http://httpd.apache.org/docs/2.2/vhosts/
If your users all share the same host name, you can just name the subdirectories under \htdocs to match their user names
- or else use the Apache Alias directive to point elsewhere on your system for each user. |
With regards to my last reply, I have found the file httpd-userdir.conf which is what I assume I use to set up the mapping for users web pages stored on the server (please excuse me being slow - newbie and trying to plough my way through the manual and a book on the software!).
This has references to both the UserDir variable and the Control Access, how would I set this up so the user just typed "http://-domain-name.co.uk-/username to get their pages? I see from the examples you have ~ prior to their name, so instead of "chris" its ~chris? - is the tilde necessary or is that just an example? |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 13 Apr '07 0:44 Post subject: |
|
|
tdonovan wrote: | re: "a) set up the server so it maps the url to their folder with their html code, i.e. <www.domain_name>/username/index.html "If your users all have different host names - you want virtual hosts.
The Apache 2.2 docs for virtual hosts are at http://httpd.apache.org/docs/2.2/vhosts/
If your users all share the same host name, you can just name the subdirectories under \htdocs to match their user names
- or else use the Apache Alias directive to point elsewhere on your system for each user. re: "b) ... can get the server to point to that (ftp server) for storing the files? "You can use the Apache module mod_proxy_ftp to do this.
If you want to serve all requests from your ftp server, you would use directives like this: Code: | LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
...
<IfModule proxy_ftp_module>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ftp://192.168.0.210/
ProxyPassReverse / ftp://192.168.0.210/
</IfModule> |
Be sure to read the Apache mod_proxy docs carefully, in order to keep your server secure.
-tom- |
Mm.. I seem to be stuck now.. I have printed out manual and its been bound, but the userdir function doesnt seem to be doing its thing.
My code reads:
UserDir public_html
<Directory \\media-server\Public\Apache\*\public_html>
AllowOverride FileInfo AuthConfig Limit Indexes Limit
</Directory>
The above directory structure exists, and their is a index.html in the directories under two names I am using, but all I get is page not found? |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 13 Apr '07 7:04 Post subject: |
|
|
You might be making it harder than it needs to be with UserDir.
That directive is useful for hosting a large number (100's, 1000's) of users - but really not necessary for a few users.
Also - you normally use forward-slashes in httpd.conf, even for Windows.
If you must use backslashes (i.e. in your media-server name) you must double them.
For example: if you have two users named Chris and Bob, you could create two directories on media-server:\\media-server\Public\Apache\Chris
\\media-server\Public\Apache\Bob In httpd.conf, set you DocumentRoot to "\\\\media-server/Public/Apache".
You would normally set permissions like this:<Directory "\\\\media-server/Public/Apache">
Order deny,allow
Allow from all
</Directory> This would make both directories (as well as the root directory) visible to everyone via a browser,
although presumably Bob and Chis would need their ftp passwords to change anything in their own subdirectories via ftp.
Whether they do depends on your ftp config, not your Apache config.
Your statement "...so each user cant see the others folders/directories..." is a little confusing.
Do you really mean that only Chris can view Chris' web directory and only Bob can view Bob's web directory?
Web sites are usually world-visible. Browser requests are pretty much anonymous unless you set up Apache passwords and require all visitors to log in before viewing the web site.
If you do this, you can control who sees which directories - but I'm not sure that's what you mean.
For example: it's not clear why Bob would want to create a web site that only he can see.
-tom- |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 13 Apr '07 11:47 Post subject: |
|
|
tdonovan wrote: | You might be making it harder than it needs to be with UserDir.
That directive is useful for hosting a large number (100's, 1000's) of users - but really not necessary for a few users.
Also - you normally use forward-slashes in httpd.conf, even for Windows.
If you must use backslashes (i.e. in your media-server name) you must double them.
For example: if you have two users named Chris and Bob, you could create two directories on media-server:\\media-server\Public\Apache\Chris
\\media-server\Public\Apache\Bob In httpd.conf, set you DocumentRoot to "\\\\media-server/Public/Apache".
You would normally set permissions like this:<Directory "\\\\media-server/Public/Apache">
Order deny,allow
Allow from all
</Directory> This would make both directories (as well as the root directory) visible to everyone via a browser,
although presumably Bob and Chis would need their ftp passwords to change anything in their own subdirectories via ftp.
Whether they do depends on your ftp config, not your Apache config.
Your statement "...so each user cant see the others folders/directories..." is a little confusing.
-tom- |
You are quite right with regards to my confusion over others cant see the directories, I meant the folders they access when using FTP in order to upload the files, not the actual web pages hosted by the HTTP service.
The reason I am using \\ convention is due to the fact the external hard drive caddy which is plugged into my network via RJ45 has full FTP hardware account control and uses UNC mapping protocols to map drives to the PC and network, so I have to use "MAP network drive" and then use UNC paths to assign the drive letter as normal to appear in Windows, however when browsing the network it takes me via server-name\public\folder to map drives, plus shows them as these when listing drives in My Computer. The caddy automatically uses PUBLIC as its default folder which has all the directories on the caddy when mapping drives, any FTP accounts set up on the caddy seem to be created hidden or something as they wont appear (as far as I can see) as a sub directory off the PUBLIC folder or anywhere else on the hard drive, so the only way I can allow multiple folders for each user on this drive is to map them/create them off the PUBLIC folder (as they are not accessible/visible if created the other way).
I tried using / but it failed to load up, mainly as the FTP caddy uses the UNC format/server format, also Apache runs and loads as a service fine with the \\ so I was assuming it could see/find the folders, I didn't realise it was a case of adding extra \ to fix it.
does this code go in the http_userdir.conf file? or do I leave that alone? |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 13 Apr '07 18:01 Post subject: |
|
|
re: "does this code go in the http_userdir.conf file?"
No - Your DocumentRoot and the <Directory> block which describes it go in httpd.conf.
-tom- |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 13 Apr '07 18:10 Post subject: |
|
|
tdonovan wrote: | re: "does this code go in the http_userdir.conf file?"
No - Your DocumentRoot and the <Directory> block which describes it go in httpd.conf.
-tom- |
ok, so no need to use the userdir.conf file..
What circumstances would I need to use the userdir.conf file (out of interest) do I need to comment these calls to this conf file out or can I just leave them "active"? |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Fri 13 Apr '07 18:47 Post subject: |
|
|
If you use the module mod_userdir, and you have a UserDir directive - you do so in in extra\httpd-userdir.conf and Include this file from httpd.conf.
If you are not using mod_userdir (...I presume you are not...) - you don't edit extra\httpd-userdir.conf and you don't Include it from httpd.conf.
You can also comment out the LoadModule userdir_module modules/mod_userdir.so directive in httpd.conf.
mod_userdir is helpful if you have so many users that you don't want to deal with them individually,
but need them to become available whenever you create a new directory.
I'm guessing that for your installation mod_userdir is more confusing than helpful.
-tom- |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Fri 13 Apr '07 22:13 Post subject: |
|
|
tdonovan wrote: | If you use the module mod_userdir, and you have a UserDir directive - you do so in in extra\httpd-userdir.conf and Include this file from httpd.conf.
If you are not using mod_userdir (...I presume you are not...) - you don't edit extra\httpd-userdir.conf and you don't Include it from httpd.conf.
You can also comment out the LoadModule userdir_module modules/mod_userdir.so directive in httpd.conf.
mod_userdir is helpful if you have so many users that you don't want to deal with them individually,
but need them to become available whenever you create a new directory.
I'm guessing that for your installation mod_userdir is more confusing than helpful.
-tom- |
Agreed, the problem also is all the books I have been getting regarding apache (I now have about 4!) dont really cover the user-dir module very well or give well document examples.
The way you have explained it here works fine, I have just tested it, although I didnt want an error page to appear when the domain name was typed with no user name, i.e. just domain name, but just an info page on the server hardware spec - I still need to learn how to get html to get the server hardware info as the page is accessed! , the only way I could get it to hide the folder listing was to hide the index.html on the default directory as specified in the Apache file path you used in the earlier example, the only reason I did this, was I didnt want this to show up when users logon to the hard drive caddy using the caddies FTP logon side, since it doesnt have any file permission or security control when you give users access to the PUBLIC folder (see below for more info)
I think my problem is that since the server is an old 1ghz processor (dual 500mhz), it only has about 145gb hard drive space (8 x 18gb) of which 15gb has been allocated as C:\ for the OS, since the other 7 are running in a raid-5 config, one other drive is obviously being used as redundant drive should 1 drive fail - this is an old server, and I dont really want to buy bigger drives than 18gb as for this server they get expensive after 18gb sizes, so by having the external caddy situation on the network I can benefit from the 250gb IDE drive for the html files etc, this way users can FTP onto the caddy via a seperate account set up on the caddy rather than setting up the server do this function as well, the knock on downside is that the FTP caddy gives me only one viable option, which is to allow them access to the PUBLIC folder, which means Apache can map to it fine, but then all users who login to the caddy see everyone elses folders and have full read/write access to the whole drive - not just the apache folder for the html etc, but anything else on there, obviously the ftp function on the caddy is set to not allow anonymous users, so I have to set up the accounts (to a max of eight) for anyone to access it, the downside as stated is all accounts get to see all others folders and full permissions, which I cant see a way round!
If I want to allow cgi scripts etc:
a) what is the best freeware cgi package?
b) how do I set this up in apache?
I have installed PHP and MySqL as well as phpMyAdmin, which were working fine when I used http://localhost/phpmyadmin/index.php, however now these fail to display the pages, so I assume this is due to the change in the root document path, since the phpinfo.php and phpmyadmin were installed/created in the original htdocs folder off Apache, I dont really want to move these as doing so would make phpmyadmin become a folder my users can get access to - is there anyway to include this folder additionally as well as the document root you suggested above? Now I need to get phpmyadmin running again since the documentroot has been moved, plus then address the above errors. My software is installed all in subdirectories off C:\Server\ with phpmyadmin running in a folder of htdocs of Apache.. |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Tue 17 Apr '07 2:29 Post subject: |
|
|
tdonovan wrote: | If you use the module mod_userdir, and you have a UserDir directive - you do so in in extra\httpd-userdir.conf and Include this file from httpd.conf.
If you are not using mod_userdir (...I presume you are not...) - you don't edit extra\httpd-userdir.conf and you don't Include it from httpd.conf.
You can also comment out the LoadModule userdir_module modules/mod_userdir.so directive in httpd.conf.
mod_userdir is helpful if you have so many users that you don't want to deal with them individually,
but need them to become available whenever you create a new directory.
I'm guessing that for your installation mod_userdir is more confusing than helpful.
-tom- |
Now the document root is set to the new path, how do I get it to still register/pick up myphpadmin which is in a directory off the default htdocs directory. I dont want to "move" the myphpadmin to the same area as the document-room as the folder is on a local drive caddy which is not directoy/password secure, so anyone with an FTP account onto the caddy can remove/delete or trash the folder! |
|
Back to top |
|
tdonovan Moderator
Joined: 17 Dec 2005 Posts: 611 Location: Milford, MA, USA
|
Posted: Tue 17 Apr '07 23:47 Post subject: |
|
|
You can do this with the Alias directive, which is described in the Apache docs here: http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias.
For example: Code: | Alias /myphpadmin "C:/Apache2/htdocs/myphpadmin"
<Directory "C:/Apache2/htdocs/myphpadmin">
Order allow,deny
Allow from all
</Directory> |
-tom- |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Thu 19 Apr '07 10:40 Post subject: |
|
|
tdonovan wrote: | You can do this with the Alias directive, which is described in the Apache docs here: http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias.
For example: Code: | Alias /myphpadmin "C:/Apache2/htdocs/myphpadmin"
<Directory "C:/Apache2/htdocs/myphpadmin">
Order allow,deny
Allow from all
</Directory> |
-tom- |
Thanks Tom.. that did the trick, however there is one thing I am having problems with using Alias.
Having now got the Alias command to point to phpmyadmin correctly (even after moving the folder to keep it in line with the rest of the installs and updating any references where needed, there are two files that I want to display when the URL is typed on the web site/server.
One is a phpinfo.php file which displays the information about the install, the other is a default index.html which will show if the user types in the domain name and no "username" is keyed (i.e. http://domain-name.co.uk/" will show this default index.html, and http://domain-name.co.uk/phpinfo.php" will show the phpinfo install versions etc.
Since the defaults htdocs folder is now on the Caddy drive as per this previous email thread, I dont want the documentroot directory of this folder to hold any systems files/folders which I create for information etc (my default index.html has server hardware specs), since this caddy has no "security access/permissions" logic, it means all users can see each others folders on the caddy (thats fine with me!), however when I set up an alias as follows:
Alias /information "C:/Server/phpinfo"
<Directory "C:/Apache2/htdocs/phpinfo">
Order allow,deny
Allow from all
</Directory>
typing http://domain-name.co.uk/phpinfo.php will bring up the not found message, do I need to make the folder name the same as the .php? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 20 Apr '07 16:55 Post subject: |
|
|
you can create an index.php in that folder.
Code: |
<?php
phpinfo();
?>
|
in httpd.conf find
DirectoryIndex index.htm index.html
add index.php
to
DirectoryIndex index.php index.htm index.html
restart apache |
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Sat 21 Apr '07 9:32 Post subject: |
|
|
James Blond wrote: | you can create an index.php in that folder.
Code: |
<?php
phpinfo();
?>
|
in httpd.conf find
DirectoryIndex index.htm index.html
add index.php
to
DirectoryIndex index.php index.htm index.html
restart apache |
The problem is, that I want the Index.html etc to display server information, and the phpinfo.php to display the phpinfo config, I suppose I am trying to set up a /htdocs off the server folder which only contains htdocs for the server to show and not anyone else.
i.e. all docs like config display php type files, or the default index.html/index.htm web page that would be shown on the default url would be the server config or software config versions/information.
All other docs for users would be in the mapped drive path like Tom showed me earlier which is working fine. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|
ccwking
Joined: 06 Apr 2007 Posts: 11
|
Posted: Sun 22 Apr '07 13:20 Post subject: |
|
|
I seem to have solved my index problem now too .... good learning curve!! |
|
Back to top |
|
|
|
|
|
|