Link to home
Start Free TrialLog in
Avatar of Office-Shadow
Office-ShadowFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Virtual hosts not workiing on Apache

Hi,

We have one production server which hosts a dozen or so domains, some of which have many subdomains.

This server is running PHP4 and I want to upgrade it to PHP5. To make sure there are no problems doing so, I want to copy the existing sites onto a development server set up with PHP5 and start debugging that.

I've got the server set up with Debian (same as the live server) and have installed the latest stable versions of PHP/MYSQL on it.

After consulting a more server-savvy friend it was suggested that I:
   * Copy across the contents of /etc/apache2/sites-available
   * Copy across the website place to the same location on thh new server
   * Point the relevent domains to the new server's IP in my hosts file

So I attemted this for a single domain and the first problem encountered was that, other than a file called 'default', there was nothing in my sites-available folder on the live server.

These domains were originally set up using Plesk which seems to have a different way of managing vhosts. Looking in /var/www/vhosts/example.com/conf there is a file called httpd.include which seemed to contain the required information (attached), so I tried copying this to sites-available and disabling 'default'.

I've restarted apache, and tried to access the URL in my browser and it just takes lists the contents of /var/www instead of showing the

As you can tell, I'm no server expert - I'm a programmer - so I'm not entirely sure what I'm doing!

Any help would be much appreciated!
NameVirtualHost *:80
 
<VirtualHost *:80>
	ServerName   example.com
	ServerAlias  www.example.com
	UseCanonicalName Off
	ServerAdmin  "exampel@example.com"
	DocumentRoot /var/www/vhosts/example.com/httpdocs
	CustomLog  /var/www/vhosts/example.com/statistics/logs/access_log plesklog
	ErrorLog  /var/www/vhosts/example.com/statistics/logs/error_log
<IfModule mod_userdir.c>
	UserDir /var/www/vhosts/example.com/web_users
</IfModule>
	ScriptAlias  /cgi-bin/ /var/www/vhosts/example.com/cgi-bin/
	Alias  /plesk-stat /var/www/vhosts/example.com/statistics/
	<Location  /plesk-stat/>
		Options +Indexes
	</Location>
	<Location  /plesk-stat/logs/>
		Require valid-user
	</Location>
	Alias  /webstat /var/www/vhosts/example.com/statistics/webstat
	Alias  /webstat-ssl /var/www/vhosts/example.com/statistics/webstat-ssl
	Alias  /ftpstat /var/www/vhosts/example.com/statistics/ftpstat
	Alias  /anon_ftpstat /var/www/vhosts/example.com/statistics/anon_ftpstat
	Alias  /awstats-icon /usr/share/awstats/icon
	<IfModule mod_ssl.c>
		SSLEngine off
	</IfModule>
	<Directory /var/www/vhosts/example.com/httpdocs>
	<IfModule mod_perl.c>
	<Files ~ (\.pl$)>
		SetHandler perl-script
		PerlHandler ModPerl::Registry
		Options ExecCGI
		allow from all
		PerlSendHeader On
	</Files>
	</IfModule>
	<IfModule mod_php4.c>
		php_admin_flag engine on
		php_admin_flag safe_mode off
		php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:/tmp"
	</IfModule>
	<IfModule mod_php5.c>
		php_admin_flag engine on
		php_admin_flag safe_mode off
		php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:/tmp"
	</IfModule>
	<IfModule mod_python.c>
	<Files ~ (\.py$)>
		SetHandler python-program
		PythonHandler	mod_python.cgihandler
	</Files>
	</IfModule>
		Options -Includes +ExecCGI
	</Directory>
	<Directory /var/www/vhosts/example.com/web_users>
	<IfModule mod_php4.c>
		php_admin_flag engine off
	</IfModule>
	<IfModule mod_php5.c>
		php_admin_flag engine off
	</IfModule>
	</Directory>
</VirtualHost>

Open in new window

Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi yah

the Vhosts file should be in /etc/httpd/conf

and file called vhosts

I am attaching my vhosts, try to follow , hopefully it will work.

you will have to type your document path like this :  DocumentRoot /var/www/html/intranet

