How to config Apache 2.x PHP 5.x with SuPHP

Discussion in 'HOWTO-Related Questions' started by longvnit, May 17, 2009.

  1. longvnit

    longvnit New Member

    I used latest version of apache, php and suphp.
    I compiled by command bellow :

    Code:
    ### compile apache
    ./configure \
    --prefix=/usr/local/apache \
    --enable-layout=Apache \
    --enable-modules=all \
    --enable-mods-shared=all \
    --enable-proxy \
    --enable-suexec \
    --enable-so \
    --with-mpm=prefork \
    --with-suexec-caller=apache \
    --with-suexec-userdir=public_html \
    --with-suexec-docroot=/home \
    --with-suexec-logfile=/dev/null \
    --with-suexec-safepath=/usr/local/bin:/usr/bin:/bin:/usr/home:/usr/sbin \
    --disable-dav \
    --disable-dav-fs
    
    
    ### compile php
    ./configure \
    --prefix=/usr/local/php \
    --with-mysql=/var/lib/mysql \
    --with-config-file-path=/etc \
    --enable-cgi \
    --enable-force-cgi-redirect \
    --enable-mbstring \
    --with-jpeg-dir=/usr/lib \
    --with-png-dir=/usr/lib \
    --with-zlib-dir=/usr/lib \
    --with-freetype-dir=/usr/lib \
    --without-sqlite \
    --with-mysql-sock=/var/lib/mysql \
    --with-bz2 --with-curl --enable-bcmath --enable-exif --with-gd \
    --with-zlib --enable-calendar --with-openssl --with-gmp \
    --enable-ftp --enable-magic-quotes --with-mcrypt --with-mhash --enable-ctype \
    --enable-tidy --enable-dom --with-libxml-dir=/usr/lib --enable-libxml --enable-xml \
    --enable-xmlreader --enable-xmlwriter --enable-zip --enable-shmop --enable-wddx \
    
    
    ### compile suphp
    ./configure \
    --prefix=/usr/local \
    --with-apache-user=apache \
    --with-apr=/usr/local/apache/bin \
    --with-logfile=/usr/local/apache/logs/suphp.log \
    --with-apxs=/usr/local/apache/bin/apxs \
    --with-min-uid=500 \
    --with-min-gid=500 \
    --with-apr=/usr/local/apache/bin
    
    
    ### Suphpconfig in /usr/local/etc/suphp.conf
    
    [global]
    ;Path to logfile
    logfile=/usr/local/apache/logs/suphp.log
    
    ;Loglevel
    loglevel=info
    
    ;User Apache is running as
    webserver_user=apache
    
    ;Path all scripts have to be in
    docroot=/home:${HOME}/public_html
    ;docroot=/
    ;Path to chroot() to before executing script
    ;chroot=/mychroot
    
    ; Security options
    allow_file_group_writeable=true
    allow_file_others_writeable=false
    allow_directory_group_writeable=true
    allow_directory_others_writeable=false
    
    ;Check wheter script is within DOCUMENT_ROOT
    check_vhost_docroot=true
    
    ;Send minor error messages to browser
    errors_to_browser=true
    
    ;PATH environment variable
    env_path=/bin:/usr/local/php/bin
    
    ;Umask to set, specify in octal notation
    umask=0133
    
    ; Minimum UID
    min_uid=500
    
    ; Minimum GID
    min_gid=500
    
    
    [handlers]
    ;Handler for php-scripts
    x-httpd-php="php:/usr/local/php/bin/php-cgi"
    
    ;Handler for CGI-scripts
    x-suphp-cgi="execute:!self"
    
    ### Suexec info
    
     -D AP_DOC_ROOT="/home"
     -D AP_GID_MIN=100
     -D AP_HTTPD_USER="apache"
     -D AP_LOG_EXEC="/dev/null"
     -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin:/usr/home:/usr/sbin"
     -D AP_UID_MIN=100
     -D AP_USERDIR_SUFFIX="public_html"
    
    ### httpd-vhosts.conf
    
    <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot "/home/longvnit/public_html"
        ServerName longvnit.net
        ServerAlias www.longvnit.net
        ErrorLog "logs/longvnit.net-error_log"
        CustomLog "logs/longvnit.net-access_log" common
        SuexecUserGroup longvnit longvnit
        suPHP_Engine on
        suPHP_AddHandler x-httpd-php
        suPHP_UserGroup longvnit longvnit
        suPHP_ConfigPath /etc/
    </VirtualHost>
    But when i used http://longvnit.net then Browser reported Error 403 : HTTP Error 403 Forbidden

    I sured that changed mode those folders to 755, files to 644. I used Centos OS 5.2 and Disabled SELinux.

    Please help me.
    Thanks so much !
     
    Last edited: May 17, 2009
  2. bernholdt

    bernholdt Member

  3. longvnit

    longvnit New Member

    Please help me !
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Is there an index file (such as index.html) in the document root?
     
  5. longvnit

    longvnit New Member

  6. falko

    falko Super Moderator Howtoforge Staff

    Can you post the vhost configuration?
    Any errors in Apache's error log?
     
  7. longvnit

    longvnit New Member

    Error_log:

    Code:
    [Thu May 21 04:11:54 2009] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
    [Thu May 21 04:11:54 2009] [notice] Digest: generating secret for digest authentication ...
    [Thu May 21 04:11:54 2009] [notice] Digest: done
    [Thu May 21 04:11:55 2009] [notice] Apache/2.2.11 (Unix) configured -- resuming normal operations
    httpd-vhost.conf:

    Code:
    AddHandler x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    
    
    <VirtualHost *:80>
        ServerAdmin [email][email protected][/email]
        DocumentRoot "/home/longvnit/public_html"
        ServerName longvnit.net
        ServerAlias [url]www.longvnit.net[/url]
        ErrorLog "logs/longvnit.net-error_log"
        CustomLog "logs/longvnit.net-access_log" common
        SuexecUserGroup longvnit longvnit
        suPHP_UserGroup longvnit longvnit
    <Directory "/home/longvnit/public_html">
        Options -Indexes FollowSymLinks
        AllowOverride AuthConfig FileInfo
        Order allow,deny
        Allow from all
    </Directory>
    </VirtualHost>
     
  8. falko

    falko Super Moderator Howtoforge Staff

    You should have something like this in your vhost:
    Code:
    suPHP_Engine on
    suPHP_UserGroup username groupname
    AddHandler x-httpd-php .php .php3 .php4 .php5
    suPHP_AddHandler x-httpd-php
     
  9. longvnit

    longvnit New Member

    I tried again, but it showed :

    [​IMG]
     
  10. falko

    falko Super Moderator Howtoforge Staff

    Did you restart Apache?
    Does
    Code:
    httpd -t
    show any errors?
     
  11. longvnit

    longvnit New Member

    oh. Thanks falko so much. I can't run info.php because I used tag : <? phpinfo();?> , this code can't run.

    But when i change to
    <?php
    phpinfo();
    ?>

    it run so good.

    My configuration does not error when i run command httpd -t: Syntax OK

    I want to ask that:
    How to run file php has format is:

    <?
    phpinfo();
    ?>
     
    Last edited: May 25, 2009
  12. falko

    falko Super Moderator Howtoforge Staff

Share This Page