0

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

thegrip
  • 1
  • 3

6 Answers6

1

PHP is not being turned on for your DocumentRoot.

<IfModule mod_php5.c>
php_admin_flag engine on
</IfModule>

needs to appear within either the Virtualhost section of the conf or within a Directory section - but it needs to be the directory listed as Document root:

<Directory  /var/www/vhosts/domain.com/subdomains/dev/httpdocs>
    <IfModule mod_php5.c>
      php_admin_flag engine on
      php_admin_flag safe_mode off
      php_admin_value open_basedir "/var/www/vhosts/domain.com/subdomains/dev/httpdocs:/tmp"
    </IfModule>
</Directory>
Owen
  • 11
  • 1
0

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.

Jonathan Ross
  • 2,183
  • 11
  • 14
  • 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 07: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 01 '11 at 04: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 01 '11 at 05:41
0

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 ?

user9517
  • 115,471
  • 20
  • 215
  • 297
0

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.

Nacho
  • 1
  • 1
0

you can also put a .htaccess file in the document root directory with following code

# Set the default handler.
DirectoryIndex index.php index.html index.htm
0

Make sure cgi support enabled for the second website. Please gives an option to enable/disable CGI support. This requires for the php to work as CGI

Karthik
  • 114
  • 4