but in your vhosts file i am seeing like this : DocumentRoot /var/www/vhosts/example.com/httpdocs
I dont think, you have vhosts folder under your www folder

anyway, see my vhosts configuration, if it help you

First virtual host is a copy of the main server configuration
# since in the absence of a host name, the first virtualhost applies
 
<VirtualHost *:80>
       ServerAdmin root@localhost
       ServerName Myserver
       DocumentRoot "/var/www/html"
       <Directory />
               Options FollowSymLinks
               AllowOverride None
       </Directory>
       <Directory "/var/www/html">
                       Options Indexes FollowSymLinks
                       AllowOverride None
                       Order allow,deny
                       Allow from all
       </Directory>
       Alias /icons/ "/var/www/icons/"
       <Directory "/var/www/icons">
                       Options Indexes MultiViews
                       AllowOverride None
                       Order allow,deny
                       Allow from all
       </Directory>
       ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
       <Directory "/var/www/cgi-bin">
                       AllowOverride None
                       Options None
                       Order allow,deny
                       Allow from all
       </Directory>
</VirtualHost>
 
 
<VirtualHost *:80>
       DocumentRoot /var/www/html
       ServerAdmin root@localhost
       ServerName bvhelp.myserver.local
       ServerAlias bvhelp
       Options FollowSymLinks
       DirectoryIndex /cgi-bin/viewhtml.pl
       <FilesMatch "\.(MAN|WHP|HCP|MCP|TRE|HLP|FLG|RS)$">
               ErrorDocument 404 /cgi-bin/viewhtml.pl
       </FilesMatch>
</VirtualHost>
 
<VirtualHost *:80>
       DocumentRoot /var/www/html/reports
       ServerAdmin it@myserver.com
       ServerName reports.myserver.local  ServerAlias
reports.myserver.local     ServerAlias
reports
 
       <Directory />
               AllowOverride None
       </Directory>
 
       DirectoryIndex index.html
       AccessFileName .htaccess
       ServerSignature On
       ScriptAlias /cgi-bin/ "/var/www/html/reports/cgi-bin/"
 
       <Directory "/var/www/html/reports/cgi-bin/">
               AllowOverride None
               Options None
               Order Allow,Deny
               Allow from all
       </Directory>
 
       Addhandler cgi-script .cgi
       SetEnv LANG en_GB
</VirtualHost>
 
<VirtualHost *:80>
       DocumentRoot /var/www/html/intranet
       ServerAdmin it@myserver.com
       ServerName owl.myserver.local
       ServerAlias owl
       ServerAlias owl.myserver.local
</VirtualHost>
 
 
<VirtualHost *:80>
DocumentRoot /var/www/html/development
ServerAdmin it@myserver.com
ServerName developer.myserver.local
ServerAlias developer.myserver.local
ServerAlias developer
       <Directory "/var/www/html/development">
       Order Allow,Deny
       Allow from all
       </Directory>
 
       <Directory "/var/www/html/dev/internal">
       Order Deny,Allow
       Deny from all
       Allow from 193.XXX.XXX
       </Directory>
</VirtualHost>
 
 
 
 
</VirtualHost>

Open in new window

Avatar of Office-Shadow

ASKER

Thanks fosiul, but I'm really not sure what I'd need to change from your vhosts file.

As an update, I have tried starting again and followed this guide exactly: http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2

I still had the same result of listing the /var/www/ contents.

Any more suggestions
HI  yah, they way your tutorial described, i did different way.
i didnot had to create any file called dev.example.com

give little bit of time, i need to see little bit of more configuration in myserver. as i am out of office
i will do that tomorrow morning
SOLUTION
Avatar of fosiul01
fosiul01
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hiya, no I do not have that line because I do not have a file at /etc/httpd/conf/vhosts
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm running Debian linux.

I have a couple different httpd.conf's:

/etc/apache2/httpd.conf - this one is blank
/etc/apache/httpd.conf - the last line of this is 'Include /etc/apache/conf.d', which is an empty directory.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes that was the problem, I've now disabled apache and started apache and have got my vhost working! thanks for your help fosiul01