Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

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

0
Office-Shadow
Asked:
Office-Shadow
  • 5
  • 4
3 Solutions
 
fosiul01Commented:
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

0
 
Office-ShadowAuthor Commented:
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
0
 
fosiul01Commented:
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fosiul01Commented:
quick question :
in your httpd.conf , did you enable this line

Include /etc/httpd/conf/vhosts

without enabling this line, virtual host concept will not work
0
 
Office-ShadowAuthor Commented:
Hiya, no I do not have that line because I do not have a file at /etc/httpd/conf/vhosts
0
 
fosiul01Commented:
are  you using linux or anything else ??

if you are using Red hat or Centos or even Fedora, you should have a file called httpd.conf

and in httpd.conf you will have to mention where is your vhosts file which is by this line etc/httpd/conf/vhosts

and in vhosts file you will have to configure your document root file

now telll me which linux you are using??
0
 
Office-ShadowAuthor Commented:
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.
0
 
Office-ShadowAuthor Commented:
What it looks like to me is that I have apache and apache2 installed, and I've been configuring apache2 - however it is apache that is actually running!

How do I disable apache and run apache2 instead?
0
 
Office-ShadowAuthor Commented:
Yes that was the problem, I've now disabled apache and started apache and have got my vhost working! thanks for your help fosiul01
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now