Installere suPHP Centos 6

Wed 01 May 2013

Her er en rask gjenomgang av hvordan du kan installere suPHP på en Centos 6 server.

1: Laste ned suPHP arkivet

# mkdir software

# cd software

# wget

# tar xfzv suphp-0.7.1.tar.gz

2: Kompiler og installer mod_suphp

# cd suphp-0.7.1

# yum install httpd-devel

# ./configure --with-apr=/usr/bin/apr-1-config

# make

# make install

3: Konfigurering av mod_suphp og Apache

a) Vi trenger å konfigurere selve suphp. Jeg har valgt å legge konfigurasjonen i filen: "/usr/local/etc/suphp.conf".

;Path to logfile


;User Apache is running as

;Path all scripts have to be in

;Path to chroot() to before executing script

; Security options

;Check wheter script is within DOCUMENT_ROOT

;Send minor error messages to browser

;PATH environment variable

;Umask to set, specify in octal notation

; Minimum UID

; Minimum GID

;Handler for php-scripts

;Handler for CGI-scripts

b) Vi trenger å konfigurere Apache til å laste mod_suphp istedet for mod_php. Jeg har valgt å legge denne konfigurasjonen i følgende fil: "/etc/httpd/conf.d/suphp.conf".

# This is the Apache server configuration file providing suPHP support.
# It contains the configuration directives to instruct the server how to
# serve php pages while switching to the user context before rendering.

LoadModule suphp_module modules/

# This option tells mod_suphp if a PHP-script requested on this server (or
# VirtualHost) should be run with the PHP-interpreter or returned to the
# browser "as it is".
suPHP_Engine on

# Disable php when suphp is used, to avoid having both.
<IfModule mod_php5.c>
php_admin_flag engine off
<IfModule mod_php4.c>
php_admin_flag engine off

# To use suPHP to parse PHP-Files
AddHandler x-httpd-php .php
AddHandler x-httpd-php .php .php4 .php3 .phtml

# This option tells mod_suphp which path to pass on to the PHP-interpreter
# (by setting the PHPRC environment variable).
# Do *NOT* refer to a file but to the directory the file resides in.
# E.g.: If you want to use "/path/to/server/config/php.ini", use "suPHP_Config
# /path/to/server/config".
# If you don't use this option, PHP will use its compiled in default path.
# suPHP_ConfigPath /etc

# If you compiled suphp with setid-mode "force" or "paranoid", you can
# specify the user- and groupname to run PHP-scripts with.
# Example: suPHP_UserGroup foouser bargroup
# suPHP_UserGroup apache apache

# This option tells mod_suphp to handle requests with the type <mime-type>.
# Please note this only works, if an action for the handler is specified
# in the suPHP configuration file.
suPHP_AddHandler x-httpd-php

# This option tells mod_suphp to NOT handle requests with the type <mime-type>.
# suPHP_RemoveHandler <mime-type>

4: Sett opp din vhost til å bruke suphp

Jeg viser de ene statementet du trenger å legge til din allerede eksisterende vhost fil.

suPHP_UserGroup brukeren gruppen

5: Restart Apache

$ sudo service apache restart

6: Test at oppsettet fungerer som forventet

Legg følgende inn i en index.php

echo "I am running as user = ";

Når du åpner denne siden i nettleseren din er det altså brukeren som du har oppgitt i vhost filen som skal være den som kjører php scriptene og ikke apache brukeren.

Lykke til...

Tagged as : server centos php suphp


Tagged as : server centos php suphp