Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
Hello, I have Suse9.1 with Apache 2.0, php 4.3, If i access my php page http://localhost/index.php , it asks for download, my php page is not executing ?? i have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2004
    Location
    Sydney, Australia
    Posts
    42

    php and cgi not working on suse9.1


    Hello,

    I have Suse9.1 with Apache 2.0, php 4.3, If i access my php page http://localhost/index.php, it asks for download, my php page is not executing ?? i have download the tar file -> ./configure, make & make install.

    If i try to execute my cgi program, this is what i get

    #!/usr/local/bin/perl
    print ("Content-type: text/html\n\n");
    print ("<HTML>");
    print ("<HEAD>");
    print ("<TITLE>");
    print ("Hello World");
    print ("</TITLE>");
    print ("</HEAD>");
    print ("<BODY>");
    print ("<H2>Hello World</H2>");
    print ("</BODY>");
    print ("</HTML>");

    #print "Content-type: text/plain\n\n";
    #print 'Hello World!';

    cgi is not executing as well. Apache is running. can anyone advise me to get my php and cgi to work ??

    any help would be highly appricated ?

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    how bout posting parts of your apache httpd.conf file. specifically the parts where php is loaded and also the parts that talk about cgi

    for php your httpd.conf needs something like this

    Code:
    # Load php4_module
    LoadModule php4_module        modules/libphp4.so
    
    # Tell Apache to parse certain extensions as PHP.  For example,
    #    let's have Apache parse the .php extension as PHP.  You could
    #    have any extension&#40;s&#41; parse as PHP by simply adding more, with
    #    each separated by a space.  We'll add .phtml to demonstrate
    
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps
    for your cgi it sounds like your cgi folder is not executable, defined by your httpd.conf
    http://www.google.com/search?hl=en&l...he&btnG=Search

  3. #3
    Just Joined!
    Join Date
    Sep 2004
    Location
    Sydney, Australia
    Posts
    42
    Hey,

    I don't have any php modules loaded in httpd.conf file. If i add
    LoadModule php4_module modules/libphp4.so apache gives an error listed below :

    Cannot load /srv/www/modules/libphp4.so into server: /srv/www/modules/libphp4.so: cannot open shared object file: No such file or directory

    I don't have libphp4.so or any modules ? PLease advise what to do.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    13
    On Debian you have this library file in the directory

    /usr/lib/apache/1.3/libphp4.so

    On Redhat and Fedora
    it will be in

    /usr/lib/

    or

    /[php installation directory]/lib

    try to search using

    $ locate libphp4.so

    good luck

  6. #5
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    You may be best posting your httpd.conf (with servernames/ips changed) up somewhere for us to look at. We would then be able to help you much easier.

    As for your perl scripts not executing in the directory you want, you need to ensure they are either in the $DocumentRoot/cgi-bin/ directory (do a search for ScriptAlias to find exactly where this is). Or you need to have that directory allowed to execute cgi scripts with something like:

    <Directory /$DocumentRoot/perlstuff/>
    Options +ExecCGI
    </Directory>

    Inside the appropriate VirtualHost block.

    The PHP scripts probably look the same (just text, not being parsed) for one reason, with a couple of different solutions. See if you can find the exact configure line you used to make the php module. Did you specify a '--with-apxs2filter' on the compilation? If not, and there is no libphp4.so on your machine, then you either need to recompile it, or use the CGI version of the program. Let us know which it is, and we will do what we can to help you further.

    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  7. #6
    Just Joined!
    Join Date
    Sep 2004
    Location
    Sydney, Australia
    Posts
    42
    I don't have a control panel. I am testing on a Local server. here is my httpd.conf file entries :

    #
    # /etc/apache2/httpd.conf
    #
    # This is the main Apache server configuration file. It contains the
    # configuration directives that give the server its instructions.
    # See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about
    # the directives.

    # Based upon the default apache configuration file that ships with apache,
    # which is based upon the NCSA server configuration files originally by Rob
    # McCool. This file was knocked together by Peter Poeml <poeml+apache@suse.de>.

    # If possible, avoid changes to this file. It does mainly contain Include
    # statements and global settings that can/should be overridden in the
    # configuration of your virtual hosts.


    # Overview of include files, chronologically:
    #
    # httpd.conf
    # |
    # |-- uid.conf . . . . . . . . . . . . . . UserID/GroupID to run under
    # |-- server-tuning.conf . . . . . . . . . sizing of the server (how many processes to start, ...)
    # |-- sysconfig.d/loadmodule.conf . . . . .[*] load these modules
    # |-- listen.conf . . . . . . . . . . . . . IP adresses / ports to listen on
    # |-- mod_log_config.conf . . . . . . . . . define logging formats
    # |-- sysconfig.d/global.conf . . . . . . .[*] server-wide general settings
    # |-- mod_status.conf . . . . . . . . . . . restrict access to mod_status (server monitoring)
    # |-- mod_info.conf . . . . . . . . . . . . restrict access to mod_info
    # |-- mod_usertrack.conf . . . . . . . . . defaults for cookie-based user tracking
    # |-- mod_autoindex-defaults.conf . . . . . defaults for displaying of server-generated directory listings
    # |-- mod_mime-defaults.conf . . . . . . . defaults for mod_mime configuration
    # |-- errors.conf . . . . . . . . . . . . . customize error responses
    # |-- ssl-global.conf . . . . . . . . . . . SSL conf that applies to default server _and all_ virtual hosts
    # |
    # |-- default-server.conf . . . . . . . . . set up the default server that replies to non-virtual-host requests
    # | |--mod_userdir.conf . . . . . . . . enable UserDir (if mod_userdir is loaded)
    # | `--conf.d/apache2-manual?conf . . . add the docs ('?' = if installed)
    # |
    # |-- sysconfig.d/include.conf . . . . . .[*] your include files
    # | (for each file to be included here, put its name
    # | into APACHE_INCLUDE_* in /etc/sysconfig/apache2)
    # |
    # `-- vhosts.d/ . . . . . . . . . . . . . . for each virtual host, place one file here
    # `-- *.conf . . . . . . . . . . . . . (*.conf is automatically included)
    #
    #
    # Files marked[*] are created from sysconfig upon server restart: instead of
    # these files, you edit /etc/sysconfig/apache2

    # Filesystem layout:
    #
    # /etc/apache2/
    # |-- conf.d/
    # | |-- apache2-manual.conf . . . . . . . conf that comes with apache2-doc
    # | |-- mod_php4.conf . . . . . . . . . . (example) conf that comes with apache2-mod_php4
    # | `-- ... . . . . . . . . . . . . . . . other configuration added by packages
    # |-- default-server.conf
    # |-- errors.conf
    # |-- httpd.conf . . . . . . . . . . . . . top level configuration file
    # |-- listen.conf
    # |-- magic
    # |-- mime.types -> ../mime.types
    # |-- mod_autoindex-defaults.conf
    # |-- mod_info.conf
    # |-- mod_log_config.conf
    # |-- mod_mime-defaults.conf
    # |-- mod_perl-startup.pl
    # |-- mod_status.conf
    # |-- mod_userdir.conf
    # |-- mod_usertrack.conf
    # |-- server-tuning.conf
    # |-- ssl-global.conf
    # |-- ssl.crl/ . . . . . . . . . . . . . . PEM-encoded X.509 Certificate Revocation Lists (CRL)
    # |-- ssl.crt/ . . . . . . . . . . . . . . PEM-encoded X.509 Certificates
    # |-- ssl.csr/ . . . . . . . . . . . . . . PEM-encoded X.509 Certificate Signing Requests
    # |-- ssl.key/ . . . . . . . . . . . . . . PEM-encoded RSA Private Keys
    # |-- ssl.prm/ . . . . . . . . . . . . . . public DSA Parameter Files
    # |-- sysconfig.d/ . . . . . . . . . . . . files that are created from /etc/sysconfig/apache2
    # | |-- global.conf
    # | |-- include.conf
    # | `-- loadmodule.conf
    # |-- uid.conf
    # `-- vhosts.d/ . . . . . . . . . . . . . . put your virtual host configuration (*.conf) here
    # |-- vhost-ssl.template
    # `-- vhost.template


    # Load php4_module
    # LoadModule php4_module modules/libphp4.so

    # Tell Apache to parse certain extensions as PHP. For example,
    # let's have Apache parse the .php extension as PHP. You could
    # have any extension(s) parse as PHP by simply adding more, with
    # each separated by a space. We'll add .phtml to demonstrate

    #LoadModule php4_module /usr/lib/apache/libphp4.so

    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    AddType application/x-httpd-php .php4

    AddHandler cgi-script .cgi

    ScriptAlias /cgi-bin/ /usr/local/apache/cgi-bin/

    ### Global Environment ################################################## ####
    #
    # The directives in this section affect the overall operation of Apache,
    # such as the number of concurrent requests.

    # run under this user/group id
    Include /etc/apache2/uid.conf

    # - how many server processes to start (server pool regulation)
    # - usage of KeepAlive
    Include /etc/apache2/server-tuning.conf

    # ErrorLog: The location of the error log file.
    # If you do not specify an ErrorLog directive within a <VirtualHost>
    # container, error messages relating to that virtual host will be
    # logged here. If you *do* define an error logfile for a <VirtualHost>
    # container, that host's errors will be logged there and not here.
    ErrorLog /var/log/apache2/error_log

    # generated from APACHE_MODULES in /etc/sysconfig/apache2
    Include /etc/apache2/sysconfig.d/loadmodule.conf

    # IP addresses / ports to listen on
    Include /etc/apache2/listen.conf

    # predefined logging formats
    Include /etc/apache2/mod_log_config.conf

    # generated from global settings in /etc/sysconfig/apache2
    Include /etc/apache2/sysconfig.d/global.conf

    # optional mod_status, mod_info
    Include /etc/apache2/mod_status.conf
    Include /etc/apache2/mod_info.conf

    # optional cookie-based user tracking
    # read the documentation before using it!!
    Include /etc/apache2/mod_usertrack.conf

    # configuration of server-generated directory listings
    Include /etc/apache2/mod_autoindex-defaults.conf

    # associate MIME types with filename extensions
    TypesConfig /etc/apache2/mime.types
    DefaultType text/plain
    Include /etc/apache2/mod_mime-defaults.conf

    # set up (customizable) error responses
    Include /etc/apache2/errors.conf

    # global (server-wide) SSL configuration, that is not specific to
    # any virtual host
    Include /etc/apache2/ssl-global.conf

    # forbid access to the entire filesystem by default
    <Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
    </Directory>

    # use .htaccess files for overriding,
    AccessFileName .htaccess
    # and never show them
    <Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    </Files>

    # List of resources to look for when the client requests a directory
    DirectoryIndex index.html index.html.var

    ### 'Main' server configuration #############################################
    #
    # The directives in this section set up the values used by the 'main'
    # server, which responds to any requests that aren't handled by a
    # <VirtualHost> definition. These values also provide defaults for
    # any <VirtualHost> containers you may define later in the file.
    #
    # All of these directives may appear inside <VirtualHost> containers,
    # in which case these default settings will be overridden for the
    # virtual host being defined.
    #
    Include /etc/apache2/default-server.conf

    # Another way to include your own files
    #
    # The file below is generated from /etc/sysconfig/apache2,
    # include arbitrary files as named in APACHE_CONF_INCLUDE_FILES and
    # APACHE_CONF_INCLUDE_DIRS
    Include /etc/apache2/sysconfig.d/include.conf


    ### Virtual server configuration ############################################
    #
    # VirtualHost: If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at
    # <URL:http://httpd.apache.org/docs-2.0/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.
    #
    Include /etc/apache2/vhosts.d/*.conf


    # Note: instead of adding your own configuration here, consider
    # adding it in your own file (/etc/apache2/httpd.conf.local)
    # putting its name into APACHE_CONF_INCLUDE_FILES in
    # /etc/sysconfig/apache2 -- this will make system updates
    # easier


    locate libphp4.so gives nothing... How to compile php with apache ? what should i do next ?

  8. #7
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    Okay, since you have PHP installed at least, that means you compiled it without apache module support. Though this isn't "normal", it is okay. What you need to do is this:

    echo "Action php4-script /cgi-bin/php" >> /etc/apache2/httpd.conf
    echo "AddHandler php4-script .php .php3 .php4 .phtml" >> /etc/apache2/httpd.conf
    cp `which php` /usr/local/apache/cgi-bin/
    cat >> info.php << EOF
    <?php
    phpinfo();
    ?>
    EOF

    This is where I can't be sure of things. You will need to move that info.php into your DocumentRoot. However, I don't know what that is defined as. Once you do that, you can restart apache and try to access http://localhost/info.php which should give you a nice PHPInfo() page.

    This is not the same as perl. The first script you posted was a perl script, and should be executed if you have "Options +ExecCGI" turned on for the directory the perl program is located in.

    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  9. #8
    Just Joined!
    Join Date
    Sep 2004
    Location
    Sydney, Australia
    Posts
    42
    HI Samuel,

    Thanks for your reply. still i get an error when i execute php script. i did what exactly you mentioned. this is what i get

    Access forbidden!

    You don't have permission to access the requested object. It is either read-protected or not readable by the server.

    If you think this is a server error, please contact the webmaster.
    Error 403

    there is no apache directory in /usr/local, i created it now. I have php info page in /srv/www/htdocs. still no luck, same for .cgi script.
    what should i do now ?

  10. #9
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    Okay, first you need to find where your cgi scripts are being placed. You need to move that /usr/local/apache/cgi-bin/php binary to wherever that cgi-bin directory is. The output you pasted seems to have stated it was in /usr/local/apache, but it was probably wrong. Also, this is the error you get in your browser. This means nothing. Since you are the administrator, you get to see the actual error logs. Look at them. Maybe tell us what they say, hey?

    Once that php binary is in the right place, and is able to be executed by apache, and the info.php is 644 so that apache can read it, you should be in good shape.

    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  11. #10
    Just Joined!
    Join Date
    Sep 2004
    Location
    Sydney, Australia
    Posts
    42
    Still i don't understand quite a few things. Can you please explian in detail (step-by-step) ? I have the correct permission in the righ directory. what next ? Thanks for ur help.

Page 1 of 2 1 2 LastLast

Posting Permissions

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