Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm helping maintain an e-commerce site that is run on Magento. This site is an outlet for our wholesale customers. We have recently decided to open a second store to reach out to our Retail customers. We decided to set up another website inside of our magento store so that we can share the products across both stores.

I'm in the process of setting up this new site on the server, but have run into an issue. I've set up the second vhost for the new retail site, and I've made the DocumentRoot for this vhost the same as for the wholesale site, so we can use one magento application for both sites. This is where the error occurs.

When I browse to the new store it triggers a download of the index.php file. So I know the DocumentRoot directive is working, but it seems like PHP is being broken in the process.

I'm using plesk to manage the server. I've made sure that PHP is turned on in both vhosts and still get the same issue.

Does this sound like a problem of PHP breaking, or is it possible my vhost.conf file is set up incorrectly? (Although the vhost is managed by plesk and appears correct)

Any help will be much appreciated.

EDIT:

Here's the vhost configs (generated by plesk):

<VirtualHost IPADDRESS:80>
ServerName   domain.com:80
ServerAdmin  "myemail@gmail.com"
DocumentRoot /var/www/vhosts/domain.com/subdomains/tk/httpdocs
CustomLog  /var/www/vhosts/domain.com/statistics/logs/access_log plesklog
ErrorLog  /var/www/vhosts/domain.com/statistics/logs/error_log
<IfModule mod_ssl.c>
    SSLEngine off
</IfModule>
<Directory  /var/www/vhosts/domain.com/subdomains/tk/httpdocs>
<IfModule mod_php4.c>
    php_admin_flag engine on
    php_admin_flag safe_mode off
    php_admin_value open_basedir "/var/www/vhosts/domain.com/subdomains/tk/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/mkdesigngroup.com/subdomains/tk/httpdocs:/tmp"
</IfModule>
    Options -Includes -ExecCGI
</Directory>
Include /var/www/vhosts/domain.com/subdomains/tk/conf/vhost.conf

And here's what I've added in vhost.conf (which is included by plesk):

DocumentRoot /var/www/vhosts/domain.com/subdomains/dev/httpdocs

-grip

share|improve this question
    
Can you show us the /var/www/vhosts/domain.com/subdomains/tk/conf/vhost.conf please –  Iain Mar 30 '11 at 19:59
    
lain, just added both the relevant http.include and vhost.conf code above –  thegrip Mar 30 '11 at 20:11

3 Answers 3

If it's not interpreting index.php properly and not displaying it as a page it in the browser then the Web Server doesn't know .php should be treated as a viewable file.

There's a file to enable index.php files alongside index.html. I'd say it's a PHP configuration tweak that's needed.

--edit--

I've maybe confused two things here by not being clear.

On Ubuntu Lucid there's a file (/etc/apache2/mods-available/dir.conf) to allow index.php to be treated as an index file, ie you can write www.me.com instead of www.me.com/index.php to view it.

<IfModule mod_dir.c>

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

If that's present then there's another PHP tweak needed like the famous php5-mysql needed to make PHP talk to a MySQL database.

share|improve this answer
    
I added a DirectoryIndex directive to the vhost.conf file for the second vhost, but no luck. –  thegrip Mar 30 '11 at 19:53
    
The code above should exist in the /etc/apache2/mods-available/dir.conf directory AFAIK not the individual Vhost files. –  Jonathan Ross Mar 31 '11 at 7:21
    
Yep since it's already in there I went ahead and removed it from vhost.conf. Looks like it may be the php5-mysql issue, although wouldn't I see a php error in that case? –  thegrip Apr 1 '11 at 4:13
    
You could try apt-get install php5-mysql to see if that package is install. It's a famous gotcha. You don't see an error usually. –  Jonathan Ross Apr 1 '11 at 5:41

That your Apache just serves up the .php file without trying to interpret it suggests that the second vhost isn't configured correctly. Did you restart Apache after enabling php on the second vhost ?

share|improve this answer
    
Yea I updated the plesk configs and then restarted apache as well. –  thegrip Mar 30 '11 at 19:49

I had the same issue and solved it by adding the following lines to the vhost.conf:

DocumentRoot /var/www/vhosts/domain.com/subdomains/dev/httpdocs

<Directory /var/www/vhosts/domain.com/subdomains/dev/httpdocs>
        <IfModule sapi_apache2.c>
                php_admin_flag engine on
        </IfModule>
        <IfModule mod_php5.c>
                php_admin_flag engine on
        </IfModule>
</Directory>

The first line changes the document root but, for some reason, PHP stops working. The rest of the lines bring PHP back to life.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.