PHP working only within virtual domains

Discussion in 'Installation/Configuration' started by xefil, Jan 21, 2010.

  1. xefil

    xefil New Member

    Hello to all,

    I've installed ISPConfig 3.0.1.6 on a fresh CentOS 5.4 following online guide.
    All works fine, until I've created a first test slot domain.
    I've seen the PHP files could be interpreted by apache only if they are into the slot of the new domain.
    If I try to open squirrelmail (http://myserveriporname/squirrelmail/) I obtain an empty page.
    The same for roundcube.
    These sites (Aliases) has worked without problems at the beginning.
    To note, the same happen if I try to open a file with only the following istruction:
    <?=phpinfo();?>
    Under the slot it works, in the squirrelmail or roundcube folder not.
    If I open a html page, it works.
    No errors into logs.

    Any idea?

    Simon
     
  2. yoplait

    yoplait Member

    that's exactly the same problem for me in subdomains.
    In the main domain, php works, but in the subdomains, php doesn't work, but html does.

    I'll try to find the problem on my side...
     
  3. yoplait

    yoplait Member

    As I can see :
    - subdomain.domain.org/truc.html works fine.
    - subdomain.domain.org/truc.php (with the same file renamed) doesn't work.

    The error is :
    Code:
    Not Found
    
    The requested URL /php5-cgi/truc.php was not found on this server.
    
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    
     
  4. oilyflutesalad

    oilyflutesalad New Member

    You need to add the paths to the open_basedir directives in the vhost file for each site or, if you prefer, remove it completely, though removing it is a security risk and shouldn't be done.
     
  5. yoplait

    yoplait Member

    If I can understand, I have to add a PHP option in each PHP file of the subdomain ??
    Is it an option I can put in the site's option configuration, iscponfig interface ?

    In fact, I can't understand the real problem : the subdomain belongs to a main domain, and the subdomain folder is in the main domain folder ... Where does the problem come from ?
     
  6. oilyflutesalad

    oilyflutesalad New Member

    In SSH, type in:
    Code:
    cd /etc/apache2/sites-available | ls -l
    Then edit the vhost file for the domain/subdomain you want. eg
    Code:
    vi mynewwebsite.com.vhost
    Look for this line:
    Code:
        php_admin_value open_basedir [file paths here]
    And change it to this:
    Code:
        php_admin_value open_basedir /var/www/clients/client1/web1/web:/var/www/clients/client1/web1/tmp:/usr/share/php5:/tmp:/usr/share/phpmyadmin
    Mine says client1 and web1, but yours will probably be different so make sure you put the correct client and web numbers in.
     
  7. xefil

    xefil New Member

    Ok, seems same problem, but what about my scenario?
    Do I have to add some directives to my "/etc/httpd/conf.d/roundcube.conf" that I've added, or in "/etc/httpd/conf.d/squirrelmail.conf" that comes with ISPConfig and had worked until adding the first test website?

    Thank's!

    Simon
     
  8. oilyflutesalad

    oilyflutesalad New Member

    Config files should have nothing to do with it. Turn on display_errors in php.ini and I bet it'll come up with an open_basedir error.

    Can you still access pma and squirrelmail through the main domain (the one where you access ISPConfig)?
     
  9. xefil

    xefil New Member

    Thank you oilyflutesalad for the hints you have given to yoplait.
    Trying they have worked for mee to.
    The trick was "php_admin_value open_basedir".

    Now it works :)

    Simon
     
  10. oilyflutesalad

    oilyflutesalad New Member

    Am glad you've got yours working again xefil :)
    Yoplait, did my last post (with all the code blocks) help to fix yours?
     
  11. yoplait

    yoplait Member

    I didn't have time until now, I will try, I hope, this evening.

    Do I have to put it in the subdomain or in the main domain ?
    I think I understand it's in the subdomain, doesn't it ?

    Moreover, isn't it a "feature request" or "bug" for ispconfig in your opinion ? ... I'm really surprised to see that I need to do that stuff just for adding a subdomain :S ...
    (I'm not critizing ! I'm just trying to improve this great software ! ;) )
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Neither nor. Its not nescesary to add anything for a subdomain in ispconfig and I run a lot of them on my servers all with working php.

    Just make sure that your subdomain exists in dns and that the subdomain is either added as website were you enabled php or if you added it as subdomain to an existing website, then this existing website must have php enabled. If you dont anable php in the underlaying website, you can not run php scripts of course.
     
  13. yoplait

    yoplait Member

    Ok, so the question is always there ...
    This is exactly the problem : the main domain has php and it works very well, but not in the subdomain !
    And if I understand well what you mean, it should work very well this way !
    In the main domain, I have a wordpress website. In the subdomain I just have a .php file with "hello world" inside. (and a .html, with the same code...)
    Wordpress works great, html works great, and the php "hello world" fails... :(

    My configuration : ispconfig 3.0.1.6
    - main domain : ipadress *, CGI, SSI, suEXEC, Own Error-Documents and CGI as PHP without SSL, autosub www.
    - sub domain : test , domain.org, L, /test/,
    - in DNS of ispconfig : A test server-ip-adress
    - in the DNS area of my domain "provider (?)" : test.domain.org A server-ip-adress

    - here is also the conf file domain.conf for apache :
    Code:
    <Directory /var/www/domain.org>
        AllowOverride None
        Order Deny,Allow
        Deny from all
    </Directory>
    
    <VirtualHost *:80>
          DocumentRoot /var/www/clients/client0/web4/web
    
        ServerName domain.org
        ServerAlias www.domain.org
        ServerAlias test.domain.org
        ServerAdmin [email protected]
    
        ErrorLog /var/log/ispconfig/httpd/domain.org/error.log
    
        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 503 /error/503.html
    
        <Directory /var/www/domain.org/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
        <Directory /var/www/clients/client0/web4/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
    
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
    
        # cgi enabled
            <Directory /var/www/clients/client0/web4/cgi-bin>
          Order allow,deny
          Allow from all
                                        
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
    
        # cgi enabled
            <Directory /var/www/clients/client0/web4/cgi-bin>
          Order allow,deny
          Allow from all
        </Directory>
        ScriptAlias  /cgi-bin/ /var/www/clients/client0/web4/cgi-bin/
        AddHandler cgi-script .cgi
        AddHandler cgi-script .pl
        # suexec enabled
        SuexecUserGroup web4 client0
        # php as cgi enabled
        ScriptAlias /php5-cgi /var/www/php-cgi-scripts/web4/php-cgi-starter
        Action php5-cgi /php5-cgi
        AddHandler php5-cgi .php .php3 .php4 .php5
        <Directory /var/www/php-cgi-scripts/web4/>
            Order allow,deny
            Allow from all
        </Directory>
    
        RewriteEngine on
        RewriteCond %{HTTP_HOST}   ^test.domain.org [NC]
        RewriteRule   ^/(.*)$ /var/www/clients/client0/web4/web/test/$1  [L]
    </VirtualHost>
    
    What do you think about that ?
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    If you want to have a subdomain with a separate directory, you should create it as separate wesite (domian) by entering sub.domain.com into the domain field of the domain form and not as subdomain. The reason that your config does not work is wordpress as wordpress uses a .htaccess file in the main directory of the site which also affects the test subdirectory.
     
    Last edited: Jan 22, 2010
  15. yoplait

    yoplait Member

    I can see a .htaccess in the main domain, but it seems to be empty :
    Code:
    # BEGIN WordPress
    
    # END WordPress
    
    If I rename this htaccess file, it doesn't change anything.
    Moreover, there is another domain without wordpress which has the same subdomain problem about php
    I don't really want to have my subdomain in a separate directory, because I'd like to have the same FTP user and all in the same directory is easier for me anyway...
    But first of all, my goal is to understand how subdomains works in ispconfig ^^ .
    Isn't it a problem with the PHP choice in website ispconfig configuration ?

    Really, I can't understand where i did a mistake (on 2 websites ... ??)
     
  16. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok. Sou you recreated the subdomains as separate websites as I told you above and they are still not working?

    Subdomains are domain aliases which can be redirected with a apache rewrite rule.

    See here: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

    But what you wanted is a separate website where the subdomain shall point to, so you have to create a domain (website) and not add it as subdomain which is a website alias.

    no.

    But by the way, it would have been really better if you would have made a new thread, as this is all not related to the issues of the original poster.
     
  17. yoplait

    yoplait Member

    It's my fault, sorry, but I thought at the beginning it was exactly the same problem...
    Don't hesitate to move this discussion if it's necessary ;) .

    I think I understand what you say as that subdomain is not good to make with ispconfig and make a new domain for a subdomain is better.
    I will do it like this !

    I've tested to create directly the subdomain like a new website in isconfig and it works great. So I will keep this solution. Thanks for you help and sorry for the "squat" of this thread ! :S
     

Share This Page