Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I have configured virtual host file on apache and when running php files in the browser I get php code... Here is my vhost configuration: Code: <VirtualHost *:80> ServerAdmin ...
  1. #1
    Just Joined!
    Join Date
    Jan 2012
    Posts
    12

    Apache displays php code

    Hello,

    I have configured virtual host file on apache and when running php files in the browser I get php code...

    Here is my vhost configuration:
    Code:
    <VirtualHost *:80>
            ServerAdmin sample(at)sample.com
            ServerName sample.sample.com
            DocumentRoot /var/www/html/test
            ErrorLog /var/log/httpd/test_error.log
            CustomLog /var/log/httpd/test_access.log combined
            AddType application/x-httpd-php .php .html .htm
    </VirtualHost>
    Could you please suggest what else I need to include or what to check?

    Regards

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    Is PHP installed? How did you install it? It should be installed via yum (versus manually) along with Apache, for a painless Apache+PHP webserver.

    Normally, you should be able to do:

    Code:
    yum install httpd php
    and
    Code:
    service httpd restart
    and be off and running. Maybe you can just back up any modified apache/php config files and reinstall the packages, to be on the safe side. To see if any packages have been modified, you can run:

    Code:
    rpm -qV httpd
    rpm -qV php
    After confirming that, I'd start with a PHP file in the DocumentRoot first (e.g. /var/www/html/phpinfo.php), to make sure you can get any PHP working at all.

    Also you might want to temporarily enable error output in the PHP.ini file (/etc/php.ini, probably).

  3. #3
    Just Joined!
    Join Date
    Jan 2012
    Posts
    12
    Hi,

    I have solved my problem. It's kind of my fault.
    First of all I didn't have this record "LoadModule php5_module modules/libphp5.so" in my http.conf file.
    I was thinking that I don't need it because I do have file "php.conf" where mentioned record exists. But file "php.conf" was not loaded by apache.

    The problem was that in the file "http.conf", I have specified that config file for virtual host is "Include vhost.conf" and I commented "Include conf.d/*.conf" so because of that "php.conf" was not loaded.

    Thanks and sorry for taking your time...

  4. #4
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    Quote Originally Posted by zibrnp View Post
    Hi,

    I have solved my problem. It's kind of my fault.
    First of all I didn't have this record "LoadModule php5_module modules/libphp5.so" in my http.conf file.
    I was thinking that I don't need it because I do have file "php.conf" where mentioned record exists. But file "php.conf" was not loaded by apache.

    The problem was that in the file "http.conf", I have specified that config file for virtual host is "Include vhost.conf" and I commented "Include conf.d/*.conf" so because of that "php.conf" was not loaded.

    Thanks and sorry for taking your time...
    Glad you got it sorted. I did not have to manually do that stuff on my box, though. The packages are already configured to work, which is why I asked. For example, the file:

    /etc/httpd/conf.d/php.conf

    belongs to the php package, and loads the module like you had to do.

    Then in /etc/httpd/conf/httpd.conf, there is this bit:

    Code:
    #
    # Load config files from the config directory "/etc/httpd/conf.d".
    #
    Include conf.d/*.conf
    which calls the above php.conf file, which loads the module.

    anyway, important thing is, you got it working!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...