Forum Moderators: phranque

Message Too Old, No Replies

blocking off php/cgi from certain vhosts

         

sirvulcan

6:46 am on Apr 22, 2003 (gmt 0)

10+ Year Member



How can i lock off PHP/CGI from certain vhosts

oilman

9:15 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to WebmasterWorld sirvulcan :) - can you be a little more specific about what it is exactly you are wanting to do?

sirvulcan

11:11 pm on Apr 22, 2003 (gmt 0)

10+ Year Member



I run a hosting business with some friends, we were wanting to start a "HTML only" offer, whereby people who take the offer only can use HTML (not php/cgi). As our apache is compiled in with php n cgi and its on everywhere. All of our clients run off VHOSTS. If we were to add a HTML only client in, is there a way we can stop them using php and cgi and still let the other clients on other plans use php/cgi

BjarneDM

1:39 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



that's no problem. but at present you've mismanaged the httpd conf filedd ;-)

1) take at look at your httpd.conf file
for each of your virthosts you'll need to create a virtual host section like this:
<VirtualHost *>
ServerName www.webserver.com
DocumentRoot /Volumes/brugere/client/documents
<Directory "/Volumes/brugere/client/documents">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ "/Volumes/brugere/client/cgi-bin/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
php_value include_path ".:/Volumes/brugere/client"
php_value session.cookie_domain "www.webserver.com"
php_value session.save_path "/Volumes/brugere/client/tmp"
php_value session.use_only_cookies "1"
ErrorLog "/Volumes/brugere/client/logs/error_log"
CustomLog "/Volumes/brugere/client/logs/referer_log" referer
CustomLog "/Volumes/brugere/client/logs/agent_log" agent
CustomLog "/Volumes/brugere/client/access_log" common
</VirtualHost>

you can keep a separate file for each of you clients by adding this line at the end of the httpd.conf file:
Include /private/etc/httpd/users
every file in that directory will be included and interpreted by apache

if you want to offer MySQL as well, create a mysql folder in the user account folder and make a symbolic link ( ln -s ) from the standard place where MySQL stores things.
lrwxrwxrwx 1 mysql mysql 56 Apr 28 22:00 client -> /Volumes/brugere/client/mysql
remember to set up a user account with mysql too for each of your clients to have MySQL access

almost *everything* can be defined on an account by account basis.
keep the main httpd.conf file as lean and mean as possible and move everything else into the individual user account files.
get hold of a good advanced book on apache and read the online manual.
the online php manual is also a good place to start.
you can download a complete pdf manual for MySql - highly recommended

BjarneDM

1:50 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



so - in the end you'll end up with a standard client directory like this:

mysql
- containing the client mysql database
- remember to set chown -R mysql:mysql
cgi-bin
- contains all the cgi programs for the client
- if you only want the person to use some specific cgi's
- set chown -R root:client ; chmod -R 755
documents
- contains the client web-site
php-includes
- for handling php include files that aren't accessible by directly accessing a URL
- useful for storing php macros for logging in to mysql
tmp
- for the php session files