Accessing phpMyAdmin returns php as text

Discussion in 'Installation/Configuration' started by RavanH, Nov 15, 2013.

  1. RavanH

    RavanH New Member

    Hi all,

    After following the instructions on http://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3-p4 "The Perfect Server - Debian Wheezy (Apache2, BIND, Dovecot, ISPConfig 3)", with the difference that I installed PHP5.5 and did not include mod_php5 and mod_suphp (instead installing both mod_fcgid and mod_fastcgi with PHP-FPM) I ran into the weirdest thing.

    I was able to connect to ISPConfig3 via the usual *:8080 port and succesfully created several sites (setting them to use PHP-FPM)... so far so good... But when I want to connect to phpMyAdmin via *:8081/phpmyadmin, I get to see the index.php content as text instead of a rendered interface like expected.

    What's weird is that when leaving out :8081 (so straight to */phpmyadmin I get the phpMyAdmin interface. Plus, I tried a phpinfo.php test file in the /var/www/apps dir and accessing that with *:8081/phpinfo.php it gets rendered just fine.

    Can anybody enlighten me on what is going on / wrong ? And will this mean the ISPConfig Monitoring App will not work on my server ?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The titorial does not contain an optional modules, so each module that you do not install will cause a function on the server to fail.

    phpmyadmin uses mod_php. as you did not install it, phpmyadmin fails.
     
  3. RavanH

    RavanH New Member

    Hi Till, thanks for your reply :)

    But like I described, phpmyadmin does work on the server without mod_php5. It seems to be using FPM/FastCGI when accessed via port 80 on /phpmyadmin and it works just perfect there... It's only on port 8081 that it returns plain text instead of passing PHP to CGI like it is supposed to ... Well, as far as I guess because the phpinfo.php via port 8081 reports "Server API : CGI/FastCGI"

    If phpmyadmin cannot run on CGI/FastCGI then any requests should at least cause a PHP or internal server error instead of Apache simply responding with a text dump of the index.php file content.

    Or am I wrong?
     
    Last edited: Nov 15, 2013
  4. RavanH

    RavanH New Member

    UDATE:

    Till, you did put me on the right track!

    To make phpmyadmin work with CGI/FastCGI there are some changes to the file /etc/apache2/sites-available/apps.vhost needed:

    What was:
    Code:
      <IfModule mod_fcgid.c>
        DocumentRoot /var/www/apps
        SuexecUserGroup ispapps ispapps
        <Directory /var/www/apps>
          Options Indexes FollowSymLinks MultiViews +ExecCGI
          AllowOverride AuthConfig Indexes Limit Options FileInfo
          AddHandler fcgid-script .php
          FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
          Order allow,deny
          Allow from all
        </Directory>
      </IfModule>
    
    Should become:
    Code:
      <IfModule mod_fcgid.c>
        DocumentRoot /var/www/apps
        SuexecUserGroup ispapps ispapps
        <Directory /var/www/apps>
          Options Indexes FollowSymLinks MultiViews +ExecCGI
          AllowOverride AuthConfig Indexes Limit Options FileInfo
          AddHandler fcgid-script .php
          FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
          Order allow,deny
          Allow from all
        </Directory>
        <Directory /usr/share/phpmyadmin>
          Options Indexes FollowSymLinks MultiViews +ExecCGI
          AllowOverride AuthConfig Indexes Limit Options FileInfo
          AddHandler fcgid-script .php
          FCGIWrapper /var/www/php-fcgi-scripts/apps/.php-fcgi-starter .php
          Order allow,deny
          Allow from all
        </Directory>
      </IfModule>
    
    Notice how the first part stays unaltered while the added <Directory /usr/share/phpmyadmin>...</Directory> part contains an exact copy of the directive above it...

    After restarting Apache, it now seems to work :)

    I wonder why phpmyadmin works without hesitation in PHP-FPM while this extra work is needed for PHP-CGI. Anyway, thanks again!
     
    Last edited: Nov 16, 2013
  5. RavanH

    RavanH New Member

    UPDATE 2:

    A similar modification to the file /etc/apache2/sites-available/ispconfig.vhost (adding a <Directory /usr/share/phpmyadmin> directive holding a copy of the one above) will make phpmyadmin links from within the ISPConfig admin panel work too :)
     
  6. RavanH

    RavanH New Member

    UPDATE 2.b:

    I suppose adding
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}:8080%{REQUEST_URI}
    
    to the /etc/phpmyadmin/apache.conf file (just below <Directory /usr/share/phpmyadmin>) should improve security... Of course, this uses the main ISPConfig admin panel certificate so might cause a warning message for users that come in via another (their own vhost) domain. I suppose replacing %{HTTP_HOST} with the servers qualified domain would solve that.

    Or is this a bad approach?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The link in ispconfig is freely configurable, so you can use any location for phpmyadmin. The ispconfg vhost should not be modified this way as neither phpmyadmin nor any other software then ispconfig igself should not be accessible on port 8080 for security reasons.
     
  8. RavanH

    RavanH New Member

    Oh... but by default, the phpmyadmin link from inside the ISPConfig panel uses port 8080. Why's that?
     
  9. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    Because the phpmaydmin link is /phpmyadmin. So it's on the same host as ispconfig itself, which is on port 8080.
     
  10. RavanH

    RavanH New Member

    Yeah, obviously... But why is the default setting "/phpmyadmin" if it is not wise to have that?

    Anyway, I modified that setting to "https://[SERVERNAME]/phpmyadmin/" and that works fine now. Funny though that modifying it to hold any url parameters like "https://[SERVERNAME]/phpmyadmin/?db=[DATABASENAME]" (which is a suggested placeholder) will result in an error...
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    The default setup is absolutely correct and works out of the box if the sever matches ispconfigs system requirements, which are described in the perfect setup guides. That it does not work on your server is caused by the software modules that you left out from the guide, in this case, apache mod_php.
     

Share This Page