PDA

View Full Version : How to config Apache 2.x PHP 5.x with SuPHP


longvnit
17th May 2009, 20:17
I used latest version of apache, php and suphp.
I compiled by command bellow :

### 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 admin@longvnit.net
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 !

bernholdt
18th May 2009, 01:51
Try this http://www.howtoforge.com/forums/showthread.php?t=29801&highlight=suphp Worked for me

longvnit
19th May 2009, 15:53
Please help me !

falko
20th May 2009, 17:39
Is there an index file (such as index.html) in the document root?

longvnit
20th May 2009, 17:49
i uploaded index.html , it show so good , but file php it show to like this :
http://upnhanh.sieuthinhanh.com/userimages/images/sieuthiNHANH2009052013921zwrhyjm0yj12338.jpeg

falko
21st May 2009, 19:50
Can you post the vhost configuration?
Any errors in Apache's error log?

longvnit
21st May 2009, 20:12
Error_log:

[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:


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


<VirtualHost *:80>
ServerAdmin webmaster@longvnit.net
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_UserGroup longvnit longvnit
<Directory "/home/longvnit/public_html">
Options -Indexes FollowSymLinks
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

falko
22nd May 2009, 17:26
You should have something like this in your vhost:
suPHP_Engine on
suPHP_UserGroup username groupname
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php

longvnit
25th May 2009, 02:24
I tried again, but it showed :

http://upnhanh.sieuthinhanh.com/userimages/images/sieuthiNHANH2009052013921zwrhyjm0yj12338.jpeg

falko
25th May 2009, 14:06
Did you restart Apache?
Does httpd -t show any errors?

longvnit
25th May 2009, 16:25
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();
?>

falko
26th May 2009, 23:56
You must set short_open_tag to 1 in your php.ini - see http://de.php.net/manual/en/ini.core.php